[英]Original source of typescript from compiled javascript and source map
I havent used sourcemaps and typescript before, so please bear that in mind. 我以前没有使用过sourcemap和typescript,因此请记住这一点。
I have to work with a project which was compiled to single javascript file from multiple typescript files. 我必须处理一个项目,该项目已从多个打字稿文件编译为单个javascript文件。
I have available these files: 我有以下文件:
lib.js (the compiled js code of the project)
lib.js.map (the source map of the lib.js)
lib.d.ts (the "header" of the lib.js before it was compiled)
So I tried to view the original source files (original .ts files) in a browser but they are all blank in chrome and firefox outputs this message in them: 因此,我尝试在浏览器中查看原始源文件(原始.ts文件),但是在chrome中它们都是空白的,并且firefox在其中输出此消息:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /path/source/file/file.ts was not found on this server. </p>
</body></html>
Can I somehow view the original .ts files, the compiled lib.js file is huge (2MB+) and it is a nightmare to work with. 我能以某种方式查看原始的.ts文件吗,编译后的lib.js文件很大(超过2MB),并且无法正常工作。
Thanks for the help in advance! 我在这里先向您的帮助表示感谢!
See if the last line of you generate .js file is the path for your map file. 查看生成的.js文件的最后一行是否是地图文件的路径。 The path must be relative if you use Chrome or Firefox.
如果您使用的是Chrome或Firefox,则该路径必须是相对的。 if the path is absolute you get a 404 error.
如果路径是绝对路径,则会出现404错误。 Change this:
更改此:
//# sourceMappingURL:X;/path/AdvantageClientAD.js.map //#sourceMappingURL:X; /path/AdvantageClientAD.js.map
To this: //# sourceMappingURL:AdvantageClientAD.js.map 为此://#sourceMappingURL:AdvantageClientAD.js.map
This work if your ts files are in the same project as the .js files are deployed. 如果您的ts文件与部署的.js文件位于同一项目中,则此方法有效。 But not if you have your typescript files in other project.
但是如果您在其他项目中有打字稿文件,则不会。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.