We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// 包裹前 const m = 1; module.exports.m = m; // 包裹后 function(exports,require,module,__ filename,__ dirname){ const m = 1; module.exports.m = m; }
node --v8-options | grep harmony
.mjs
--experimental-modules
import aa from 'aa.mjs
// a.mjs function aa() { console.log('aa'); } export default aa;
// b.mjs import aa from './test.mjs'; aa();
console.log('pre cc') function aa() { console.log('cc'); } export default aa;
**这里的输出比较有趣,可以看到是import的时候直接运行模块外面的全局代码,然后运行完所有import的代码才执行调用代码
node --experimental-modules bb.mjs # pre aa # pre cc # aa # cc
The text was updated successfully, but these errors were encountered:
No branches or pull requests
为什么node不支持ESM(ECMAScript module)?
node --v8-options | grep harmony
获取node最新特性.mjs
后缀来兼容ESMECM的实现
node 如何调用ECM
.mjs
和使用--experimental-modules
变量import aa from 'aa.mjs
直接修改aa的值,然后别的模块引入aa的值的时候也是最新的值**这里的输出比较有趣,可以看到是import的时候直接运行模块外面的全局代码,然后运行完所有import的代码才执行调用代码
The text was updated successfully, but these errors were encountered: