-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fixes for tests in environment branch #14865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
eed2530
91138fc
f6e4463
4578d2d
9c3aa38
5fd8edf
4509536
11ab96e
15fc25e
8897c3e
de91192
d5b6a76
7794452
59cd518
ce5ed6b
ad982c6
732cfaf
1bedc36
f2989dd
c370419
6beed57
fdf0670
eeb4ea9
d7b534c
b7eeccb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| 'astro': major | ||
| --- | ||
|
|
||
| Remove astro:ssr-manifest module | ||
|
|
||
| The `astro:ssr-manifest` module was created to allow integrations to access the manifest. It's no longer used by any integrations and is not used by Astro internally, so has been removed. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,8 @@ function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] { | |
| const pagesToCss: Record<string, Record<string, { order: number; depth: number }>> = {}; | ||
| // Map of module Ids (usually something like `/Users/...blog.mdx?astroPropagatedAssets`) to its imported CSS | ||
| const moduleIdToPropagatedCss: Record<string, Set<string>> = {}; | ||
| // Keep track of CSS that has been bundled to avoid duplication between ssr and prerender. | ||
| const cssModulesInBundles = new Set(); | ||
ematipico marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const cssBuildPlugin: VitePlugin = { | ||
| name: 'astro:rollup-plugin-build-css', | ||
|
|
@@ -49,6 +51,21 @@ function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] { | |
| return environment.name === 'client' || environment.name === 'ssr' || environment.name === 'prerender'; | ||
| }, | ||
|
|
||
| transform(_code, id) { | ||
| if(isCSSRequest(id)) { | ||
| // In prerender, don't rebundle CSS that was already bundled in SSR. | ||
| // Return an empty string here to prevent it. | ||
| if(this.environment.name === 'prerender') { | ||
| if(cssModulesInBundles.has(id)) { | ||
| return { | ||
| code: '' | ||
| } | ||
| } | ||
| } | ||
| cssModulesInBundles.add(id); | ||
| } | ||
| }, | ||
|
|
||
| async generateBundle(_outputOptions, bundle) { | ||
| // Collect CSS modules that were bundled during SSR build for deduplication in client build | ||
| if (this.environment?.name === 'ssr' || this.environment?.name === 'prerender') { | ||
|
|
@@ -114,6 +131,9 @@ function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] { | |
|
|
||
| // For this CSS chunk, walk parents until you find a page. Add the CSS to that page. | ||
| for (const id of Object.keys(chunk.modules)) { | ||
| // Only walk up for dependencies that are CSS | ||
| if(!isCSSRequest(id)) continue; | ||
|
|
||
| const parentModuleInfos = getParentExtendedModuleInfos(id, this, hasAssetPropagationFlag); | ||
| for (const { info: pageInfo, depth, order } of parentModuleInfos) { | ||
| if (hasAssetPropagationFlag(pageInfo.id)) { | ||
|
|
@@ -187,6 +207,13 @@ function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] { | |
| ) | ||
| return; | ||
|
|
||
| // Delete empty CSS chunks. In prerender these are likely duplicates | ||
| // from SSR. | ||
| if(stylesheet.source.length === 0) { | ||
| delete bundle[id]; | ||
| return; | ||
| } | ||
|
Comment on lines
+210
to
+215
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we check that we're inside the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be ok. Should we leave in empty CSS chunks in the other environments?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The minor issue I see is that the comment doesn't reflect the actual code, because I can't see anything regarding "SSR" and "prerender" , so I'm not sure how to interpret the code. |
||
|
|
||
| const toBeInlined = | ||
| inlineConfig === 'always' | ||
| ? true | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.