迁移到 EMS
参考:Pure ESM package (opens in a new tab)
步骤
- 将
package.json
中的type
改为module
tsconfig.json
配置参考
{
"compilerOptions": {
"target": "ESNext",
"module": "Node16",
"moduleResolution": "Node16",
"esModuleInterop": true,
"outDir": "./dist",
"removeComments": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
- 修改 import 语句的后缀,都需要以
.js
结尾