Closed wjram2133 closed 1 year ago
You'll have to give me more information. Are you using require()
?
I am having the same issue in production. I have tried both import and require. Works fine locally.
I see that I'm missing "types"
in my package.json
but I don't see anything else that would prevent a bundler from including dist/index.js
— it's simply a 0 dependency ES6 module.
AFAICT, TS by default uses CommonJS w/o node resolution. The issue appears to be that TS is blindly emitting require('@adraffy/ens-normalize')
. If I make a new TS project, and set my tsconfig to ..., module: "es6", moduleResolution: "node", ...
, I get the expected compiled output.
I'm not a JS dev so any advice would be appreciated. I'm under the impression that supplying a CommonJS prebuild is unnecessary.
I have included a CJS build and updated the npm package accordingly (1.8.8). Hopefully, this should improve import/require experience.
Error emits:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/.../node_modules/@adraffy/ens-normalize/dist/index.js require() of ES modules is not supported.
with configuration:
{ "compileOnSave": true, "allowJs": true, "compilerOptions": { "module": "commonjs", "esModuleInterop": true, "target": "es6", "noImplicitAny": false, "sourceMap": true, "baseUrl": ".", "rootDir": ".", "allowJs": true, "skipLibCheck": true, "moduleResolution": "node", "experimentalDecorators": true, "importHelpers": true, "resolveJsonModule": true, "allowSyntheticDefaultImports": true, "typeRoots": [".node_modules/@types"], "outDir": "./dist", "paths": { "src": ["./src"] } }, "ts-node": { "require": ["tsconfig-paths/register"] }, "include": ["./**/*"], "exclude": ["./node_modules/**/*"], "allowSyntheticDefaultImports": true }