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

PathDisabled Flag is not exposed to plugins #3976

Open
ef4 opened this issue Nov 12, 2024 · 0 comments
Open

PathDisabled Flag is not exposed to plugins #3976

ef4 opened this issue Nov 12, 2024 · 0 comments

Comments

@ef4
Copy link

ef4 commented Nov 12, 2024

If a plugin uses build.resolve() to invoke default resolving behavior and esbuild decides that the path is disabled by "browser" in package.json, the answer returned to the plugin does not include any indication that the path is supposed to be disabled. The plugin sees a successful resolution, with an only-partially-resolved filename in the result (which can be missing its extension).

If the plugin decide to leave this resolution result unchanged, esbuild will error while trying to load the incorrect path. The fact that this path was supposed to be disabled has been lost.

Here is a tiny reproduction: https://github.com/ef4/esbuild-bug-repro which produces:

[~/hacking/bug-repro2]$ pnpm build                                                                                                                                                                  [main]

> esbuild-bug@1.0.0 build /Users/edward/hacking/bug-repro2
> node ./build.js

✘ [ERROR] Could not read from file: /Users/edward/hacking/bug-repro2/browser-disabled

    demo.js:1:19:
      1 │ import * as p from "./browser-disabled";
        ╵                    ~~~~~~~~~~~~~~~~~~~~

/Users/edward/hacking/bug-repro2/node_modules/.pnpm/esbuild@0.24.0/node_modules/esbuild/lib/main.js:1476
  let error = new Error(text);
              ^

Error: Build failed with 1 error:
demo.js:1:19: ERROR: Could not read from file: /Users/edward/hacking/bug-repro2/browser-disabled
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