2016-01-12 59 views
2

這個url-scheme/protocol是什麼意思? meteor:// app/.....url scheme meteor:// app/..... meteorjs

我在瀏覽器開發工具中打開流星項目時看到了它。所有編譯/傳輸/縮小的文件都在http://localhost:3000之下。但是,源映射指向的所有源文件位於另一個名爲meteor的目錄中:// app

當我嘗試在瀏覽器中打開這些路徑時(或通過選擇在新選項卡中打開鏈接)它說它可以打開它們。

他們如何爲流星服務? 鉻調試工具如何訪問? chrome調試工具如何知道如何處理「meteor://」?

developer tools with http://location:3000 and meteor://..app

例如.js.map文件: {"version":3,"sources":["meteor://app/password_client.js"],"names"

回答

3

如果別人每奇蹟是如何工作的.....

原始的源代碼可以被包含在源地圖(sourcesContent)。如果你在那裏提供它,你可以在「sources」中放置你喜歡的任何路徑,開發工具會將它顯示在它自己的文件夾中,就像問題中的圖片一樣。

嘗試:

mkdir example 
cd example 
npm install babel-cli #needed to compile and create source map 

#create a hello world js website: 
echo "document.write('hello world') ; //spaces before ; will be removed in transpiled file" > hello.js 
echo "<script src='hello-compiled.js'></script>" > hello.html 

#create compiled version and source map 
node ./node_modules/babel-cli/bin/babel hello.js --out-file hello-compiled.js --source-maps 

cat hello-compiled.js #to see the generated map file 
sed -i 's/hello.js/sourcefiles:\/\/sourcesfiles\/hello.js/g' hello-compiled.js.map #change the local url to one with the new protocol 
cat hello-compiled.js #to see the map file after the change 
#(or just open up the file in an editor and change sources":["hello.js"] to sources":["sourcefiles://sourcefiles/hello.js"] 

rm hello.js #get rid of the original so that you don't see it in your sources 
#(you can always regenerate it with the echo command above) 

google-chrome hello.html #on ubuntu if you have chrome installed 
open hello.html #will probably work on osx 

##now look at sources in developer tools - you should see source files in theor own folder called sources 
#I had to ctrl-shift-r to see all the files 
#you should be able to add a breakpoint in the sourcefiles://sourcefiles/hello.js 
+0

真好!我一直都在想這個。 – oligofren