-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Polyfilling require
#2091
Comments
For common JS this should be possible - you just readFileSync the file and eval it (in some manor). However for loading ES modules, we need the #2054. |
I traced this back to #1938 but it's another issue. What's the current status? |
You can run rollup or another bundler on that file first and get an output without top level require - it's what I've done with Deno before when trying to "share code" between projects. |
I think properly polyfilling Both @benjamingr's solution and #2114 is a potential solution. #2114 would be the way that I think we should support it long term out of the box. |
@kitsonk I think it's even more complicated than that. With dynamic imports and top level await you wouldn't be able to implement require because it is synchronous and returns what was actually in |
@rsp it is significantly simpler to use a module bundler (like webpack, browserify or parcel) to transpile all the requires for you (and deal with the |
|
Too far away from the standard is not a good idea. ES Modules is good enough. |
Recently #3380 landed, does it resolve the issue? |
@bartlomieju I agree this could be closed. We might want to open another issue tracking Likely the polyfill issue can also be treated as Good First Issues (I believe some of them should not be too complicated) |
When importing a js file, of which, has top-level require in it, is there a way to polyfill those to use imports or something similar in order to get the script loaded?
Might be related to #2054 but it's not dynamic
The text was updated successfully, but these errors were encountered: