GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||
GeezerVison is showing github.com — Entry points proposal spec and implementation by guybedford · Pull Request #32 · nodejs/ecmascript-modules
This repository was archived by the owner on Apr 16, 2020. It is now read-only.
Conversation
|
|
I think a
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@ljharb glad to hear that! When no |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The file extension has the highest precedence. If the filename has If the file extension is ambiguous ( If If there is no |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
can it please be renamed to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
No. The point is to match
We considered Again, Stage 4 is designated for UX review and feedback. What we name things now doesn’t matter, everything is temporary until we get broader exposure and feedback from a wider audience of users. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
kinda unfortunate design 🤷 i guess we can discuss it later though
like i said, its fine to be "commonjs", it just needs to be updated in all the other places too.
personal reminder for |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
66aebb1 to
5374da9
Compare
There was an error while loading. Please reload this page.
|
What is the expected behavior of having colliding CLI flag and package.json? node -m bin/entryThe spec makes it look like |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The spec says that the flag will “tell Node to parse as ESM entry points that would otherwise be ambiguous.” Hence the flag throws on I would be wary of throwing in the example you listed above, because the user’s intent is clear. They need to tell Node the module type to use for the entry point either via a flag or We can always add more error-checking later on to increase the cases under which we throw errors; we don’t need to throw for this case. Even though we could, it’s probably much simpler UX to just tell users that |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
On further thought, I guess this is a case of user intent versus author intent. Currently author intent overrides user intent for file extensions but nothing else (I think). I could also see a UX case for user intent always taking priority. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I don't understand this statement. A package is unrelated to my question really except that it is used as a configuration point, only files have specific formats and the configuration points seem to have some conflict in this PR about specifying formats for files. The question isn't about if we can have dual mode packages, but rather what happens when a resource has conflicting configuration.
I don't understand this either, the user has 2 configuration points via CLI and package.json, and they are conflicting in my example. Since we have this conflict, why not just state that the conflict itself is an error "Cannot treat bin/entry.js as ESM via --type because a package.json has marked it as CJS" or somesuch; that would cause the user to resolve the conflict. To clarify, the design of this PR currently means that files are not having a well defined format statically, as they can be altered depending on how they are consumed. node --type=module bin/entry.js// bin/entry.js // package.json denotes this file as CJS // CLI denotes this file as ESM // works if loaded via CLI with --type=module // fails if loaded via static information from package.json import('./entry.js');
We don't need to do anything really since we can mandate any design decision we can agree upon and we can write up rationalizations afterwards. The concern I have is that we have multiple configuration points and they are contradicting each other. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@bmeck Sure, we can error if the package scope and For the purposes of development, though, I think that that can be a separate PR, if @guybedford doesn’t have time to add that before this week’s meeting. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Seems fine as a diff PR |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The other remaining thing we need to work out is how exactly dual-mode packages will work, since we would want to throw only if the flag conflicts with either way that a dual-mode package allows its files to be run. So maybe this error handling can be part of figuring out the details of how dual-mode packages can be specified by users and run by Node. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
55dcaf8 to
4228797
Compare
af0d1ef to
a63e09c
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Rubber stamp LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
please run CI before landing and make commit messages follow upstream guidelines |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Finally… this is an amazing step in my books 🙏 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
☝️ someone’s following along closely |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
4228797 to
39ba864
Compare
a63e09c to
3a71de7
Compare
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
CI all green, merged. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
How would libraries(in node_modules) provide a path to the module, considering that "pkg.main" already points to for example a "umd" source file. Will there be a "pkg.src" field in symmetry with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Currently in this implementation |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It doesn't preclude it if we do extension look up - you'd omit the extension (which is a reigning best practice anyways with cjs) and then have one extension for ESM and another for CJS. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
That's what I've been doing with Roff.js (and a few other projects published to NPM with both /* package.json */ { … "main": "./pan-and-zoom", … } With package contents like this: Are you saying this will stop working at some point? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Automatic extension resolution contradicts our goal of browser equivalence, so I assume it won't be enabled by default; though I expect it would be possible via opt-in configuration or a package-level loader. In ESM mode .js files are treated as ESM, so at the very least it would be confusing to rely on extensions for disambiguation. A better UX is probably a way to explicitly define each entry point. Such a new field would also allow specifications of other types of entry points, like for browsers (see the commonly used |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.