4 ms·
Assuming it has no imports or requires, and no references to meta, it’s a bare JavaScript file, and whether you treat it as esm or cjs shouldn’t matter, no?
by jwalton 3y ago
Assuming it has no imports or requires, and no references to meta, it’s a bare JavaScript file, and whether you treat it as esm or cjs shouldn’t matter, no?
- lhorie 3y agoJS has two top level grammars, one defaults to loose mode and the other defaults to strict mode, among other nuances. Possibly the most devious nuance is whether the spec's appendix B applies, which affects whether html comment syntax is valid (yes, this is a thing). The html comment token can therefore be parsed either as a comment or as a series of operators depending on the grammar being used. Effectively, this means it's possible to craft a program that does different things in CJS vs ESM mode.