0no-co / wonka

🎩 A tiny but capable push & pull stream library for TypeScript and Flow
MIT License
709 stars 29 forks source link

Wonka module not found #72

Closed idkjs closed 4 years ago

idkjs commented 4 years ago

I have been trying to install Wonka on a reason project for last two days and cant seem to get it to be recognized.

reproduction here: https://github.com/idkjs/wonka-not-found

Steps to repoduce error

Setup Project

Dependencies have been installed with pnpm.

pnmp i bs-webapi wonka

Add new deps to bsconfig.json:

  "bs-dependencies": [
    "wonka",
    "reason-react",
    "bs-webapi"
  ],

Run Project

npm install
npm start

On running npm start compiler error is:

➜  wonka-not-found npm start

> wonka-not-found@0.1.0 start /Users/prisc_000/Downloads/wonka-not-found
> bsb -make-world -w -ws _

bsb: no work to do.
bsb: no work to do.
File "bsconfig.json", line 1
Error: package gentype not found or built
- Did you install it?
- If you did, did you run `bsb -make-world`?
>>>> Start compiling
[18/25] Building src/Blinking...ClickEventDemo-ReasonReactExamples.cmj
FAILED: src/BlinkingGreeting/WonkaClickEventDemo-ReasonReactExamples.cmj src/BlinkingGreeting/WonkaClickEventDemo-ReasonReactExamples.cmi /Users/prisc_000/Downloads/wonka-not-found/src/BlinkingGreeting/WonkaClickEventDemo.bs.js
/Users/prisc_000/.fnm/node-versions/v13.3.0/installation/pnpm-global/3/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.2-dev.1/node_modules/bs-platform/lib/bsc.exe -nostdlib -bs-package-name reason-react-examples -bs-ns ReasonReactExamples  -bs-package-output commonjs:src/BlinkingGreeting -color always -bs-suffix -I . -I src/ReducerFromReactJSDocs -I src/ReasonUsingJSUsingReason -I src/BlinkingGreeting -I src/FetchedDogPictures -I src -I /Users/prisc_000/Downloads/wonka-not-found/node_modules/reason-react/lib/ocaml -I /Users/prisc_000/Downloads/wonka-not-found/node_modules/bs-webapi/lib/ocaml -I /Users/prisc_000/Downloads/wonka-not-found/node_modules/wonka/lib/ocaml -I /Users/prisc_000/Downloads/wonka-not-found/node_modules/bs-platform/lib/ocaml -w -30-40+6+7+27+32..39+44+45+101 -bs-super-errors -bs-no-version-header -o src/BlinkingGreeting/WonkaClickEventDemo-ReasonReactExamples.cmj src/BlinkingGreeting/WonkaClickEventDemo.reast

  We've found a bug for you!
  /Users/prisc_000/Downloads/wonka-not-found/src/BlinkingGreeting/WonkaClickEventDemo.re 5:6-10

  3 │    fromEvent(document, 'click').subscribe(() => console.log('Clicked!')
      ); */
  4 │ open Webapi.Dom;
  5 │ open Wonka;
  6 │ [@react.component]
  7 │ let make = () => {

  The module or file Wonka can't be found.
  - If it's a third-party dependency:
    - Did you list it in bsconfig.json?
    - Did you run `bsb` instead of `bsb -make-world`
      (latter builds third-parties)?
  - Did you include the file's directory in bsconfig.json?

[23/25] Building src/FetchedD...hedDogPictures-ReasonReactExamples.cmj
FAILED: subcommand failed.
>>>> Finish compiling(exit: 1)

Thank you, sir.

kitten commented 4 years ago

Not sure what's going on here exactly. I tried installing with pnpm and yarn and both seems to work (?)

idkjs commented 4 years ago

I just retried again after your test. Doesnt work for me on either yarn or pnpm. Oddly it works if i copy the files directly like so: https://github.com/idkjs/rxjs-reason-practice/tree/master/src/wonka. So the code works but its not being exposed on my machine?

kitten commented 4 years ago

sorry to ask this, but have you tried resetting the wonka-not-found repo and removing all node_modules?

idkjs commented 4 years ago

I went started a new random project with bsb -init random -theme basic-reason then went into node_modules and ran npm install on the Wonka dep: copied this into Demo.re:

let waitForArray = () => Js.Promise.resolve([|1, 2, 3|]);
let source =
  Wonka.make((. observer) => {
    let (next, complete) = observer;
    let cancelled = ref(false);
    let promise = waitForArray();
    Js.Promise.then_(
      arr =>
        if (! cancelled^) {
          Array.iter(next, arr);
          complete();
        },
      promise,
    );
    () => cancelled := true;
  });

Now Wonka is recognised.

Incidentally, that code from the example doesnt compile:

  We've found a bug for you!
  /Users/prisc_000/working/GitHub/combining-variadics/src/Demo.re 41:9-44:9

  39 ┆ Js.Promise.then_(
  40 ┆   arr =>
  41 ┆     if (! cancelled^) {
  42 ┆       Array.iter(next, arr);
  43 ┆       complete();
  44 ┆     },
  45 ┆   promise,
  46 ┆ );

  This has type:
    unit
  But somewhere wanted:
    Js.Promise.t('a) (defined as Js.Promise.t('a))

FAILED: subcommand failed.
>>>> Finish compiling(exit: 1)
idkjs commented 4 years ago

To your question on resetting:

➜  wonka-not-found-master rm -rf node_modules lib .merlin pnpm-lock.yaml 
pnpm-lock.yaml
➜  wonka-not-found-master pnpm i
Packages: +34
++++++++++++++++++++++++++++++++++
Resolving: total 34, reused 33, downloaded 1, done
node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.2-dev.1/node_modules/bs-platform: Running postinstalnode_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.2-dev.1/node_modules/bs-platform: Running postinstalnode_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.2-dev.1/node_modules/bs-platform: Running postinstall script, done in 5s

dependencies:
+ bs-webapi 0.15.6
+ react 16.12.0
+ react-dom 16.12.0
+ reason-react 0.7.0
+ wonka 4.0.6 (4.0.7 is available)

devDependencies:
+ bs-platform 7.0.2-dev.1
+ moduleserve 0.9.1
➜  wonka-not-found-master cats
{
  "build": "bsb -make-world",
  "start": "bsb -make-world -w ",
  "clean": "bsb -clean-world",
  "server": "moduleserve ./ --port 8000",
  "test": "echo \"Error: no test specified\" && exit 1"
}
➜  wonka-not-found-master npm start

> wonka-not-found@0.1.0 start /Users/prisc_000/Downloads/wonka-not-found-master
> bsb -make-world -w 

