When it's able to use ESModule in Node.js, I just need to delete index.js and rename index.mjs file to index.js,then it should works.
But I notice docs ".mjs files are limited to basic functionality without support for esm options.",
which means my thought above will not work for options in .esmrc.json won't work.
And when try it locally, it throw errors "can't not load module from .mjs",after I change .mjs to .js,the error disappear。
So is there a smooth and convenient upgrade solution recommended?
Before Node.js finally support ESModule, I apply
esm
to my project. For upgrading smoothly once Node.js support it, I draw a plan like this:index.mjs
where I wrote my code with ESModuleindex.js
, and codes inner like this:When it's able to use ESModule in Node.js, I just need to delete
index.js
and renameindex.mjs
file toindex.js
,then it should works.But I notice docs ".mjs files are limited to basic functionality without support for esm options.", which means my thought above will not work for options in
.esmrc.json
won't work. And when try it locally, it throw errors "can't not load module from .mjs",after I change .mjs to .js,the error disappear。So is there a smooth and convenient upgrade solution recommended?