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?
-
-
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 -
explicit > implicit
2 replies 0 retweets 1 like -
So what you're saying is native modules will never support `main` in package.json? Because that's implicit and not explicit. Now when I want to use `foobar` package I'll have to do `./node_modules/foobar/path/to/main.mjs`? Good luck with that. I'll use `babel-node` over that ugly
2 replies 0 retweets 2 likes
Mathias Bynens Retweeted Mathias Bynens
I literally just said “we’re working on making that happen” in this very thread…https://twitter.com/mathias/status/996143144646266880 …
Mathias Bynens added,
-
-
But you also kept repeating yourself that explicit > implicit, and I'm not quite understanding because `package.main` is not explicit.
1 reply 0 retweets 0 likes -
Replying to @joshmanders @nzgb and
From the same tweet I quoted before: “`package.main` is different”
1 reply 0 retweets 0 likes - 2 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.