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

Regression: Since 0.15.0 can't resolve packages on Windows #2585

Closed
KingSora opened this issue Sep 30, 2022 · 2 comments
Closed

Regression: Since 0.15.0 can't resolve packages on Windows #2585

KingSora opened this issue Sep 30, 2022 · 2 comments

Comments

@KingSora
Copy link

KingSora commented Sep 30, 2022

Good day!

OS Version: Windows11 21H2
Node Version: 16.17.0

I'm using esbuild on windows and noticed that since version 0.15.0 packages can't be resolved properly. I'm also using WSL with Ubuntu without this issue.

I've created a minimal example:

// input.js
export * from 'react';
// esbuild.js
require("esbuild")
  .build({
    entryPoints: ["input.js"],
    bundle: true,
    outfile: "out.js",
  })
  .catch(() => process.exit(1));

When I'm running node esbuild with the 0.14.54 version, everything works. With version 0.15.0 and above I'm getting:

X [ERROR] Could not resolve "react"

input.js:1:14:
1 │ export * from "react";
╵ ~~~~~~~

You can mark the path "react" as external to exclude it from the bundle, which will remove this
error.

I've also attached a video for you.

2022-09-30.15-05-35.mp4
@evanw
Copy link
Owner

evanw commented Sep 30, 2022

I'm unable to reproduce this. I don't have access to a Windows machine myself but I ran the following on Windows in CI and it worked:

mkdir a
cd a
npm init -y
npm i esbuild@0.14.54 react@18.2.0
echo "export * from 'react';" > input.js
echo "require('esbuild').build({entryPoints:['input.js'],bundle:true,outfile:'out.js'}).catch(()=>process.exit(1));" > esbuild.js
node ./esbuild.js
cd ..

mkdir b
cd b
npm init -y
npm i esbuild@0.15.0 react@18.2.0
echo "export * from 'react';" > input.js
echo "require('esbuild').build({entryPoints:['input.js'],bundle:true,outfile:'out.js'}).catch(()=>process.exit(1));" > esbuild.js
node ./esbuild.js
cd ..

I'm guessing you have a parent directory with a Yarn PnP package manifest. If that's the case, you'll need to tell Yarn to exclude the folder you're currently trying to build in using ignorePatternData. See #2495 for an example of this case. This will likely need a newer version of esbuild than 0.15.0 since support for ignorePatternData was improved in version 0.15.8.

Edit: In any case, adding the logLevel: 'debug' option should provide more information about what specifically is failing.

@KingSora
Copy link
Author

I had a .pnp.cjs file in the home directory of my windows user... removing it solved the issue - Thanks!

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

2 participants