-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] esm: Import modules by https #21223
Conversation
Right now it is a basic prototype. I guess I inserted http loading in the invalid place. A lot of work needs to be done. But the basic idea is working
We can download different versions of the same module and it still will work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the pr! unfortunately this doesn't really fulfill what I think are some important prerequisites for this. 1) we should follow https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts and 2) we shouldn't need to use temp files.
because of this i am -1 on this change. I should clarify however that I do want to support importing from https URLs in the future.
This thing makes sense, like Codesandbox does, for example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, no.
This will break the ecosystem and significantly damage the security and stability of it.
Modules in npm
are already fetching files from thirdparty servers upon install, and fetching files from thirdparty servers in start-time would be much worse.
If this gets merged in the current state, packages in npm
will end up relying on this.
Currently, updates are installed only when manually requested and could be downgraded. With this, updates would propagate between launches and in some situations there would be no way to roll back (e.g. if the resource holds only the latest version). The users of this is also less likely to follow semver.
If we will make it easy for npm modules to load resources like this, this will end up blowing up much much worse than left-pad did. I don't think it's worth it.
Perhaps, the negative consequences could be minimized if loading-over-http would be allowed only for end programs, not from npm modules (or would be allowed only with an explicit opt-in flag), but I still am not sure that it brings any positive value even in that case.
To be explicit: -1 in the current form.
I agree with this, but I don't think that's the particular issue with this PR. What we may need is probably some sort of trusted service that makes rules about the integrity and versioning of these modules (kind of like the npm registry) and we can limit the origins of the modules to a whitelist (possibly configurable by users). (It would be even cooler to be able to load modules over P2P but being cool is not enough either). |
Very -1 on this. It completely changes alters the threat model for Node.js in ways that just aren't workable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also -1 for reasons others have mentioned.
If this were merged and released, it'd be minutes before the first feature request comes in to disable it globally (and rightly so.)
For some historic perspective: pull requests implementing some kind of over-the-wire require() have been filed - and rejected - since the start of the project.
Thanks for the effort (cc @nodejs/modules) - we intend (I think) to allow users to have this behaviour with loaders. This will be possible in Node.js - just not by default in core. If you want this to be brought up please do feel free to open an issue in https://github.com/nodejs/modules I'm also -1 for the reasons above - thanks a lot for your effort, consider making this a loader that can be released in userland and people can use :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Echoing the sentiment of @benjamingr. Just ensuring my -1 is explicit.
I will open the issue in the modules repo because I believe this loader can benefit some people. And I am fine if this feature won't be enabled in the core by default Thanks everyone for your feedback |
I think Deno got it right with sandboxing and security. Deno really solved the modular ecosystem with http imports IMO. |
Hi everyone,
I implemented basic version of esm over the internet idea. Example below is working.
I'd like to know from the community: what do you think?
Personally I am dying to see Node.js doing something like this. I just feel like
node_modules
managed bynpm
sometimes just gets overhead. It's how we got used to it - yeah. But it doesn't mean we can't experiment with other ideas, right?How
I basically added new
translator
calledhttp
where I am fetching (or if it's already there then reading from the disk) somethingNext
I am able to invest more time to it but I'd like to know if it will make sense. That is why WIP basically 😄
If yes then I'd like to see in this PR
import
statements (it's like in the browser right now - you get one script that has toexport default
)Checklist
Consider this PR more like a draft for now. Things will get done if I get green light
make -j4 test
(UNIX), orvcbuild test
(Windows) passes