Skip to content

Commit

Permalink
Make 'lit' always be bundled in SSR (withastro#3164)
Browse files Browse the repository at this point in the history
* Make 'lit' always be bundled in SSR

* Adds a changeset
  • Loading branch information
matthewp authored Apr 21, 2022
1 parent 45046c2 commit e4bc30c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/build/vite-plugin-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export function vitePluginPages(opts: StaticBuildOptions, internals: BuildIntern
let rendererItems = '';
for (const renderer of opts.astroConfig._ctx.renderers) {
const variable = `_renderer${i}`;
imports.push(`import ${variable} from '${renderer.serverEntrypoint}';`);
// Use unshift so that renderers are imported before user code, in case they set globals
// that user code depends on.
imports.unshift(`import ${variable} from '${renderer.serverEntrypoint}';`);
rendererItems += `Object.assign(${JSON.stringify(renderer)}, { ssr: ${variable} }),`;
i++;
}
Expand Down
1 change: 1 addition & 0 deletions test/ssr-lit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('Lit integration in SSR', () => {
}

it('Is able to load', async () => {
delete globalThis.window;
const html = await fetchHTML('/');
const $ = cheerioLoad(html);
expect($('#win').text()).to.equal('function');
Expand Down

0 comments on commit e4bc30c

Please sign in to comment.