Different compiler version: clean current repo
Cleaning... 46 files.
[37/37] Building src/ReactDOMRe.cmj
[246/246] Building src/Webapi.cmj
File "bsconfig.json", line 1
Error: package gentype not found or built 
- Did you install it?
- If you did, did you run `bsb -make-world`?
>>>> Start compiling 
[16/25] Building src/BlinkingGreeting/WonkaClickEventDemo-ReasonReactExamples.cmj
FAILED: src/BlinkingGreeting/WonkaClickEventDemo-ReasonReactExamples.cmj src/BlinkingGreeting/WonkaClickEventDemo-ReasonReactExamples.cmi /Users/prisc_000/Downloads/wonka-not-found-master/src/BlinkingGreeting/WonkaClickEventDemo.bs.js 
/Users/prisc_000/Downloads/wonka-not-found-master/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.2-dev.1/node_modules/bs-platform/lib/bsc.exe -nostdlib -bs-package-name reason-react-examples -bs-ns ReasonReactExamples  -bs-package-output commonjs:src/BlinkingGreeting -color always -bs-suffix -I . -I src/ReducerFromReactJSDocs -I src/ReasonUsingJSUsingReason -I src/BlinkingGreeting -I src/FetchedDogPictures -I src -I /Users/prisc_000/Downloads/wonka-not-found-master/node_modules/reason-react/lib/ocaml -I /Users/prisc_000/Downloads/wonka-not-found-master/node_modules/bs-webapi/lib/ocaml -I /Users/prisc_000/Downloads/wonka-not-found-master/node_modules/wonka/lib/ocaml -I /Users/prisc_000/Downloads/wonka-not-found-master/node_modules/bs-platform/lib/ocaml -w -30-40+6+7+27+32..39+44+45+101 -bs-super-errors -o src/BlinkingGreeting/WonkaClickEventDemo-ReasonReactExamples.cmj src/BlinkingGreeting/WonkaClickEventDemo.reast

  We've found a bug for you!
  /Users/prisc_000/Downloads/wonka-not-found-master/src/BlinkingGreeting/WonkaClickEventDemo.re 5:6-10

  3 │    fromEvent(document, 'click').subscribe(() => console.log('Clicked!')
      ); */
  4 │ open Webapi.Dom;
  5 │ open Wonka;
  6 │ [@react.component]
  7 │ let make = () => {

  The module or file Wonka can't be found.
  - If it's a third-party dependency:
    - Did you list it in bsconfig.json?
    - Did you run `bsb` instead of `bsb -make-world`
      (latter builds third-parties)?
  - Did you include the file's directory in bsconfig.json?

[21/25] Building src/ReducerFromReact...ReducerFromReactJSDocs-ReasonReactExamples.cmj
FAILED: subcommand failed.
>>>> Finish compiling(exit: 1)
idkjs commented 4 years ago

Then when I repeat building Wonka from node_modules like so, Wonka is recognised:

wonka pwd
/Users/prisc_000/Downloads/wonka-not-found-master/node_modules/wonka
➜  wonka pnpm i
 WARN  @ampproject/rollup-plugin-closure-compiler: acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but version 7.1.0 was installed. WARN  gatsby > gatsby-cli: ink@2.6.0 requires a peer of @types/react@>=16.8.0 but none was installed. WARN  gatsby: react-hot-loader@4.12.18 requires a peer of @types/react@^15.0.0 || ^16.0.0 but none was installed.
 WARN  gatsby-plugin-netlify: webpack-assets-manifest@3.1.1 requires a peer of webpack@>=4.4.0 but none was installed. WARN  ts-jest@24.3.0 requires a peer of jest@>=24 <25 but none was installed.Packages: +2100
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Resolving: total 2097, reused 2097, downloaded 0, done
node_modules                             |  WARN  Cannot link bin "detect" of "detect-port-alt" to "/Users/prisc_000/Downloads/wonka-not-found-master/node_modules/.pnpm/registry.npmjs.org/wonka/4.0.6/node_modulesnode_modules                             |  WARN  Cannot link bin "detect" of "detect-port-alt" to "/Users/prisc_000/Downloads/wonka-not-found-master/node_modules/.pnpm/registry.npmjs.org/wonka/4.0.6/node_modules/wonka/node_modules/.pnpm/node_modules/.bin". A package called "detect-port" already has its bin linked.
node_modules                             |  WARN  Cannot link bin "detect-port" of "detect-port-alt" to "/Users/prisc_000/Downloads/wonka-not-found-master/node_modules/.pnpm/registry.npmjs.org/wonka/4.0.6/node_modules/wonka/node_modules/.pnpm/node_modules/.bin". A package called "detect-port" already has its bin linknode_modules                             |  WARN  Cannot link bin "detect-port" of "detect-port-alt" to "/Users/prisc_000/Downloads/wonka-not-found-master/node_modules/.pnpm/registry.npmjs.org/wonka/4.0.6/node_modules/wonka/node_modules/.pnpm/node_modules/.bin". A package called "detect-port" already has its bin linked.
node_modules                             |  WARN  Cannot link bin "jest" of "jest-cli" to "/Users/prisc_000/Downloads/wonka-not-found-master/node_modules/.pnpm/registry.npmjs.org/wonka/4.0.6/node_modules/wonka/nonode_modules                             |  WARN  Cannot link bin "jest" of "jest-cli" to "/Users/prisc_000/Downloads/wonka-not-found-master/node_modules/.pnpm/registry.npmjs.org/wonka/4.0.6/node_modules/wonka/node_modules/.pnpm/node_modules/.bin". A package called "jest" already has its bin linked.
node_modules/.pnpm/registry.npmjs.org/core-js-pure/3.6.4/node_modules/core-js-pure: Running postinstall scnode_modules/.pnpm/registry.npmjs.org/core-js-pure/3.6.4/node_modules/core-js-pure: Running postinstall script...
node_modules/.pnpm/registry.npmjs.org/core-js/2.6.11/node_modules/core-js: Running postinstall script...
node_modules/.pnpm/registry.npmjs.org/cwebp-bin/5.1.0/node_modules/cwebp-bin: Running postinstall script..node_modules/.pnpm/registry.npmjs.org/core-js-pure/3.6.4/node_modules/core-js-pure: Running postinstall scnode_modules/.pnpm/registry.npmjs.org/core-js/2.6.11/node_modules/core-js: Running postinstall script, don
e in 403mses/.pnpm/registry.npmjs.org/bs-platform/7.0.2-dev.1/node_modules/bs-platform: Running postinstalnode_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.2-dev.1/node_modules/bs-platform: Running postinstall script...
node_modules/.pnpm/registry.npmjs.org/gentype/3.10.0/node_modules/gentype: Running postinstall script...
node_modules/.pnpm/registry.npmjs.org/cwebp-bin/5.1.0/node_modules/cwebp-bin: Running postinstall script, 
done in 4ses/.pnpm/registry.npmjs.org/gatsby-telemetry/1.1.47/node_modules/gatsby-telemetry: Running postinode_modules/.pnpm/registry.npmjs.org/gatsby-telemetry/1.1.47/node_modules/gatsby-telemetry: Running postinode_modules/.pnpm/registry.npmjs.org/gatsby-telemetry/1.1.47/node_modules/gatsby-telemetry: Running posti
nstall script, done in 2sry.npmjs.org/husky/3.1.0/node_modules/husky: Running install script...
node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.2-dev.1/node_modules/bs-platform: Running postinstal
l script, done in 10sgistry.npmjs.org/mozjpeg/6.0.1/node_modules/mozjpeg: Running postinstall script...
node_modules/.pnpm/registry.npmjs.org/fsevents/1.2.11/node_modules/fsevents: Running install script, done 
in 13sodules/.pnpm/registry.npmjs.org/husky/3.1.0/node_modules/husky: Running postinstall script, done in node_modules/.pnpm/registry.npmjs.org/mozjpeg/6.0.1/node_modules/mozjpeg: Running postinstall script, done
 in 4sodules/.pnpm/registry.npmjs.org/pngquant-bin/5.0.2/node_modules/pngquant-bin: Running postinstall scnode_modules/.pnpm/registry.npmjs.org/pngquant-bin/5.0.2/node_modules/pngquant-bin: Running postinstall sc
ript, done in 3spm/registry.npmjs.org/sharp/0.23.4/node_modules/sharp: Running install script...
node_modules/.pnpm/registry.npmjs.org/sharp/0.23.4/node_modules/sharp: Running install script, done in 12s
node_modules/.pnpm/registry.npmjs.org/gatsby-cli/2.8.27/node_modules/gatsby-cli: Running postinstall scripnode_modules/.pnpm/registry.npmjs.org/gatsby-cli/2.8.27/node_modules/gatsby-cli: Running postinstall scripnode_modules/.pnpm/registry.npmjs.org/gatsby-cli/2.8.27/node_modules/gatsby-cli: Running postinstall script, done in 136ms
node_modules/.pnpm/registry.npmjs.org/gatsby/2.18.24_57f24dc766493f5092a1ef312d1aaceb/node_modules/gatsby:node_modules/.pnpm/registry.npmjs.org/gatsby/2.18.24_57f24dc766493f5092a1ef312d1aaceb/node_modules/gatsby:node_modules/.pnpm/registry.npmjs.org/gatsby/2.18.24_57f24dc766493f5092a1ef312d1aaceb/node_modules/gatsby: Running postinstall script, done in 507ms
node_modules/.pnpm/registry.npmjs.org/styled-components/4.4.1_b5ffe839b1a452f2d2c7d94d3059774c/node_modulenode_modules/.pnpm/registry.npmjs.org/styled-components/4.4.1_b5ffe839b1a452f2d2c7d94d3059774c/node_modulenode_modules/.pnpm/registry.npmjs.org/styled-components/4.4.1_b5ffe839b1a452f2d2c7d94d3059774c/node_modules/styled-components: Running postinstall script, done in 96ms

devDependencies:
+ @ampproject/rollup-plugin-closure-compiler 0.18.1 (0.20.0 is available)
+ @babel/core 7.8.3
+ @babel/plugin-syntax-typescript 7.8.3
+ @babel/plugin-transform-modules-commonjs 7.8.3
+ @babel/preset-env 7.8.3
+ @glennsl/bs-jest 0.4.9
+ @rollup/plugin-buble 0.21.0
+ @rollup/plugin-commonjs 11.0.1
+ @rollup/plugin-node-resolve 6.1.0 (7.0.0 is available)
+ @types/jest 24.9.0
+ @types/zen-observable 0.8.0
+ babel-plugin-closure-elimination 1.3.0
+ bs-platform 7.0.2-dev.1
+ callbag-from-iter 1.2.0
+ callbag-iterate 1.0.0
+ callbag-take 1.4.0
+ coveralls 3.0.9
+ flow-bin 0.115.0 (0.116.1 is available)
+ flowgen 1.10.0
+ gatsby 2.18.24
+ gatsby-plugin-netlify 2.1.31
+ gatsby-theme-docs-system 0.2.2
+ gentype 3.10.0
+ globby 10.0.2 (11.0.0 is available)
+ husky 3.1.0 (4.0.10 is available)
+ lint-staged 9.5.0
+ npm-run-all 4.1.5
+ prettier 1.19.1
+ react 16.12.0
+ react-dom 16.12.0
+ rimraf 3.0.0
+ rollup 1.29.0
+ rollup-plugin-babel 4.3.3
+ rollup-plugin-terser 5.2.0
+ rollup-plugin-typescript2 0.25.3
+ ts-jest 24.3.0
+ typescript 3.7.5
+ zen-observable 0.8.15
➜  wonka 
kitten commented 4 years ago

There you get a warning for genType, not Wonka. When you then install genType it should work

idkjs commented 4 years ago

That worked. Have never had to install gentype when working with npm so ignored that warning. I did not add gentypeconfig to bsconfig.json either. Does that mean that pnpm is treating gentype as a peer dependency? There aren't any listed in the repo, anyway.

kitten commented 4 years ago

I’ll have to update the readme for BS usage I think. Basically neither bs-platform nor genType are listed as peer dependencies in the package.json for raw JS, TypeScript, and Flow support. But they are indeed needed to compile Wonka with BuckleScript.