Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use CJS with Svelte 4 without throwing an error #166

Open
j3rem1e opened this issue Aug 31, 2023 · 3 comments
Open

Allow to use CJS with Svelte 4 without throwing an error #166

j3rem1e opened this issue Aug 31, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@j3rem1e
Copy link

j3rem1e commented Aug 31, 2023

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.

@sebastianrothe sebastianrothe added the enhancement New feature or request label Aug 31, 2023
@sebastianrothe
Copy link
Collaborator

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.

@benmccann
Copy link
Collaborator

benmccann commented Sep 1, 2023

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

@artemkliaus
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants