Skip to content

Commit

Permalink
fix(astro): Dynamically import sidecar to avoid sidecar code in brows…
Browse files Browse the repository at this point in the history
…er bundle
  • Loading branch information
Lms24 committed Nov 16, 2023
1 parent fcb780d commit 1bb952e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
},
"volta": {
"extends": "../../package.json"
},
"astro": {
"external": true
}
}
5 changes: 3 additions & 2 deletions packages/astro/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { setupSidecar } from '@spotlightjs/sidecar';
import type { AstroIntegration } from 'astro';
import { SPOTLIGHT_CLIENT_INIT, SPOTLIGHT_SERVER_SNIPPET } from './snippets';

Expand All @@ -24,7 +23,9 @@ const createPlugin = (): AstroIntegration => {
addDevOverlayPlugin(pluginPath);
},
'astro:server:start': async () => {
console.log('astro:server:start ------------');
// Importing this dynamically because for some reason, the top level import
// caused a dev server error because sidecar code was bundled into the server
const { setupSidecar } = await import('@spotlightjs/sidecar');
setupSidecar();
},
},
Expand Down

0 comments on commit 1bb952e

Please sign in to comment.