TheSpyder / rescript-nodejs

Node bindings for ReScript
MIT License
80 stars 16 forks source link

This code seems not to work with rescript 11.beta.2 and 3 #15

Closed JasoonS closed 1 year ago

JasoonS commented 1 year ago

I get the following error after newly adding this package to a new project:

> envio-operator@0.1.0 build /home/jasoons/Documents/code/envio/envio-operator
> rescript build

Dependency on @ryyppy/rescript-promise
rescript: [5/5] src/Promise.cmj
rescript: [7/7] install.stamp
Dependency on rescript-nodejs
rescript: [58/118] src/Module-NodeJs.cmj
FAILED: src/Module-NodeJs.cmj

  We've found a bug for you!
  /home/jasoons/Documents/code/envio/envio-operator/node_modules/.pnpm/rescript-nodejs@14.4.0/node_modules/rescript-nodejs/src/Module.res:1:9-19

  1 │ include Node_module
  2 │ 

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

rescript: [79/118] src/Buffer-NodeJs.cmj
FAILED: src/Buffer-NodeJs.cmj

  We've found a bug for you!
  /home/jasoons/Documents/code/envio/envio-operator/node_modules/.pnpm/rescript-nodejs@14.4.0/node_modules/rescript-nodejs/src/Buffer.res:1:10-20

  1 │ type t = Node.buffer
  2 │ open Js.TypedArray2
  3 │ 

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

rescript: [97/118] src/Assert-NodeJs.cmj
FAILED: cannot make progress due to previous errors.
Failure: /home/jasoons/Documents/code/envio/envio-operator/node_modules/.pnpm/rescript@11.0.0-beta.3/node_modules/rescript/linux/ninja.exe 
Location: /home/jasoons/Documents/code/envio/envio-operator/node_modules/rescript-nodejs/lib/bs
 ELIFECYCLE  Command failed with exit code 1.

I'll clone locally and investigate a bit - seems strange - but I also don't know what Node_module is.

JasoonS commented 1 year ago

Yeah, this seems to be an issue with the core package.

Upgrading 'rescript' causes this issue:

diff --git a/package.json b/package.json
index fdfeb0b..7855cf1 100644
--- a/package.json
+++ b/package.json
@@ -29,7 +29,7 @@
     "@dusty-phillips/rescript-zora": "^3.0.0",
     "onchange": "^7.1.0",
     "pta": "^1.0.0",
-    "rescript": "^10.0.1",
+    "rescript": "^11.0.0-beta.3",
     "zora": "^5.0.0"
   }
 }

I didn't see anything immediately obvious in release logs since v10.

JasoonS commented 1 year ago

That seems to be the problem node_modules/rescript/lib/ocaml/node_module.ml isn't there anymore.

JasoonS commented 1 year ago

Bingo... https://github.com/rescript-lang/rescript-compiler/pull/6285

I'll try get the needed files added here :)

TheSpyder commented 1 year ago

Oh good find!

We could perhaps just add types to this project, but that would then make it incompatible with ReScript 10. I'll ask.

JasoonS commented 1 year ago

Yeah, maybe a major version bump, and it requires rescript 11 or higher?

TheSpyder commented 1 year ago

Bundling my own types is the recommended solution. And yes it will need a new major.

DZakh commented 1 year ago

@JasoonS As a temp solution you can use the version from my PR:

    "rescript-nodejs": "github:DZakh/rescript-nodejs#3c29dcd",
JasoonS commented 1 year ago

Cool, thanks - beat me to it @DZakh 💪