Open PixievoltNo1 opened 1 year ago
I think this is causing the error:
🚨 Build failed.
Error: Could not resolve module "svelte/compiler.js" from
"./node_modules/parcel-transformer-svelte/index.js"
however once that require
is fixed, I get this error, which seems to come from svelte itself, somehow:
🚨 Build failed.
@parcel/core: Failed to resolve 'svelte/internal' from './source/app.svelte'
./source/app.svelte:36:8
35 | for (const extension of extensions) {
> 36 | extension.shown = keywords.every(word =>
> | ^
37 | extension.indexedName.includes(word)
38 | );
@parcel/resolver-default: Cannot load file './internal' from module 'svelte'
I only found this mention online:
The solution for this second issue is to add this to my package.json
:
"alias": {
"svelte/why": "https://github.com/orlov-vo/parcel-transformer-svelte/issues/37",
"svelte/internal": "./node_modules/svelte/src/runtime/internal/index.js"
}
Edit:
Actually it's because Parcel doesn't use the exports
map by default 🤦♂️
https://parceljs.org/blog/v2-9-0/#new-resolver
The config is even easier, I'll add it to my PR
"@parcel/resolver-default": {
"packageExports": true
},
Since this package seems abandoned, I published a temporary v4-compatible package until someone picks it up again.
npm rm parcel-transformer-svelte
npm i parcel-transformer-svelte-v4
// .parcelrc
"transformers": {
"*.svelte": ["parcel-transformer-svelte-v4"]
},
Svelte 4 is here! This package could work with it with some minor changes.
Svelte 4 was restructured to be importable exclusively by package exports. To work with this, the plugin must require "svelte/compiler", dropping the file extension.
Additionally, you should add a note to the readme with the above Parcel docs link and asking users to enable package exports. Parcel otherwise can't import anything from Svelte 4 by default.