-
-
Notifications
You must be signed in to change notification settings - Fork 375
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
Lerna, Yarn & Workspaces path resolution wrong for preact
/ prerender.js
#1043
Comments
preact
/ prerender.jspreact
/ prerender.js
I just moved a preact app into my lerna monorepo that's using yarn workspaces and I'm encountering the same exact issue. Is there any workaround or progress on this? |
Running into the same issue as this when using preact-cli inside a mono-repo. Is there any progress on this issue? |
The only workaround for me was disabling yarn workspaces for lerna. |
Not ideal, but after install I just copy If you have everything in
|
Small workaround for now, add two packages to your "workspaces": {
"packages": ["packages/*"],
"nohoist": ["**/preact", "**/preact-render-to-string"]
}, But for the long run, a correct package resolution should be the way to go :) |
Do you want to request a feature or report a bug?
bug
What is the current behaviour?
Because of #803, which was a fix for #795 mono-repo configurations no longer resolves
preact
correctly and returns:✖ ERROR Template execution failed: Error: Cannot find module './node_modules/preact'
This is happening when using
lerna
,yarn
and aworkspaces
configuration.If the current behaviour is a bug, please provide the steps to reproduce.
Please use the following global packages and pkgmgr to reproduce:
yarn
preact-cli
lerna
Easy shell script:
https://gist.github.com/tomsiwik/901c1acb122c9bb18d513bb348b201ea
What is the expected behaviour?
preact
andpreact-render-to-string
should use commonnode_modules
path either withrequire('preact')
or relative to the module beeing used${__dirname}/../../../../preact
(fragile).One other solution is regexing for
__dirname
:const moduleRoot = __dirname.match(/.+(?<=.*node_modules)/gm)[0]
If this is a feature request, what is motivation or use case for changing the behaviour?
Workspaced lerna breaks now what used to work pre-fix.
See change: https://github.com/preactjs/preact-cli/pull/803/files#diff-dc9a93cd49896d6e2f0463ca332bf943L28
Please mention other relevant information.
Please paste the results of
preact info
here.preact-cli 2.2.1
The text was updated successfully, but these errors were encountered: