Glad I could help! I was migrating one of my Node projects over to this new mjs style, and noticed that this could be a problem if people relied on data stored in their package.json or some other JSON file.
I'm guessing the new mjs thing is an all-or-nothing thing? I tried just adding the --experimental-modules flag on my existing app, and it didn't like it. However, I've finally had success getting my Vue front-end to send the data to the API, it process it, and return something that makes sense. (woo hoo!)
I'll defer playing with modules for a bit, though I do have an .mjs file there (you can old-style require them, too, if you add the extension) to remind me.
I'm guessing the new mjs thing is an all-or-nothing thing?
I believe that is the case. To be honest I do not know much about how Node works behind-the-scenes, but it appears that switching between --experimental-modules and CommonJS modules would be like using straight ES201* code or sending it through Babel.
... I do have an .mjs file there (you can old-style require them, too, if you add the extension) ...
Good to know! I like it because I don't have to switch headspace anymore when working on frontend and backend code.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Glad I could help! I was migrating one of my Node projects over to this new
mjs
style, and noticed that this could be a problem if people relied on data stored in their package.json or some other JSON file.I'm guessing the new
mjs
thing is an all-or-nothing thing? I tried just adding the--experimental-modules
flag on my existing app, and it didn't like it. However, I've finally had success getting my Vue front-end to send the data to the API, it process it, and return something that makes sense. (woo hoo!)I'll defer playing with modules for a bit, though I do have an
.mjs
file there (you can old-stylerequire
them, too, if you add the extension) to remind me.I believe that is the case. To be honest I do not know much about how Node works behind-the-scenes, but it appears that switching between
--experimental-modules
and CommonJS modules would be like using straight ES201* code or sending it through Babel.Good to know! I like it because I don't have to switch headspace anymore when working on frontend and backend code.