Closed MarcGodard closed 1 year ago
After updating all my packages.
Interesting. I did release a new version today that it should only have updated one small dependency
@cibernox Yeah I saw that... but this was the result. There was also an update in the svelte plugin lib... Investigating more
The error is in precompile-intl-runtime
@cibernox do you run full tests for es6 on your packages?
/home/marcgodard/Documents/Github/swp-web/node_modules/precompile-intl-runtime/dist/commonjs/stores/dictionary.js:5
const store_1 = require("svelte/store");
Says the require is the issue...
I have the same problem. Any workarounds yet?
I'm not sure what is going on, I don't think any of the changes introduced recently could have caused this. I have verified the problem locally on a sample app. I can only guess there has been some change in vite since the last published version, but I'll track it down.
While manually implementing a temporary workaround in the package-lock.json I noticed something:
svelte-intl-precompile
version 0.12.2, the dependecy for precompile-intl-runtime
has its own entry like "node_modules/precompile-intl-runtime": {...}
for version 0.8.40.8.2
instead of ^0.8.2
in the package-lock dependencies for svelte-intl-precompile), the entry in package-lock looks like "node_modules/svelte-intl-precompile/node_modules/precompile-intl-runtime": { ... }
So it's like it uses two different ways of referencing precompile-intl-runtime
library, either as a separate library or sub-folder module.
Note that npm i -S svelte-intl-precompile@0.12.1 precompile-intl-runtime@0.8.2
does not work, but hardcoding the dependency value 0.8.2 does as mentioned above.
I wonder if you're somehow randomly running into a problem I also had with a library some months ago in a hybrid cjs/mjs setting. Your setup looks very similar.
I had to add "exports"
to the main package.json as well as extra, minimal package.json files inside each subfolder for mjs/cjs via a "fixup" script as part of the build. It was based on this blog post: https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html
Here's my library package.json: https://github.com/exitplanner/xbrl-parser/blob/main/package.json
Same problem here, after updating all my packages (migrating to svelte 4) I have the same error: Error [ERR_REQUIRE_ESM]: require() of ES Module...
I have the same problem and still can't upgrade to svelte 4 :(
yep, new version is not working:
Instead change the require of index.js in spa/node_modules/precompile-intl-runtime/dist/commonjs/stores/dictionary.js to a dynamic import() which is available in all CommonJS modules.
precompile-intl-runtime
is CommonJS package without "type":"module"
? At the same time, it's included ESM modules file.import
without extension which means they can work with --experimental-specifier-resolution=node
only. It seems like https://github.com/cibernox/precompile-intl-runtime/blob/master/tsconfig.json#L3 should be NodeNext
to support relative import wich should include .js
extension.
To rollback version, you should use overrides:
"overrides": {
"svelte-intl-precompile@0.12.1": {
"precompile-intl-runtime": "0.8.2"
}
}
and "svelte-intl-precompile": "0.12.1"
in deps of course
That is helpful. I come from a trip tonight, I will church that
As pointed out by @stalkerg it's a bit confusing why precompile-intl-runtime is provided as more aligned to commons as to ESM. svelte-intl-precompile instead is configured to be a native ESM. I can only assume this was due to jest and babel complaining about issues. I've tried to move the project itself to an ESM which still supports CommonJS via export definition in package.json in addition to main pointing to commonjs. I've provided an PR which should resolve this issue. Please note that I'm not very familiar with the node/JS ecosystem, please let me know if the PR needs to be adjusted in order to align with the maintainers or other best practices.
v0.12.3 has fixed this. Try the new version and report if it works on your projects.