url scheme meteor:// app / ..... in meteorjs

时间:2016-01-12 23:53:00

标签: meteor source-maps

这个url-scheme / protocol是什么意思?流星://应用程序/ .....

当我在浏览器开发者工具中打开一个流星项目时,我看到了它。所有编译/转换/缩小的文件都在http://localhost:3000下。但是,源映射指向的所有源文件都位于另一个名为meteor:// app

的目录中

当我尝试在浏览器中打开这些路径时(或者在新标签中选择“打开链接”)时,它表示无法打开它们。

他们是如何被流星服务的? 如何通过chrome调试工具访问? chrome调试工具如何知道如何处理“meteor://”?

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

.js.map文件中的

示例: {"version":3,"sources":["meteor://app/password_client.js"],"names"

1 个答案:

答案 0 :(得分:3)

如果有其他人都想知道这是如何运作的......

原始源代码可以包含在源映射(sourcesContent)中。如果您在那里提供它,您可以在“源”中放置您喜欢的任何路径,开发工具会将其显示在自己的文件夹中,如问题中的图片所示。

尝试:

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