0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Fix polyfills not being available to imports on Netlify (#6117)

* fix(netlify): Try to make polyfill external

* feat(webapi): Add polyfill applier for SSR

* fix(netlify): Externalize polyfills so they're always applied before user code

* chore: changeset

* test(netlify): Add test for polyfill being in the proper place

* config(netlify): Remove unnecessary change to package.json

* revert(netlify): Revert changes

* feat(astro): Add a way for packages to explicitely mark themselves as needing to be external

* Update .changeset/silent-dragons-sell.md

---------

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
Erika 2023-02-06 21:17:34 +01:00 committed by GitHub
parent 1b591a1431
commit 32abe49bd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View file

@ -0,0 +1,6 @@
---
'@astrojs/netlify': patch
'astro': patch
---
Fix polyfills not being available in certain cases

View file

@ -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 ||

View file

@ -50,5 +50,8 @@
"cheerio": "^1.0.0-rc.11",
"mocha": "^9.2.2",
"vite": "^4.0.3"
},
"astro": {
"external": true
}
}