mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -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:
parent
1b591a1431
commit
32abe49bd0
3 changed files with 15 additions and 0 deletions
6
.changeset/silent-dragons-sell.md
Normal file
6
.changeset/silent-dragons-sell.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
'@astrojs/netlify': patch
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix polyfills not being available in certain cases
|
|
@ -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 ||
|
||||
|
|
|
@ -50,5 +50,8 @@
|
|||
"cheerio": "^1.0.0-rc.11",
|
||||
"mocha": "^9.2.2",
|
||||
"vite": "^4.0.3"
|
||||
},
|
||||
"astro": {
|
||||
"external": true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue