-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
adapter-static fails with ESM config #1311
Comments
#936 was a pre-requisite for the upcoming work to publish the adapters as ESM. Until that's done it's probably better to continue using import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const adapter = require('@sveltejs/adapter-static'); |
Cool, I'll stick to
|
That's likely due to a bug in Svelte 3.38.0 and 3.38.1 — should be fixed in 3.38.2 |
Nice, working now! There's one more likely unrelated problem I noticed on nested routes. They appear to be requesting static assets prefixed by their directory name, i.e.
It also causes that route's |
I'm trying to use adapter static too, but weirdly when I try to use .cjs it spits out this error
instead. I downgraded to adapter static 1.0.0-next.7 and it worked, but still got mad at me for using cjs. I don't know if my issue is related or not, but I thought this info may be helpful. |
@TheBlueOompaLoompa Did you change your imports from ESM to CJS after renaming |
Yes I did |
@janosh sounds like you must have a relative @TheBlueOompaLoompa can you paste your entire config file? |
This was working yesterday until I ran npm ci today because of github actions, I think I first installed packages about 4-5 days ago.
Also I would like to point out that after downgrading adapter static to 1.0.0-next.7 from 1.0.0-next.8 it worked. |
https://github.com/sveltejs/kit/blob/master/packages/adapter-static/CHANGELOG.md#100-next8 The change in next.8 was that the adapter was rewritten from CJS to ESM, which means that you can no longer |
I did try to re-write it with ESM, but it just spat out:
Also no my global.css isn't relative, I have it set to |
Can you please share what your attempted ESM conversion looks like? It's almost impossible for anybody to know what the issue is if we can't see that file. (By the way, we shouldn't really even be having a support session in the GitHub issues -- probably the Discord server instead). |
This comment has been minimized.
This comment has been minimized.
Just bit by this myself. I had Is there a reason for
|
@TheBlueOompaLoompa edit — i see @pikeas already replied along those lines |
yes, so users don't have to type all that. not sure i understand the question. why is anything a package?! |
going to close this issue as it's descended into tech support, and this isn't really the venue — if someone is able to reproduce the |
Oops, that was it! 🤦 Odd though that the relative link wasn't a problem under Sapper. Sorry for the noise here. All good for closing. |
Every additional dependency has a maintenance burden. Because the static adapter is so simple - one 5 line function wrapped in an object - it could be described in docs and doesn't need to be its own package. |
@pikeas that sounds like a bad idea. Asking users to copy paste code makes it impossible to update afterwards. |
This comment has been minimized.
This comment has been minimized.
@austinbakker This isn't relevant to this issue. Please see #622, #612, and https://gist.github.com/acoyfellow/2779fb121fac0f32c7419e8dfede772d |
I'm still having this issue:
Any ideas? i honestly don't know what to try This is my svelte.config.cjs file:
|
@davidmgrana I suggest just doing what the error says, i.e. |
npm init svelte@next test-esm-static cd test-esm-static mv svelte.config.cjs svelte.config.js yarn add -D @sveltejs/kit@next @sveltejs/adapter-static@next
and changing the contents of
svelte.config.js
tofollowed by
svelte-kit (dev|build)
throwsI was expecting this to work now that #936 is merged but looks like the adapters still need updating?
The text was updated successfully, but these errors were encountered: