- Convert ES modules to CommonJS
- Convert CommonJS to ES modules
Before
import { a } from './a.js';
import b from './b.js';
export var c = 1;
export default 2
export default class Person { }
export default function(){}
After
const {a} = require('./a.js');
const b = require('./b.js');
var c = 1;
exports.c = c;
module.exports = 2;
Before
const {a} = require('./a.js');
const b = require('./b.js');
var c = 1;
exports.c = c;
module.exports = 2;
After
import { a } from "./a.js";
import b from "./b.js";
var c = 1;
export { c };
export default 2;
- 将 ES 模块转换为 CommonJS
- 将 CommonJS 转换为 ES 模块
转换前
import { a } from './a.js';
import b from './b.js';
export var c = 1;
export default 2
转换后
const {a} = require('./a.js');
const b = require('./b.js');
var c = 1;
exports.c = c;
module.exports = 2;
转换前
const {a} = require('./a.js');
const b = require('./b.js');
var c = 1;
exports.c = c;
module.exports = 2;
转换后
import { a } from "./a.js";
import b from "./b.js";
var c = 1;
export { c };
export default 2;