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

Feature Request: Support for yarn 2 pnp #26

Open
mikevalstar opened this issue Jun 19, 2020 · 4 comments
Open

Feature Request: Support for yarn 2 pnp #26

mikevalstar opened this issue Jun 19, 2020 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mikevalstar
Copy link

As part of yarn 2 they are adding a new method of accessing dependencies: pnp

https://classic.yarnpkg.com/en/docs/pnp/
https://classic.yarnpkg.com/en/docs/pnp/getting-started

since you're using webpack this can be supported using

https://github.com/arcanis/pnp-webpack-plugin

Thanks

@mikevalstar mikevalstar changed the title feature Request: Support for yarn 2 pnp eature Request: Support for yarn 2 pnp Jun 19, 2020
@mikevalstar mikevalstar changed the title eature Request: Support for yarn 2 pnp Feature Request: Support for yarn 2 pnp Jun 19, 2020
saltyshiomix added a commit that referenced this issue Jun 19, 2020
@saltyshiomix saltyshiomix added enhancement New feature or request good first issue Good for newcomers labels Jun 19, 2020
saltyshiomix added a commit that referenced this issue Jun 19, 2020
saltyshiomix added a commit that referenced this issue Jun 19, 2020
saltyshiomix added a commit that referenced this issue Jun 19, 2020
@saltyshiomix
Copy link
Owner

Hi @mikevalstar , thank you for your feature request!

I just added support for yarn2 pnp, but we must add runtime dependencies like this:

{
  "dependencies": {
    "@babel/core": "^7.10.3",
    "@babel/plugin-proposal-class-properties": "^7.10.1",
    "@babel/plugin-proposal-object-rest-spread": "^7.10.3",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@babel/plugin-transform-react-jsx": "^7.10.3",
    "@babel/plugin-transform-runtime": "^7.10.3",
    "@babel/preset-env": "^7.10.3",
    "@babel/preset-react": "^7.10.1",
    "@babel/preset-typescript": "^7.10.1",
    "@babel/runtime-corejs3": "^7.10.3",
    "@react-ssr/core": "latest",
    "@react-ssr/express": "latest",
    "babel-plugin-css-modules-transform": "^1.6.2",
    "babel-plugin-react-require": "^3.1.3",
    "express": "^4.17.1",
    "lz-string": "^1.4.4",
    "pnp-webpack-plugin": "^1.6.4",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "urlsafe-base64": "^1.0.0"
  },
  "installConfig": {
    "pnp": true
  }
}

(Because react-ssr uses lots of babel configs and tricky server side rendering. (e.g. lz-string))

Any ideas?

Because of this, I think pnp is currently not supported with NEXT.js

@saltyshiomix
Copy link
Owner

If you have some time, please try examples/support-yarn2-pnp :)

Another way is to use @react-ssr/core@^0.24.0 and @react-ssr/express@^0.24.0(or @react-ssr/nestjs-express@^0.24.0) 👍

@mikevalstar
Copy link
Author

mikevalstar commented Jun 20, 2020

amazing; works great. (I am and was using @react-ssr/express)

I am getting an error/warning when booting (this does not cause any bad effects, but thought I would point it out)

ERROR in ./react-ssr-src/entry-index.jsx
Module not found: Error: Can't resolve '/Users/mikevalstar/projects/abc/.yarn/$virtual/@react-ssr-core-virtual-58ce43c274/0/cache/@react-ssr-core-npm-0.24.0-9e73bff365-698deb1492.zip/node_modules/@react-ssr/core/dist/development/app.js' in '/Users/mikevalstar/projects/abc/react-ssr-src'
@ ./react-ssr-src/entry-index.jsx 6:0-217 16:51-54

@mikevalstar
Copy link
Author

They are changing how they do dependencies in yarn 2 so I think adding the runtime dependencies like you have done is correct. This is still one of the major working items with Yarn 2 as far as I have been following.

https://dev.to/arcanis/introducing-yarn-2-4eh1#deprecating-bundle-dependencies

I actually dont use Next.js for any of my current projects but they did put support into their roadmap: https://github.com/vercel/next.js/milestone/22?closed=1

As a bit of an aside and background, the project(s) I'm currently working on are for a client that has a couple of issues that Yarn 2 solves:

  • Their build server has a very limited internet connection (yes i know)
  • Their prod server does not have an internet connection
  • The client wants more control over the packages in the app (to do code scans), and checking in the yarn cache folder is not ideal

So our ideal solution is to include the packages in the repo so the app can deploy and boot faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants