Skip to content

Work around vercel/ncc import issues#3329

Open
kewisch wants to merge 1 commit into
mozilla:masterfrom
kewisch:ncc-fix
Open

Work around vercel/ncc import issues#3329
kewisch wants to merge 1 commit into
mozilla:masterfrom
kewisch:ncc-fix

Conversation

@kewisch

@kewisch kewisch commented Jan 5, 2025

Copy link
Copy Markdown
Contributor

Here is a workaround so web-ext compiles with vercel's ncc. It doesn't like dynamic imports, but will happily ignore them if indirect. Any chance you'd accept this patch?

See vercel/ncc#935 for details.

@Rob--W Rob--W left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a hack to work around ncc. We're not in favor of such a hack.

The purpose of the code here is to evaluate a config file as JS code and use its result. The use of nonce shows that import() is not exactly the perfect API here, because of its module caching behavior.

We are willing to consider non-hacky alternatives, such as logic that uses the vm module to execute code (https://nodejs.org/api/vm.html).

@kewisch

kewisch commented Feb 5, 2025

Copy link
Copy Markdown
Contributor Author

I think vm might not work without --experimental-vm-modules for ESM config files, but I'll see if there is another way to solve this. Let me know if you have ideas!

@Rob--W

Rob--W commented Mar 13, 2025

Copy link
Copy Markdown
Member

readFile + eval (maybe with source map comment to attribute the file correctly if there is an error in it)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants