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

feat: Allow customized filter to be passed from external source #39

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

vctqs1
Copy link

@vctqs1 vctqs1 commented May 31, 2023

In my use case, I am utilizing esbuild in development mode and would like to externalize for the react and react-dom packages. However, I do not want to externalize the nested packages like react/jsx-runtime and react/jsx-dev-runtime.

plugins: [EsmExternals({ externals: ['react', 'react-dom'] })],

Currently, the makeFilter function defaults to a positive match for all cases, including react/jsx-runtime and react/jsx-dev-runtime. We have a corresponding test case available here.

To address this, I have introduced the ability to pass externals as regrex and customize by myself instead, allowing for customization.

const externalRegExp = new RegExp("^(" + ["react", "react-dom"].join("|") + ")$")
// this will make all react and react-dom packages externals, but not react/abc or react-dom/abc

build({
    plugins: [EsmExternals({ externals: externalRegExp })],
})

This pull request aims to implement this enhancement and improve the flexibility of the EsmExternalsPlugin.

Thank you for your consideration.

@vctqs1
Copy link
Author

vctqs1 commented May 31, 2023

@remorses Could you have a look and review this, thank you so much

@vctqs1
Copy link
Author

vctqs1 commented Aug 14, 2023

@remorses hi, could you help to review this PR, please help me know if I need to do anything else. Thank you

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.

1 participant