diff options
author | 2022-06-21 08:32:05 -0400 | |
---|---|---|
committer | 2022-06-21 08:32:05 -0400 | |
commit | f5afaf24984ee7d4d6e908a7eeed17f5ca18c61e (patch) | |
tree | 68cb423edc44774f6ffecd2e860c41439c653756 /packages/integrations/netlify/src | |
parent | 411af7ae4b0435d740a25fd645380e5bd3949d3a (diff) | |
download | astro-f5afaf24984ee7d4d6e908a7eeed17f5ca18c61e.tar.gz astro-f5afaf24984ee7d4d6e908a7eeed17f5ca18c61e.tar.zst astro-f5afaf24984ee7d4d6e908a7eeed17f5ca18c61e.zip |
Support re-exporting astro components containing client components (#3625)
* Support re-exporting astro components containing client components
* Include metadata for markdown too
* Fix ssr, probably
* Inject post-build
* Remove tagName custom element test
* Allows using the constructor for lit elements
* Fix hoisted script scanning
* Pass through plugin context
* Get edge functions working in the edge tests
* Fix types for the edge function integration
* Upgrade the compiler
* Upgrade compiler version
* Better release notes for lit
* Update .changeset/unlucky-hairs-camp.md
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
* Properly test that the draft was not rendered
* Prevent from rendering draft posts
* Add a changeset about the build perf improvement.
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Diffstat (limited to 'packages/integrations/netlify/src')
-rw-r--r-- | packages/integrations/netlify/src/integration-edge-functions.ts | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/packages/integrations/netlify/src/integration-edge-functions.ts b/packages/integrations/netlify/src/integration-edge-functions.ts index a4bd66e51..f82e6ecc2 100644 --- a/packages/integrations/netlify/src/integration-edge-functions.ts +++ b/packages/integrations/netlify/src/integration-edge-functions.ts @@ -1,4 +1,5 @@ import type { AstroAdapter, AstroConfig, AstroIntegration, BuildConfig, RouteData } from 'astro'; +import type { Plugin as VitePlugin } from 'vite'; import esbuild from 'esbuild'; import * as fs from 'fs'; import * as npath from 'path'; @@ -97,12 +98,31 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {}) return { name: '@astrojs/netlify/edge-functions', hooks: { - 'astro:config:setup': ({ config }) => { + 'astro:config:setup': ({ config, updateConfig }) => { if (dist) { config.outDir = dist; } else { config.outDir = new URL('./dist/', config.root); } + + // Add a plugin that shims the global environment. + const injectPlugin: VitePlugin = { + name: '@astrojs/netlify/plugin-inject', + generateBundle(_options, bundle) { + if(_buildConfig.serverEntry in bundle) { + const chunk = bundle[_buildConfig.serverEntry]; + if(chunk && chunk.type === 'chunk') { + chunk.code = `globalThis.process = { argv: [], env: {}, };${chunk.code}`; + } + } + } + }; + + updateConfig({ + vite: { + plugins: [injectPlugin] + } + }); }, 'astro:config:done': ({ config, setAdapter }) => { setAdapter(getAdapter()); |