-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
[astro-ci] Lit element SSR failure #9275
Comments
I think this is likely caused by this change: https://github.com/vitejs/vite/pull/9146/files We have specific module ids we externalize: https://github.com/withastro/astro/blob/main/packages/integrations/lit/src/index.ts#L16-L22 |
@matthewp #9146 was released in 3.0.1. It is a possibility then that we broke Astro CI before the latest release then. external: [
'lit-element/lit-element.js',
'@lit-labs/ssr/lib/install-global-dom-shim.js',
'@lit-labs/ssr/lib/render-lit-html.js',
'@lit-labs/ssr/lib/lit-element-renderer.js',
'@astrojs/lit/server.js',
], Should be: external: [
'lit-element',
'@lit-labs/ssr',
'@astrojs/lit',
], But I don't understand why these needs to be in |
Maybe that was the intended behavior but Vite 2.0 let you externalize specific modules and not just entire packages. We've been using I think your solution might work in this case, I'll try it. I wonder why this is the intended behavior though. Packages can have multiple entrypoints and some of them might need to be externalized and some others not. |
cc @brillout @bluwy @benmccann @dominikg, sorry for pinging you all but we better correctly define and specify how |
It sounds like the Vite 2 behavior was packages for |
IIUC |
@matthewp looks like Vite v2 indeed allowed to define both specific entries in I'm curious though about why you needed the |
Sounds good to me. Although I also wonder why If it'd be up to me I'd remove |
It could be used to make a dependency |
We can probably revisit this now. In the past it was because deps were optimized in SSR (are they never any more?) which led to the possibility of multiple instances of a package existing and The other (but related) reason (and why this specific case breaks) is because this code: import 'a';
import 'b'; if We apply tldr; we (ab)use noExternal and external heavily. maybe we should calm down. |
Ok, I see. If you want to have |
Same suspicion. As for |
@brillout I think that @matthewp gave a concrete use case in his prev message, and hinted that there may not be a bug. They are adding deps to |
Ok, I think I understand now: a package needs partial externalization if some files are source files (= noExternal) while other files need to be deduped (= external). |
It would be nice if you could configure this scenario with some sort of config. I could see some config like |
Describe the bug
We are receiving a
window is not defined
error when using our Lit Element SSR renderer. This is likely a problem with Vite respecting our shims for browser globals likewindow
.Reproduction
(see logs)
System Info
Used Package Manager
pnpm
Logs
pnpm build
andpnpm link --global
from~/repos/vite/packages/vite
pnpm link --global vite
from~/repos/astro/packages/astro
pnpm dev
(or build) from~/repos/astro
pnpm test:match "Lit integration in SSR
Validations
The text was updated successfully, but these errors were encountered: