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

🚀 Feature Request: support --no-bundle with static and dynamic ES Module imports #2697

Closed
IgorMinar opened this issue Feb 9, 2023 · 1 comment · Fixed by #2769
Closed
Assignees
Labels
enhancement New feature or request

Comments

@IgorMinar
Copy link
Contributor

Describe the solution

As a workaround for #2672 which requires more work, we could initially extend the --no-bundle to support uploading multiple files by traversing the entry-point module pointed to via main property, and extracting graph of modules imported via static and dynamic ES imports.

It would be sufficient if we initially supported dynamic imports with literal strings instead (i.e. not support import(someVariable).

There are various tools out there that can scan files for ES imports. I believe Vite uses some library that avoids building up the whole AST, but maybe we could just try using ESBuild first since we already depend on it, and use it just to extract the graph (and not do any code transformation).

@IgorMinar IgorMinar added the enhancement New feature or request label Feb 9, 2023
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Feb 9, 2023
@lrapoport-cf lrapoport-cf moved this from Untriaged to Backlog in workers-sdk Feb 18, 2023
@IgorMinar
Copy link
Contributor Author

We could use https://www.npmjs.com/package/es-module-lexer to quickly scan for dynamic imports to create a list of files to upload.

This library was also mentioned on #2766 so we could amortize the cost of this dependency across multiple use cases in wrangler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants