4 ms·
What’s the overall feeling on using .mjs files? My initial thoughts were “urgh I just want to have .js files in my projects” but I’m wondering if I’ll warm to
by mjgs 5y ago
What’s the overall feeling on using .mjs files?
My initial thoughts were “urgh I just want to have .js files in my projects” but I’m wondering if I’ll warm to them given that they make things a lot easier.
Are people eventually just all going to use .mjs files for everything?
- shriek 5y agoIf you have package.json file you can still use .js file with 'type: module' in package.json. https://nodejs.org/api/esm.html#esm_enabling https://nodejs.org/api/esm.html#esm_enabling
- mjgs 5y agoYeah but it seems like it might be easier to just start using .mjs everywhere, no?
- ranguna 5y agoI don't think so.
- mjgs 5y agoI know it’s a bit of an apples and pears comparison, but which part of changing the file extension feels more difficult than editing package.json? I’m thinking about new projects rather than converting existing projects. One benefit I can see to .mjs is that if all extensions are .mjs it’s clear what type of project it is without the need to open up package.json.
- ranguna 5y agoWith the context you've added now, I might agree. Existing projects would be a pain to rename all files compared to adding a single line to the package.json . About new projects, I'd have to read more about this new extension, for some reason it feels like a temporary solution that'll just get merged to the normal js extension in a future release.
- mjgs 5y agoYeah it totally has the feel of a temporary solution. From what I’ve read though, there doesn’t appear to be much of a plan apart from the current solution. My initial reaction is that I want to keep all my files with .js extension. One thing that could potentially be problematic is for files that need to run in the browser and on the server. Really curious to see where the community’s tea leaves settle. My guess is that people will eventually just start using the new extension.