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

Doesnt work with Yarn Berry (Workspaces) #137

Closed
SagnikPradhan opened this issue Apr 20, 2020 · 8 comments
Closed

Doesnt work with Yarn Berry (Workspaces) #137

SagnikPradhan opened this issue Apr 20, 2020 · 8 comments

Comments

@SagnikPradhan
Copy link

SagnikPradhan commented Apr 20, 2020

Describe the bug
Yarn requires a clear list of dependencies required, so it throws error when it tries to load any of the transformers

Logs

λ yarn rollup -c -w
rollup v2.6.1
bundles src/main.ts → public\build\bundle.js...
[!] (plugin svelte) Error: [svelte-preprocess] Error transforming 'typescript'.

Message:
svelte-preprocess tried to access typescript, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: typescript (via "typescript")
Required by: svelte-preprocess@virtual:d293af44cc1e0d0fc09cc0c8c4a3d9e5fccdf4ddebae06b8fad52a312360d8122c830d53ecc46b13c13aaad8c6ae7dbd798566bd5cba581433425b2ff3f7540b#npm:3.7.1 (via /D:/Sagnik/Projects/d-zone/.yarn/unplugged/svelte-preprocess-virtual-129fc9d93a/node_modules/svelte-preprocess/dist/transformers/)

[STACK-TRACE-1]

Stack:
Error: svelte-preprocess tried to access typescript, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: typescript (via "typescript")
Required by: svelte-preprocess@virtual:d293af44cc1e0d0fc09cc0c8c4a3d9e5fccdf4ddebae06b8fad52a312360d8122c830d53ecc46b13c13aaad8c6ae7dbd798566bd5cba581433425b2ff3f7540b#npm:3.7.1 (via /D:/Sagnik/Projects/d-zone/.yarn/unplugged/svelte-preprocess-virtual-129fc9d93a/node_modules/svelte-preprocess/dist/transformers/)

[STACK-TRACE-2]

To Reproduce

  1. Create a directory and use yarn set version berry
  2. Run yarn add lerna --dev and yarn lerna init
  3. Change lerna.json to
{
  "packages": [
    "packages/webapp",
    "packages/server"
  ],
  "npmClient": "yarn",
  "useWorkspaces": true,
  "version": "0.2.0"
}
  1. Create the same directory as https://github.com/sveltejs/template in packages/webapp and empty directory packages/server
  2. Run cd packages/webapp
  3. Run yarn install
  4. Run yarn add svelte-preprocess and change Rollup Config
  5. Run yarn add typescript --dev and yarn tsc --init
  6. Change main.js to main.ts and add lang="ts" to script tags
  7. Run yarn dev

Expected behavior
Run quietly and start the server

Stacktraces
If you have a stack trace to include, we recommend putting inside a <details> block for the sake of the thread's readability:

Stack trace
Require stack:
- D:\Sagnik\Projects\d-zone\.yarn\unplugged\svelte-preprocess-virtual-129fc9d93a\node_modules\svelte-preprocess\dist\transformers\typescript.js
- D:\Sagnik\Projects\d-zone\.yarn\unplugged\svelte-preprocess-virtual-129fc9d93a\node_modules\svelte-preprocess\dist\utils.js
- D:\Sagnik\Projects\d-zone\.yarn\unplugged\svelte-preprocess-virtual-129fc9d93a\node_modules\svelte-preprocess\dist\autoProcess.js
- D:\Sagnik\Projects\d-zone\.yarn\unplugged\svelte-preprocess-virtual-129fc9d93a\node_modules\svelte-preprocess\dist\index.js
- D:\Sagnik\Projects\d-zone\packages\webapp\rollup.config.js
- D:\Sagnik\Projects\d-zone\.yarn\cache\rollup-npm-2.6.1-6e29b31c16-2.zip\node_modules\rollup\dist\shared\loadConfigFile.js
- D:\Sagnik\Projects\d-zone\.yarn\cache\rollup-npm-2.6.1-6e29b31c16-2.zip\node_modules\rollup\dist\bin\rollup

Require stack:
- D:\Sagnik\Projects\d-zone\.yarn\unplugged\svelte-preprocess-virtual-129fc9d93a\node_modules\svelte-preprocess\dist\transformers\typescript.js
- D:\Sagnik\Projects\d-zone\.yarn\unplugged\svelte-preprocess-virtual-129fc9d93a\node_modules\svelte-preprocess\dist\utils.js
- D:\Sagnik\Projects\d-zone\.yarn\unplugged\svelte-preprocess-virtual-129fc9d93a\node_modules\svelte-preprocess\dist\autoProcess.js
- D:\Sagnik\Projects\d-zone\.yarn\unplugged\svelte-preprocess-virtual-129fc9d93a\node_modules\svelte-preprocess\dist\index.js
- D:\Sagnik\Projects\d-zone\packages\webapp\rollup.config.js
- D:\Sagnik\Projects\d-zone\.yarn\cache\rollup-npm-2.6.1-6e29b31c16-2.zip\node_modules\rollup\dist\shared\loadConfigFile.js
- D:\Sagnik\Projects\d-zone\.yarn\cache\rollup-npm-2.6.1-6e29b31c16-2.zip\node_modules\rollup\dist\bin\rollup
    at Object.makeError (D:\Sagnik\Projects\d-zone\.pnp.js:10171:34)
    at resolveToUnqualified (D:\Sagnik\Projects\d-zone\.pnp.js:17526:37)
    at resolveRequest (D:\Sagnik\Projects\d-zone\.pnp.js:17614:27)
    at Object.resolveRequest (D:\Sagnik\Projects\d-zone\.pnp.js:17682:26)
    at Function.module_1.Module._resolveFilename (D:\Sagnik\Projects\d-zone\.pnp.js:16879:34)
    at Function.module_1.Module._load (D:\Sagnik\Projects\d-zone\.pnp.js:16764:40)
    at Module.require (internal/modules/cjs/loader.js:1036:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (D:\Sagnik\Projects\d-zone\.yarn\unplugged\svelte-preprocess-virtual-129fc9d93a\node_modules\svelte-preprocess\dist\transformers\typescript.js:1:244)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)

Information about your project:

  • Your browser and the version: Doesn't Matter

  • Your operating system: Windows 7 32bit

  • svelte-preprocess version: 3.7.1

  • Whether your project uses Webpack or Rollup: Rollup

Additional context
None

@SagnikPradhan
Copy link
Author

IDK Why? But it works on a non workspace folder?

@SagnikPradhan
Copy link
Author

Seems like the temporary solution is to use https://yarnpkg.com/configuration/yarnrc#packageExtensions

@kaisermann
Copy link
Member

If people don't bother getting some warnings during a yarn/npm install, I can define the preprocessors as peerDependencies of the package. I'm not used to working with berry, but would that solve your issue?

@SagnikPradhan
Copy link
Author

You can define the preprocessors as peerDependencies and use peerDependenciesMeta to declare them as optional.

Reference: peerDependenciesMeta in NPM and Yarn

@kaisermann
Copy link
Member

kaisermann commented Apr 22, 2020

@SagnikPradhan Ahhh, interesting! Didn't know that existed. Would you know the difference between an peerDependency with the peerDependenciesMeta "optional" set to true, and an optionalDependency? Found it.

@kaisermann
Copy link
Member

@SagnikPradhan Just released 3.7.3 with explicit peerDeps. Can you check if it resolves your issue?

@SagnikPradhan
Copy link
Author

Seems like your forgot to add less as optional, reference.

Other than the warning everything works great!

@kaisermann
Copy link
Member

Heh, oops! Added it to 3.7.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants