-
Notifications
You must be signed in to change notification settings - Fork 46
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
Use a Node module in the prelude #45
Comments
The difficulty here is having require do the right thing inside a new VM context since you can't just pass in the parent context's require function... |
The problem is that the parent context's |
Possibly. I assume that if the module modified globals it would modify the parent realm too. |
ping @bterlson - this is the major barrier to being able to use test262-harness inside a polyfill/shim module as part of normal tests. |
@ljharb do you have any thoughts/suggestions for how to address the issues discussed above? |
No, I'm not sure; but i believe you could use something like https://www.npmjs.com/package/require-for to pass a |
@thorn0 @ljharb Would it be possible for you folks to use a tool like Webpack to bundle your polyfills into a string that could be injected via the I'm asking this not (just) because I'm lazy but because that approach is host-independent. Polyfill authors could use it to vet their libraries across hosts--not just Node.js. |
It might be possible but it would be inordinately complex, and the goal is to make using the harness easy. If the hostType is node, I would assume I could access node features properly in the prelude. |
I was attempting to run a test against the promise.allsettled shim and ran into this issue. I went with @jugglinmike's proposed solution of using Webpack to bundle what I needed into a prelude file. The webpack config and bundled file is here: astlaurent1/Promise.allSettled@631acd6. I suppose I could have done that in my fork of test262 After doing all that, in hindsight, it would seem relatively straightforward to support something like Pre-packaging the prelude like this also serves the added benefit of not "polluting" test cases with module/import semantics. The bundling provides a nice boundary between what you're preparing and what you're testing (P.S. See tc39/test262#2112 for discussions on testing |
This is what we're doing for the polyfill in proposal-temporal. It works, although it makes test runs painfully slow (I suspect) because the prelude has to be parsed and executed for every test file. |
I'd like to load a Node module in the prelude, but things like
require
,global
, etc. don't exist there. Would be great to have this possibility. (Currently, I'm concatenating files to create a working prelude).The text was updated successfully, but these errors were encountered: