svelte-jester
svelte-jester copied to clipboard
Allow to use CJS with Svelte 4 without throwing an error
Today, svelte-jester throw an exception if we try to use Svelte 4 with a (classic) cjs setup.
To help with the migration path to esm and jest, it would be great to not throw an exception here but maybe add a warning to the documentation.
It works by chaining babel-jest after svelte-jester if I remove the exception, with the following config:
transform: {
"\\.svelte$": [
'jest-chain-transform',
{
transformers: [
'svelte-jester', 'babel-jest'
]
}
]
}
Integrating the transformation esm->csj could be great, but I don't think it's really necessary if it's documented.
Interesting. I thought that this would be impossible.
If you start migrating your code, this should an all at once issue. I think it is not possible to mix and match.
Svelte 4 will only output ESM, but he's setup a transformer to change that output to CJS, so that it will run with Jest. More details here: https://github.com/storybookjs/addon-svelte-csf/issues/132#issuecomment-1699885697
I think it'd be reasonable to try to support it as it'd probably make upgrading to Svelte 4 easier for folks. We can leave ESM as the default
Svelte 4 will only output ESM, but he's setup a transformer to change that output to CJS, so that it will run with Jest. More details here: storybookjs/addon-svelte-csf#132 (comment)
I think it'd be reasonable to try to support it as it'd probably make upgrading to Svelte 4 easier for folks. We can leave ESM as the default
When will fix?