迁移到 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结尾