Skip to content

Option module loading error #161

@kswope

Description

@kswope

Something is weird about the core Option module, when run with just node

but seems to work just fine with create-react-app (webpack I think)

works

Array.at([1, 2, 3], 0)->Console.log

doesn't work

Option.equal(Some(1), Some(1), (v1, v2) => {v1 == v2})->Console.log
[nodemon] starting `node src/Index.bs.js`
(node:21031) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/kevin/Dev/ReScript/rescript-notes/node_modules/@rescript/core/src/Core__Option.bs.js:3
import * as Curry from "rescript/lib/es6/curry.js";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1195:20)
    at Module._compile (node:internal/modules/cjs/loader:1239:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Module._load (node:internal/modules/cjs/loader:972:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:168:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)

If I sneak a "type":"module" into package.js inside @rescript/core package it starts working

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions