Describe the bug
I make unit test on my Typescript Svelte 4 app using ts-node with the esm loader. Many of my ts files under test import svelte-i18n and ts-node do not handle importing svelte-i18n.
Expected behavior
To import the lib as esm module.
Stacktraces
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/myproject/node_modules/svelte/src/runtime/store/index.js from /home/myproject/node_modules/svelte-i18n/dist/runtime.cjs.js not supported.
Instead change the require of index.js in /myproject/node_modules/svelte-i18n/dist/runtime.cjs.js to a dynamic import() which is available in all CommonJS modules.
at require.extensions.<computed> [as .js] (/myproject/node_modules/ts-node/dist/index.js:851:20)
at Object.<anonymous> (/myproject/node_modules/svelte-i18n/dist/runtime.cjs.js:1:20)
at require.extensions.<computed> [as .js] (/myproject/node_modules/ts-node/dist/index.js:851:20)
Potential solution
I tested to put "type":"module" and changing "main" in node_modules/svelte-i18n/package.json:
"type": "module",
"main": "dist/runtime.esm.js",
and that fixed the problem (that seems very logical).
I know doing such change make my Svelte 3 based project unit tests no longer working but the app build still works.
Describe the bug I make unit test on my Typescript Svelte 4 app using ts-node with the esm loader. Many of my ts files under test import svelte-i18n and ts-node do not handle importing svelte-i18n.
Expected behavior To import the lib as esm module.
Stacktraces
Potential solution
I tested to put "type":"module" and changing "main" in
node_modules/svelte-i18n/package.json
:and that fixed the problem (that seems very logical).
I know doing such change make my Svelte 3 based project unit tests no longer working but the app build still works.
Information about your project: