-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
ESBuild unexpectedly sees .pnp.cjs
in monorepo project root
#3338
Comments
I don't have time to look into this at the moment, sorry. But this is similar to another situation that has come up before. You should be able to configure the top-level Yarn to ignore this subfolder. Here's a comment from someone who works on Yarn that says how to do that: #2495 (comment) |
@evanw , thank you for your comment! I found, following the link you've provided, a way to address the issue! I would say that the example needs to be followed fairly closely. ie: root project (with .pnp.cjs), then, some folders later, a project that's part of the main monorepo, then an otherwise empty folder containing the folder that itself contains the isolated project. It seems to need that extra containing folder to work correctly. In my case, there's (currently) only the one non-monorepo project, so it seemed like the containing folder could be omitted, but, I haven't seen a way to do that so far, and still have a generic glob pattern that's specific enough to avoid imposing this on other projects. ie:
It appears that when the non-monorepo project is resolving modules, it ascends the folder hierarchy, and as it does so, it encounters the monorepo .pnp.cjs, which appears to be informed as to the path of the child-project, and uses a regex to decide to play possum regarding any resources it might have. |
Since the existing Yarn-provided mechansim provides a work-around, I will close this issue. |
The situation
I have a monorepo that's using Yarn's Plug'n'Play, and within that, another project that's supposed to be pretty much stand-alone, and indicates this by setting in the local
.yarnrc.yml
,nodeLinker: node-modules
(ie: no Plug'n'Play).However, when I use a simple ESBuild invocation from within a node script to produce a result 'out.js', an error is appearing which indicates that the monorepo's root
.pnp.cjs
has been seen, and is being used, which is totally unexpected.How to reproduce an example of this behavior
I'm facing an issue that on the face of it, seems like perhaps it's an unexpected ESBuild behavior, but, if I'm omitting something, then please chime in, and help me get this set up so that it will work.
I've attached a minimal monorepo project to demonstrate the behavior I'm seeing.
monorepo.tar.gz
The attachment was created using the following command (for those that might be concerned):
To reproduce the problem behavior, follow these steps, assuming you have Yarn and a recent NodeJS installed:
Note: the following assumes you're using some kind of unix-like system:
tar -xzvf monorepo.tar.gz
cd monorepo
yarn set version berry
yarn install
.pnp.cjs
file in the current folder. Verify with:ls -al .pnp.cjs
. You should see details of the file being shown.cd esbuild
yarn install
app.js
to produceout.js
:node compile.js
Why is this not expected?
The child project (
monorepo/esbuild
) has a.yarnrc.yml
file there that contains:The
nodeLinker: node-modules
directive instructs Yarn to not use Plug'n'Play to resolve dependencies.However, it's clear that regardless of this, it appears that the monorepo-root folder-contained
.pnp.cjs
file is being seen and processed in some way.If I now hide the
.pnp.cjs
(eg: by renaming to.pnp.cjs.hidden
), and re-run the command, I do not see the error, and the expectedout.js
is created successfully.What do I think it should be doing
I think the resolution of modules should be ignoring
monorepo/.pnp.cjs
entirely, because the child project has the directive (inmonorepo/esbuild/.yarnrc.yml
) that indicates it is usingnode-modules
for dependency resolution.OK, it's entirely possible that there's some magic option somewhere that I've not found yet that addresses this issue. If that's the case, please, enlighten me!
The text was updated successfully, but these errors were encountered: