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 -
You've been advocating explicit extensions lately, but this is not how things have traditionally been. What happens with inferred paths, e.g `index.js` or whatever `package.main` says?
1 reply 0 retweets 2 likes -
Not just lately :) Explicit > implicit, IMHO. `package.main` is different; native modules don’t yet support bare specifiers. We’re working on making that happen.
1 reply 0 retweets 4 likes -
I mean more like import an index file by referencing a directory
2 replies 0 retweets 1 like -
This Tweet is unavailable.
It’s a “shorthand” that doesn’t work on the web, where `/foo/` doesn’t magically resolve to `/foo/index.js`. For language features, I prefer solutions that scale to multiple environments.
-
This Tweet is unavailable.
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.