Closed dev-johnny-gh closed 1 year ago
@Rubilmax
Hi, I'll look into it next week as I can't ATM sorry I don't think we can because ethers-v6 actually forces this but I need to test some things
@Rubilmax what if we use some bundlers to output both esm and cjs dist? you can try to use it on ts-node with cjs project. then you should be able to reproduce it. if you can manage to avoid the error, let me know.
:tada: This issue has been resolved in version 4.1.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
@Rubilmax Removing this cause problem with esm project though
import { MulticallWrapper } from 'ethers-multicall-provider';
^^^^^^^^^^^^^^^^
SyntaxError: Named export 'MulticallWrapper' not found. The requested module 'ethers-multicall-provider' is a CommonJS module, which may not support all module.exports as named exports.
(node:61259) 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)
export { default as MulticallWrapper } from "./multicall-provider";
^^^^^^
@Rubilmax Removing this cause problem with esm project though
import { MulticallWrapper } from 'ethers-multicall-provider'; ^^^^^^^^^^^^^^^^ SyntaxError: Named export 'MulticallWrapper' not found. The requested module 'ethers-multicall-provider' is a CommonJS module, which may not support all module.exports as named exports.
(node:61259) 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) export { default as MulticallWrapper } from "./multicall-provider"; ^^^^^^
What's the framework you use? Your setup? I think in this case, you should use a bundler to convert ethers-multicall-provider to an esm module
It still doesn't seem to work well with cjs projects. Here's what I get:
[project-dir]/node_modules/ethers-multicall-provider/lib/index.js:1
export { default as MulticallWrapper } from "./multicall-provider";
^^^^^^
SyntaxError: Unexpected token 'export'
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1178:20)
at Module._compile (node:internal/modules/cjs/loader:1220:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Object.require.extensions.<computed> [as .js] (/Users/aleixo/Downloads/rfq-service/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Function.Module._load (node:internal/modules/cjs/loader:960:12)
[...]
Can you provide me with more details on your setup pls? Package.json, tsconfig.json
Of course, thanks. Here they are:
Sorry for the delay, it should be good with v5. It wasn't an easy one: the fix was to use module: "nodenext"
& moduleResolution: "nodenext"
Amazing, thanks a lot!
After I upgraded this package to 4.1.0 (for using ethers v6), I got ERR_REQUIRE_ESM error on ts-node:
It is caused by the "type": "module" on the package.json. My project is not an ES module project and it's hard to upgrade it to an ES module project, I got a lot of errors when I was trying to use the ES module on my project.
The current situation of the ES module on the node ecosystem is chaotic and fucked up.
So, can we remove the type: module restriction so that I can use the commonjs module resolution on typescript to import this package?