在打字稿构建上添加.js扩展
如果我将文件导入 *作为从'./dir/file''
的测试中的测试,则在构建中缺少.js扩展名,
我希望像this import *这样的输出文件从' ./dir/file.js'
问题是:是的,我可以手动添加.js,但是许多库没有手动添加.js扩展名,我不想浏览所有文件库并手动添加扩展名。
而且我知道那里有一些正则替代器添加.js扩展名。但这是唯一的方法吗?是否可以告诉Typescript添加.js(也许是通过tsconfig.json)???
If I import a file import * as test from './dir/file'
, the .js extension is missing in the build
I want the output file like this import * as test from './dir/file.js'
The problem is: YES I can add the .js manually BUT many libraries doesn't have the .js extension manually added, and I don't want to go through all files of a library and add the extension manually.
And I know there are some regex replacer out there which add the .js extension. But is this the only way?? Is there no way to tell TypeScript to add the .js (maybe via tsconfig.json)???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于此问题,有一个github问题,请查看在这里认为当前TS编译器是可能的。
There is a github issue opened about this, check it out here for workarounds, as I don't think it is possible with current ts compiler.