-
-
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
Incompatible with Yarn 2 / berry #1046
Comments
I'm also having a similar issue with yarn 2, though my error message looks slightly different.
|
That can easily be fixed (although preact-cli should fix it themselves) Just add a .yarnrc.yml with the following contents: packageExtensions:
"preact-cli@*":
dependencies:
"mkdirp": "*" Side-note: to make preact-cli work right now, also add: nodeLinker: node-modules But that's not ideal |
Fair enough, thanks! Least got me able to use Yarn 2, even if it's less than ideal. |
@DerDrodt you're welcome to contribute a fix |
I tried to, but I am not really good with Webpack. Simply using require.resolve for all loaders didn't work. I don't really know enough about that |
@DerDrodt I was able to get it working with pnp-webpack-plugin. After installing this and configuring it (shown below), I just added a import { resolve } from "path";
import PnpWebpackPlugin, { moduleLoader } from "pnp-webpack-plugin";
export default {
webpack(config, env, helpers, options) {
// other stuff...
// Let webpack work with PnP stuff
config.resolve["plugins"] = [PnpWebpackPlugin];
config.resolveLoader["plugins"] = [moduleLoader(module)];
},
}; It would probably be a little bit non-trivial to fix up preact to work for this, but it would basically entail adding another check for some kind of .pnp.js and adding in the |
Using node linker in .yarnrc.yml solved this problem for me: |
For anyone who stumbles on this in the future. As some of the others have stated, Preact is not handling dependencies properly and relies on awkward behavior. You do not need to modify your .yarnrc.yml, just add the You also do not need to enable the node-modules linker, you can abuse the same awkward behavior the preact-cli uses to accommodate the build process.
const { ensureDirSync, copySync} = require('fs-extra')
const { dirname } = require('path')
const preact = require.resolve('preact')
const preactRenderToString = require.resolve('preact-render-to-string')
ensureDirSync('./node_modules/')
copySync(preact, './node_modules/preact.js')
copySync(dirname(preactRenderToString), './node_modules/preact-render-to-string') |
Do you want to request a feature or report a bug?
Feature
What is the current behaviour?
When running the CLI with Yarn 2, because of Plug'n'Play, we get an error:
If the current behaviour is a bug, please provide the steps to reproduce.
Install Yarn 2 and run
preact build
What is the expected behaviour?
It should be able to build with Yarn 2
If this is a feature request, what is motivation or use case for changing the behaviour?
Developers will want to use the new version of Yarn.
Please mention other relevant information.
As far as I can tell, the problem is that the loaders in the Webpack configs are not declared using
require.resolve
. Doing so would allow us to use the pnp-Webpack-pluginPlease paste the results of
preact info
here.version 2.2.1
The text was updated successfully, but these errors were encountered: