Closed brechtcs closed 4 years ago
I ran into a related issue today while using Webpack! I can confirm that this change fixes it for me.
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/home/Projects/visual-pokemon-calc/node_modules/y-indexeddb/src/y-indexeddb.js
require() of ES modules is not supported.
require() of /Users/home/Projects/visual-pokemon-calc/node_modules/y-indexeddb/src/y-indexeddb.js from /Users/home/Projects/visual-pokemon-calc/.next/server/static/development/pages/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename y-indexeddb.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/home/Projects/visual-pokemon-calc/node_modules/y-indexeddb/package.json.
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1216:13)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at eval (webpack-internal:///y-indexeddb:1:18)
at Object.y-indexeddb (/Users/home/Projects/visual-pokemon-calc/.next/server/static/development/pages/index.js:1515:1)
at __webpack_require__ (/Users/home/Projects/visual-pokemon-calc/.next/server/static/development/pages/index.js:23:31)
at eval (webpack-internal:///./src/redux/yjs-core/createStore.ts:5:69)
at Module../src/redux/yjs-core/createStore.ts (/Users/home/Projects/visual-pokemon-calc/.next/server/static/development/pages/index.js:1100:1)
at __webpack_require__ (/Users/home/Projects/visual-pokemon-calc/.next/server/static/development/pages/index.js:23:31)
at eval (webpack-internal:///./src/redux/store.ts:4:79)
at Module../src/redux/store.ts (/Users/home/Projects/visual-pokemon-calc/.next/server/static/development/pages/index.js:1076:1)
at __webpack_require__ (/Users/home/Projects/visual-pokemon-calc/.next/server/static/development/pages/index.js:23:31)
at eval (webpack-internal:///./src/pages/index.tsx:23:71)
at Module../src/pages/index.tsx (/Users/home/Projects/visual-pokemon-calc/.next/server/static/development/pages/index.js:1052:1) {
code: 'ERR_REQUIRE_ESM'
}
Thanks! I will publish a new module in a bit.
Fix for https://github.com/yjs/y-indexeddb/issues/7