-
-
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
Using same version of preact for pre-rendering #803
Conversation
Maybe we should add a note on that somewhere in the FAQ maybe? or Readme? |
about the comments i added? |
Well..... For users. I think users will expect the user-land preact to affect pre-rendering Preact. |
@hassanbazzi I updated the PR to use modules from user land instead its just that it has an added step of installing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you so much for picking this one up 👍🎉 Maybe we can add a test on top of the changes to make sure we don't regress here in any future versions 💯
Not entirely sure how to write a test for it |
This reverts commit 8f8f655.
:| this was breaking the current tests.... |
I already have it |
|
||
let preact = require('preact'), | ||
renderToString = require('preact-render-to-string'); | ||
const preact = require(require.resolve(`${cwd}/node_modules/preact`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, using a monorepo manager like lerna this workaround breaks the build process and returns:
✖ ERROR Template execution failed: Error: Cannot find module './node_modules/preact'
The cwd
is located inside root/packages/mypack
and is looking for a root/packages/mypack/node_modules
, which however is located in root/node_modules
. Node won't resolve correctly due to lernas or yarns module mgmt and thus this will break.
I reverted the changes and logged destination. A revert worked but I think changing the destination to: ${__dirname}/../../../../preact
and ${__dirname}/../../../../preact-render-to-string
would work too.
Not sure what's more elegant...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any workaround for this? I just moved a preact app into my monorepo to not have to maintain it in a separate repo, and I'm running into this exact error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexjsdev With Lerna and Yarn workspaces no. If you disable yarn workspaces this should work with Lerna though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #1418
Fixes #795
What kind of change does this PR introduce?
Fixes duplicate preact problem.
preact
. andpreact-render-to-string
from user land.preact-render-to-string
to local copy but wont work with preact-Xpreact-render-to-string
in all our template'spackage.json
Did you add tests for your changes?
Already exist
Does this PR introduce a breaking change?
No