Getting source maps working with evaluated code

后端 未结 2 1290
故里飘歌
故里飘歌 2021-01-03 04:25

I have a build script that runs all my code through uglifyjs, does a bunch of fancy caching stuff, and ultimately runs eval( code ) on some JavaScript files.

2条回答
  •  半阙折子戏
    2021-01-03 05:09

    I had a similar problem and the solution seem to be using an inlined SourceMaps (DataURL of a SourceMap).

    Here is an example:

    eval("blah blah\n//@ sourceMappingURL=data:application/json;base64,...");

    Seems like you can't reference external resources from an eval.

    I think you also need to use sourcesContent to insert the source code into the SourceMap.

    Tested with Chrome 32.

提交回复
热议问题