Skip to content
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

Dynamic module import #1050

Closed
dbauszus-glx opened this issue Dec 22, 2023 · 4 comments
Closed

Dynamic module import #1050

dbauszus-glx opened this issue Dec 22, 2023 · 4 comments
Assignees
Labels
Feature New feature requests or changes to the behaviour or look of existing application features.

Comments

@dbauszus-glx
Copy link
Member

dbauszus-glx commented Dec 22, 2023

It shouldn't be required to install node module per instance. Rarely required modules like SAML should be imported on demand.

There are a couple of experimental flags which can make this happen. These are subject to change hence we will have to wait for a future node release where these features become stable.

--experimental-network-imports

Importing network based modules using https: and http: is supported under the --experimental-network-imports flag. This allows web browser-like imports to work in Node.js with a few differences due to application stability and security concerns that are different when running in a privileged environment instead of a browser sandbox.

--experimental-vm-modules

The vm.Module class provides a low-level interface for using ECMAScript modules in VM contexts. It is the counterpart of the vm.Script class that closely mirrors Module Records as defined in the ECMAScript specification.

Unlike vm.Script however, every vm.Module object is bound to a context from its creation. Operations on vm.Module objects are intrinsically asynchronous, in contrast with the synchronous nature of vm.Script objects. The use of 'async' functions can help with manipulating vm.Module objects.

@dbauszus-glx dbauszus-glx added the Feature New feature requests or changes to the behaviour or look of existing application features. label Dec 22, 2023
@dbauszus-glx dbauszus-glx self-assigned this Dec 22, 2023
@dbauszus-glx
Copy link
Member Author

21.7 had a little nugget in this regard.

vm: support using the default loader to handle dynamic import()

@dbauszus-glx dbauszus-glx changed the title Dynamic node module import Dynamic module import Jun 21, 2024
@dbauszus-glx
Copy link
Member Author

This still feels like a long time away. Even if node would support this, vercel would need to support the node version and allow the modules to be written into the tmp directory.

It is more probably that an official deno run time becomes available which would support dynamic imports.

https://github.com/vercel-community/deno?tab=readme-ov-file#dynamic-imports

@dbauszus-glx
Copy link
Member Author

@dbauszus-glx
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature requests or changes to the behaviour or look of existing application features.
Projects
None yet
Development

No branches or pull requests

2 participants