-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Support for ESM configs #29
Comments
Needs support for async config from vite, this has been merged but not released vitejs/vite#2758 Also does this mean that going forward there will be no svelte.config.cjs and we should discourage its use or are both allowed? And while we're at it, whats the list of locations vite-plugin-svelte should look for svelte.config.c?js ? (see #23 for context) |
Update, async config hook might be a better place: vitejs/vite#2800 |
Both Regarding "where to look": I think this was never specified. But we should, at some point, to save us some maintenance 😄 |
Initial code here https://github.com/sveltejs/vite-plugin-svelte/compare/feat/async-load-config-esm needs to wait until vite 2.16 is released and peer dependency updated. should we try to get rid of everything non-esm and make vite-plugin-svelte itself a type: module too? Here's another require call:
|
You also need to replace the Making it a |
Very interested in this issue. Anything I can do to help? |
unfortunately jest doesn't really support esm, so a fallback to cjs is needed. @dummdidumm would it be ok to require the cjs extension or fallback to require if import throws? |
Fine with me, if |
* feat(vite-plugin-svelte): support esm in svelte.config.js (see #29) * update vite to 2.2.1 and update other dependencies * chore: update dependencies * test: improve stability * feat: add configFile option; use require to load cjs config * also try to load svelte.config.mjs * chore: update dependencies * improve changesets
released in 1.0.0-next.8 |
I encountered a bug on windows. It tells me that the given path is not a valid scheme. Seeing that I remembered that I had the same issue in language-tools and what I did was wrapping the path with Also see nodejs/node#31710 |
* fix: use pathToFileURL to ensure windows compatibility see #29 (comment) * add changeset
Describe the feature
Support loading ESM config files. Currently only CommonJS
svelte.config
files are supported because the code usesrequire
to load it.I think that this line needs to change to use
import(..)
. Note though that TS will transpile this to arequire
anyway, that's why you need to create aconst dynamicImport = new Function('path', 'return import(path)');
function and use that one as a workaround (see microsoft/TypeScript#43329 for more info).A Usecase
Support ESM
svelte.config.js
in SvelteKitAlternatives
none
Additional context
Blocker for sveltejs/kit#936
The text was updated successfully, but these errors were encountered: