有一个使用ESM模块的TS 4.7库.
帖子主题:Re:Колибри
"target": "ES2020",
"module": "ES2020",
"lib": ["ES2020"],
"moduleResolution": "node",
Package.json
"type": "module",
我有一个主文件,其中只有一个愚蠢的导出:
Index.ts
export { Spig } from './spig';
它被编译为:
Index.js
export { Spig } from './spig';
//# sourceMappingURL=Index.js.map
问题
当我从Node CLI程序使用此库时(也启用了ESM模块),我收到以下错误:
Cannot find module <path>/lib/spig imported from <path>/lib/Index.js
When I manually add .js
in the generated Index.js
, the issue is gone:
export { Spig } from './spig.js';
我如何才能强制TypeScrip编译器也生成扩展?我错过了什么吗?