Skip to content

How to specify different conditions for different packages? #4167

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

Open
wszgrcy opened this issue May 4, 2025 · 0 comments
Open

How to specify different conditions for different packages? #4167

wszgrcy opened this issue May 4, 2025 · 0 comments

Comments

@wszgrcy
Copy link

wszgrcy commented May 4, 2025

I know we can specify the type for packages uniformly: https://esbuild.github.io/api/#conditions
But for some packages, I prefer to manually specify the conditions (due to the quirk of dependencies)
I want to use

   build.onResolve({ filter: new RegExp('buffer-crc32') }, async (args) => {
        args;
        build.resolve(args.path,)
        return null;
      });

But 'resolve' does not provide an option such as conditions: ['xxx ','yy']
If I want to modify the parsing, it can only be manually implemented, so can I expose this part of the functionality for plugin development?
like:

   build.onResolve({ filter: new RegExp('buffer-crc32') }, async (args) => {
        args;
        build.resolve(args.path,{conditions:['import','require']})
        return null;
      });
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

No branches or pull requests

1 participant