question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use .mjs for JavaScript modules

See original GitHub issue

Squoosh is mostly using TypeScript (.ts), but it also uses .js for https://github.com/GoogleChromeLabs/squoosh/blob/master/src/lib/fix-pmc.js despite it being a module.

Let’s follow our own advice and use .mjs to denote JS modules as opposed to classic scripts.

If this is a problem for our current toolchain, it would be good to identify the problem and raise it upstream.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
developitcommented, Jul 4, 2018

Grabbing this since it’s a quick change.

@mathiasbynens - we need to get Webpack to include .mjs in its list of default extensions for module resolution.

0reactions
frank-dspeedcommented, Mar 17, 2020

and maybe you should consider my suggestion to turn all files into .js then marking the package in package.json as type: module and use typescript with checkJs: true flag and use JSDOC annotations you can then still type check while working with nativ modules till they accept .mjs

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use MJS files in Node.js? - DEV Community ‍ ‍
1. Create a ES Module / MJS File · 2. Import your code · 3. Set your package type to "module".
Read more >
JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax.
Read more >
MJS - Node.js ES Module Javascript File
A file with .mjs extension is a JavaScript source code file that is used as an ECMA Module (ECMAScript Module) in Node.js applications....
Read more >
What is the difference between .js and .mjs files?
mjs an extension for EcmaScript modules · An MJS file is a source code file containing an ES Module (ECMAScript Module) for use...
Read more >
Files with .mjs extension for JavaScript modules - Medium
mjs is the extension for EcmaScript module files. Node.js or webpack are already handling them and we better know what it means before...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found