简体   繁体   English

来自已编译javascript和源代码映射的打字稿的原始来源

[英]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.

相关问题 Javascript / Typescript映射较大对象的源对象属性 - Javascript/Typescript map a source object properties from a larger object 我可以从缩小版本和相应的源映射文件重新构建原始 JavaScript 源文件吗? - Can I re-construct the original JavaScript source file from a minified version and the corresponding source-map file? 源地图行为-如何在缩小之前查看原始JavaScript - Source Map Behavior — how to view original javascript before minification 从 uglifyjs 源映射中恢复 javascript 源代码 - Recover javascript source code from uglifyjs source map 生成从Coffeescript编译的多个串联javascript文件的源映射 - Generating source maps for multiple concatenated javascript files compiled from Coffeescript 阅读 JavaScript-TypeScript 源映射并在另一个中显示代码 - Read JavaScript-TypeScript source map and reveal code in another one 离子2打字稿源图未创建 - ionic 2 typescript source map not created Chrome 源未显示从 Typescript 生成并具有源映射的文件 - Chrome sources not showing a file that was generated from Typescript and has a source map TypeScript 与 Webpack - 显示 JavaScript 但不显示 Z558B544CF685F39D34EZC403 源映射 - TypeScript with Webpack - Shows JavaScript but not TypeScript source maps 如何通过查看源代码来区分 typescript 和 javascript? - How can I distinguish typescript from javascript by looking at the source code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM