diff --git a/.changeset/silent-dragons-sell.md b/.changeset/silent-dragons-sell.md new file mode 100644 index 000000000000..233d99a9696a --- /dev/null +++ b/.changeset/silent-dragons-sell.md @@ -0,0 +1,6 @@ +--- +'@astrojs/netlify': patch +'astro': patch +--- + +Fix polyfills not being available in certain cases diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index 5ebd05f55874..c25668af4a83 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -55,6 +55,12 @@ export async function createVite( isBuild: mode === 'build', viteUserConfig: settings.config.vite, isFrameworkPkgByJson(pkgJson) { + // Certain packages will trigger the checks below, but need to be external. A common example are SSR adapters + // for node-based platforms, as we need to control the order of the import paths to make sure polyfills are applied in time. + if (pkgJson?.astro?.external === true) { + return false; + } + return ( // Attempt: package relies on `astro`. ✅ Definitely an Astro package pkgJson.peerDependencies?.astro || diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json index 25695ea79181..33caf0f62004 100644 --- a/packages/integrations/netlify/package.json +++ b/packages/integrations/netlify/package.json @@ -50,5 +50,8 @@ "cheerio": "^1.0.0-rc.11", "mocha": "^9.2.2", "vite": "^4.0.3" + }, + "astro": { + "external": true } }