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

[pnpm] export detection not working for auto-detect packages (react-is, etc) #12

Closed
fineline opened this issue Mar 4, 2019 · 13 comments
Labels
bug Something isn't working contributors welcome! contributors welcome!

Comments

@fineline
Copy link

fineline commented Mar 4, 2019

Update from maintainers: See discussion below for updated issue: #12 (comment)


I use pnpm as an alternative npm client (because it uses a central module repo and symlinks, which saves tons of disk space). When following the guide in README, I replaced this line:

$ npx @pika/web

with

$ pnpx @pika/web

which gave error:

npx: command not found: web

So looking further down at the optional npm prepare script step, I saw that referenced "pika-web" and tried that instead:

pnpx pika-web

Which seems to have worked much better. Not sure if the original version works properly with npx as I don't use it, but this version definitely seems better on pnpx.

@FredKSchott
Copy link
Owner

This sounds like thiir CLI doesn't support scoped packages, which is a bug on their end. Do you have any info on pnpx usage stats?

@fineline
Copy link
Author

No I don't. I find it much better than npm / yarn as it keeps a centralised module store instead of loading the full content of each module into each project, which also makes it much quicker to do installs etc., but most other developers I know have never heard of it. Feel free to close this issue if the original documentation works with normal npm client.

@FredKSchott
Copy link
Owner

Yea, this seems more like an issue with pnpx not matching npx correctly. Will close this issue for now, but if enough people continue to run into it we can reopen and see how the README can be clarified to point out the pnpx mismatch.

@FredKSchott
Copy link
Owner

Thanks for trying the tool out!

@idkjs
Copy link

idkjs commented Jan 15, 2020

@fineline you ever figure this out?

@FredKSchott
Copy link
Owner

Now that the library name doesn't have an "@", pnpx snowpack should work as expected. @idkjs are you still having trouble running?

@idkjs
Copy link

idkjs commented Jan 15, 2020

Just learned about snowpack today while trying to compile some es6. I tried running this demo: https://github.com/ryanlanciaux/snowpack-demo. Works with yarn. But trying with pnpm install the script get stuck once it call npx snowpack with this error:Error: 'isElement' is not exported by node_modules/.pnpm/registry.npmjs.org/react-is/16.12.0/node_modules/react-is/index.js.

full output:

 WARN  styled-components@5.0.0 requires a peer of react@>= 16.8.0 but version 0.1.0 was installed.
 WARN  styled-components@5.0.0 requires a peer of react-dom@>= 16.8.0 but version 0.1.1 was installed.
 WARN  styled-components@5.0.0 requires a peer of react-is@>= 16.8.0 but none was installed.
Packages: +442
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Resolving: total 442, reused 425, downloaded 17, done
node_modules/.pnpm/registry.npmjs.org/fsevents/1.2.11/node_modules/fsevents: Running install script, done in 5s

dependencies:
+ react <- @reactesm/react 0.1.0
+ react-dom <- @reactesm/react-dom 0.1.1
+ styled-components 5.0.0

devDependencies:
+ @babel/cli 7.8.3
+ @babel/core 7.8.3
+ @babel/preset-react 7.8.3
+ concurrently 5.0.2
+ live-server 1.2.1
+ snowpack 1.0.5

> snowpack-demo@1.0.0 prepare /Users/prisc_000/Downloads/snowpack-demo-master
> npx snowpack

⠸ snowpack installing... react, react-dom, styled-componentsError: 'isElement' is not exported by node_modules/.pnpm/registry.npmjs.org/react-is/16.12.0/node_modules/react-is/index.js
    at error (/Users/prisc_000/Downloads/snowpack-demo-master/node_modules/.pnpm/registry.npmjs.org/rollup/1.29.0/node_modules/rollup/dist/rollup.js:5340:30)
    at Module.error (/Users/prisc_000/Downloads/snowpack-demo-master/node_modules/.pnpm/registry.npmjs.org/rollup/1.29.0/node_modules/rollup/dist/rollup.js:9730:9)
    at handleMissingExport (/Users/prisc_000/Downloads/snowpack-demo-master/node_modules/.pnpm/registry.npmjs.org/rollup/1.29.0/node_modules/rollup/dist/rollup.js:9644:21)
    at Module.traceVariable (/Users/prisc_000/Downloads/snowpack-demo-master/node_modules/.pnpm/registry.npmjs.org/rollup/1.29.0/node_modules/rollup/dist/rollup.js:10069:17)
    at ModuleScope.findVariable (/Users/prisc_000/Downloads/snowpack-demo-master/node_modules/.pnpm/registry.npmjs.org/rollup/1.29.0/node_modules/rollup/dist/rollup.js:8689:39)
    at FunctionScope.findVariable (/Users/prisc_000/Downloads/snowpack-demo-master/node_modules/.pnpm/registry.npmjs.org/rollup/1.29.0/node_modules/rollup/dist/rollup.js:3025:38)
    at ChildScope.findVariable (/Users/prisc_000/Downloads/snowpack-demo-master/node_modules/.pnpm/registry.npmjs.org/rollup/1.29.0/node_modules/rollup/dist/rollup.js:3025:38)
    at BlockScope.findVariable (/Users/prisc_000/Downloads/snowpack-demo-master/node_modules/.pnpm/registry.npmjs.org/rollup/1.29.0/node_modules/rollup/dist/rollup.js:3025:38)
    at BlockScope.findVariable (/Users/prisc_000/Downloads/snowpack-demo-master/node_modules/.pnpm/registry.npmjs.org/rollup/1.29.0/node_modules/rollup/dist/rollup.js:3025:38)
    at Identifier$1.bind (/Users/prisc_000/Downloads/snowpack-demo-master/node_modules/.pnpm/registry.npmjs.org/rollup/1.29.0/node_modules/rollup/dist/rollup.js:4363:40)
⠇ snowpack installing... react, react-dom, styled-components

@FredKSchott
Copy link
Owner

FredKSchott commented Jan 15, 2020

Thanks for the extra info/output.

Okay, so we actually explicitly allow "react-is" as a dependency to ahead-of-time analyze imports. You can see it here. That means that one of two things is happening:

  • Rollup isn't matching our allowlist of react-is/index.js to that path (node_modules/.pnpm/registry.npmjs.org/react-is/16.12.0/node_modules/react-is/index.js)
  • Our allowlist step isn't properly analyzing react-is when it's installed to that path

This will need some more debugging. I'll re-open this issue and hopefully someone can help debug (would love your help, if you're interested! Otherwise, I'll try to get to it when I have a spare moment).

@FredKSchott FredKSchott changed the title Documentation not right for pnpm [pnpm] export detection not working for whitelisted packages (react-is, etc) Jan 15, 2020
@FredKSchott FredKSchott reopened this Jan 15, 2020
@FredKSchott FredKSchott added bug Something isn't working contributors welcome! contributors welcome! labels Jan 15, 2020
@idkjs
Copy link

idkjs commented Jan 15, 2020

@FredKSchott I am flattered that you would ask for my help, but sadly, I have no idea what is going on here. If you wanted to give me some direction, I would take a stab at it. This was only half of what I wanted to do. I was actually trying to use this as a bundler for a reasonml app. Do you know if that is possible, maybe in configuration?

Glad I could help.

@FredKSchott
Copy link
Owner

no problem! This may be a tricky one, feel free to poke around but no pressure if you don't feel comfortable.

Unfortunately I don't have any intimate experience with ReasonML, but if it can compile to JS and load JS dependencies, then that's all it should need to work with Snowpack.

@FredKSchott
Copy link
Owner

update: assume that this is still happening, still looking for some help from someone who is using pnpm!

@dharmavagabond
Copy link

To make it work, you just have to add react-is as a dependency (pnpm add react-is).

The “problem”—a feature really—is pnpm’s strictness. react-is is a peerDependency for styled-components, so pnpm won’t install it, hence the is not exported error.

More on the subject:

Btw, snowpack is really great!

@FredKSchott FredKSchott changed the title [pnpm] export detection not working for whitelisted packages (react-is, etc) [pnpm] export detection not working for auto-detect packages (react-is, etc) Aug 27, 2020
@FredKSchott
Copy link
Owner

FredKSchott commented Aug 27, 2020

If anyone has an example of the error you see today, please share! This issue is very old, and I have a feeling it is less blocking of an issue that it once was.

If it is still happening, we can add some handling to autoDetectExports() to give a proper error message that tells a user to add as peerDependency to resolve themselves.

Please share the error output if you run into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working contributors welcome! contributors welcome!
Projects
None yet
Development

No branches or pull requests

4 participants