import/export are static statements though
-
-
I'm not sure I understand what you mean by that. How would you know to use cjs or es modules without parsing the file?
1 reply 0 retweets 0 likes -
Parse until the first import or export. It's really not that hard.
2 replies 0 retweets 6 likes -
Not having to parse at all seems simpler, no?
3 replies 0 retweets 14 likes -
This is not simpler no. File extensions are a terrible way to detect the type of anything.
1 reply 0 retweets 8 likes -
Why? Node.js has been doing it from the start. Compare e.g. require('a.json') vs. require('b.js').
2 replies 0 retweets 0 likes -
Not just Node, MIME DBs usually use file extensions
1 reply 0 retweets 0 likes -
Replying to @bradleymeck @mathias and
Infrastructure usually detects the mime types by more than simply looking at extensions. Should you trust that an image is a jpeg just because it says it is? Detection > TakingOnFaith
1 reply 0 retweets 0 likes -
/me stares at all sorts of libraries in languages for MIME and file formats with conflicting/no header
1 reply 0 retweets 0 likes -
Replying to @bradleymeck @mathias and
The most important file types on the web can be detected by looking at the first dozen bytes or so. Why trust the extension only (or at all)?
2 replies 0 retweets 0 likes
On the web, the extension doesn’t matter at all. <script type=module> tells the browser it is a module, and if the MIME type checks out, that’s all it needs. Node.js lacks <script> and thus needs another signal, and it doesn’t have MIME types. https://www.youtube.com/watch?v=mIWCLOftfRw&list=PLNYkxOF6rcIC4NQeXpdAy0RbOACI66Hvf&index=12&t=8m08s ….
-
-
Replying to @mathias @bradleymeck and
Sure. But this solution means that we no longer have a symmetrical situation. *.mjs will become the default file extension for all module js files even those will consumed by browsers.
1 reply 0 retweets 0 likes -
File extensions may mean "nothing" on the web but adding a new one still seems to me a high price to pay for what is essentially a hack.
1 reply 0 retweets 0 likes - 4 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.