@0x706b/ts-transform-fix-esm 中文文档教程
ts-transform-fix-esm
Disclaimer
这个变压器是实验性的; 需要您自担风险使用它。
Description
向模块说明符添加文件扩展名和/或索引,并在 ESM 环境中正确需要 commonjs 模块。
例如:
import { thing } from "commonjs/file";
import { anotherThing } from "esm/folder"
成为
import { anotherThing } from "esm/folder/index.js";
import { createRequire as __createRequire } from "module";
const __require = __createRequire(import.meta.url);
const { thing } = require(commonjs/file);
ts-transform-fix-esm
Disclaimer
This transformer is experimental; use it at your own risk.
Description
Adds file extension and/or index to module specifiers and correctly requires commonjs modules in an ESM environment.
For example:
import { thing } from "commonjs/file";
import { anotherThing } from "esm/folder"
becomes
import { anotherThing } from "esm/folder/index.js";
import { createRequire as __createRequire } from "module";
const __require = __createRequire(import.meta.url);
const { thing } = require(commonjs/file);