Missed the list somehow... ---------- Forwarded message ---------- From: Isiah Meadows <[email protected]> Date: Tue, May 8, 2018 at 8:43 PM Subject: Re: Dynamic `import` with options To: Peter Jaszkowiak <[email protected]>
Here's three scenarios that aren't even possible without it: - Hot reloading: https://github.com/nodejs/node/issues/8443 - Loading modules uncached: - https://www.npmjs.com/package/import-fresh - https://github.com/nodejs/node/issues/8443#issuecomment-382316960 - Automatic re-runs of module-based tests in the browser. - Loading modules with mocks: - https://www.npmjs.com/package/proxyquire - https://www.npmjs.com/package/mock-require - https://nodejs.org/api/esm.html#esm_dynamic_instantiate_hook (requires a synthetic module and a lot of boilerplate to do it, though) There's other use cases, too: - Integrating `import` with `WebAssembly.instantiate`: https://webassembly.org/docs/js/#webassemblyinstantiate - Easier importing relative to another directory (important when dependencies get involved). ----- Isiah Meadows [email protected] www.isiahmeadows.com On Tue, May 8, 2018 at 8:04 PM, Peter Jaszkowiak <[email protected]> wrote: > What are some use cases, and how are they easier done this way than through > existing alternatives, like returning a factory function. > > On May 8, 2018 17:57, "Isiah Meadows" <[email protected]> wrote: > > Yeah, it's about that time. I'm proposing adding support for an > options object as a second "argument" for the call-like `import()`, > something like `import("./foo.mjs", {...options})`. To complement > this, I also propose adding a hook to allow embedders to optionally > return something different from the call rather than the usual import > and/or change the way something is imported. > > ----- > > Isiah Meadows > [email protected] > www.isiahmeadows.com > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > > _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

