mobily / ts-belt

šŸ”§ Fast, modern, and practical utility library for FP in TypeScript.
https://mobily.github.io/ts-belt
MIT License
1.1k stars 30 forks source link

Cannot use import statement outside a module #52

Closed icetbr closed 1 year ago

icetbr commented 1 year ago

Steps

/tsbelt # node a.js
(node:63) 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)
/tsbelt/node_modules/@mobily/ts-belt/dist/esm/index.js:1
import { pipe } from "./pipe.js";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1031:15)
    at Module._compile (node:internal/modules/cjs/loader:1065:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:196:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async Object.loadESM (node:internal/process/esm_loader:68:5)
mobily commented 1 year ago

@icetbr could you provide a repro repo?

icetbr commented 1 year ago

https://github.com/icetbr/tsbelt-bug-example

mobily commented 1 year ago

@icetbr fixed in v4.0.0-rc.1 šŸš€