-
Notifications
You must be signed in to change notification settings - Fork 18
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
Feature/esm as default transformer #101
Feature/esm as default transformer #101
Conversation
… be of type string. Received an instance of URL
correct README
- remove cjs export - remove main, because node <12 is not supported anymore
- add check for module system and correct transformer
- make it clearer, that esm is the default and cjs has to be set manually
- v12 is supported until April 2022
- remove v12 - add v17 for CI
Interesting read about dual-package libs https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c?permalink_comment_id=3850849#gistcomment-3850849 |
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Sharing something I learned, which is the reason you had to write the PR this way, is that jest always prefers the CJS version via its With Svelte 4, CJS won't work, so I think this PR is a good idea. Svelte 4 ships a CJS version of the compiler for use in Somewhat surprising to me, it turns out that Jest is still used much more than Vitest or Playwright are with Svelte eventhough the latter two are the ones we offer to setup people up with when setting up new SvelteKit projects. Hopefully Svelte and |
|
||
if (debug) { | ||
console.debug(`Running svelte-jester-transformer async in mode ${currentFileExtension}.`) | ||
} | ||
|
||
if (!preprocess) { | ||
return compiler('esm', options, filename, source) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to omit the format
option with Svelte 4 or else users will get errors printed to the console. I think we can do something like import { VERSION } from 'svelte';
to check what version users are on. @sveltejs/vite-plugin-svelte
does this
I think it's easier to start fresh with this PR rather than address all the merge conflicts, so I'm going to go ahead and close it. I sent #133 with the core changes from this PR, so please give that one a look if you've got a minute! |
FYI: this is based on #100. So if #100 gets merged first, the changes here a much smaller.
This change makes the ESM async transformer the default. It also adds an error, if it used in the wrong context (e.g. async in CJS). This should fix most of the problems (#97 #91 #86 #72), because it will let Jest use the correct transformer.
It adds documentation with a manual override for all users, who still have to use CJS.