-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix image tests crashing #14803
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
Fix image tests crashing #14803
Changes from all commits
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 |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import type { | |
| } from '../types/public/index.js'; | ||
| import { getComponentMetadata } from '../vite-plugin-astro-server/metadata.js'; | ||
| import { createResolve } from '../vite-plugin-astro-server/resolve.js'; | ||
| import { getDevCSSModuleName } from '../vite-plugin-css/util.js'; | ||
| import { PAGE_SCRIPT_ID } from '../vite-plugin-scripts/index.js'; | ||
|
|
||
| export class AstroServerPipeline extends Pipeline { | ||
|
|
@@ -120,7 +121,7 @@ export class AstroServerPipeline extends Pipeline { | |
| } | ||
| } | ||
|
|
||
| const { css } = await import('virtual:astro:dev-css'); | ||
| const { css } = await loader.import(getDevCSSModuleName(routeData.component)); | ||
|
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. If possible, we shouldn't rely on the loader anymore. We actually want to move away from it eventually, because it goes in conflicts with the new architecture. In fact, it's possible we won't need this pipeline anymore once we're able to provide all the features using
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. Not sure I understand, you can't import Vite code using the real dynamic import. It fails without this change.
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. That's the concerning part. Why does it work with Cloudflare, and not without it?
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. Because that code runs inside of the Vite runtime and this does not. So when you use regular dynamic import you are using Node.js module loader which of course can't resolve this. So we use |
||
|
|
||
| // Pass framework CSS in as style tags to be appended to the page. | ||
| const links = new Set<SSRElement>(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { getVirtualModulePageName } from '../vite-plugin-pages/util.js'; | ||
|
|
||
| const MODULE_DEV_CSS_PREFIX = 'virtual:astro:dev-css:'; | ||
|
|
||
| /** | ||
| * Get the virtual module name for a dev CSS import. | ||
| * Usage: `await loader.import(getDevCSSModuleName(routeData.component))` | ||
| */ | ||
| export function getDevCSSModuleName(componentPath: string): string { | ||
| return getVirtualModulePageName(MODULE_DEV_CSS_PREFIX, componentPath); | ||
| } | ||
|
Comment on lines
+1
to
+11
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. I think this utility should be moved next to its opposite function. Plus, we're repeating the module prefix, while we should instead use one constant to reduce errors |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,14 +138,20 @@ describe('External scripts in SSR', () => { | |
| vite: { | ||
| build: { | ||
| assetsInlineLimit: 0, | ||
| rollupOptions: { | ||
| output: { | ||
| entryFileNames: 'assets/entry.[hash].mjs', | ||
| chunkFileNames: 'assets/chunks/chunk.[hash].mjs', | ||
| assetFileNames: 'assets/asset.[hash][extname]', | ||
| }, | ||
| }, | ||
| }, | ||
| environments: { | ||
| client: { | ||
| build: { | ||
| rollupOptions: { | ||
| output: { | ||
| entryFileNames: 'assets/entry.[hash].mjs', | ||
| chunkFileNames: 'assets/chunks/chunk.[hash].mjs', | ||
| assetFileNames: 'assets/asset.[hash][extname]', | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+142
to
+154
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 PR doesn't mention anything about this change. Is it related to the CSS? If so, how does it affect it? If not, what does this change do? |
||
| }, | ||
| }); | ||
| await fixture.build(); | ||
|
|
@@ -166,14 +172,20 @@ describe('External scripts in SSR', () => { | |
| vite: { | ||
| build: { | ||
| assetsInlineLimit: 0, | ||
| rollupOptions: { | ||
| output: { | ||
| entryFileNames: 'assets/entry.[hash].mjs', | ||
| chunkFileNames: 'assets/chunks/chunk.[hash].mjs', | ||
| assetFileNames: 'assets/asset.[hash][extname]', | ||
| }, | ||
| }, | ||
| }, | ||
| environments: { | ||
| client: { | ||
| build: { | ||
| rollupOptions: { | ||
| output: { | ||
| entryFileNames: 'assets/entry.[hash].mjs', | ||
| chunkFileNames: 'assets/chunks/chunk.[hash].mjs', | ||
| assetFileNames: 'assets/asset.[hash][extname]', | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| base: '/hello', | ||
| }); | ||
|
|
@@ -198,14 +210,20 @@ describe('External scripts in SSR', () => { | |
| vite: { | ||
| build: { | ||
| assetsInlineLimit: 0, | ||
| rollupOptions: { | ||
| output: { | ||
| entryFileNames: 'assets/entry.[hash].mjs', | ||
| chunkFileNames: 'assets/chunks/chunk.[hash].mjs', | ||
| assetFileNames: 'assets/asset.[hash][extname]', | ||
| }, | ||
| }, | ||
| }, | ||
| environments: { | ||
| client: { | ||
| build: { | ||
| rollupOptions: { | ||
| output: { | ||
| entryFileNames: 'assets/entry.[hash].mjs', | ||
| chunkFileNames: 'assets/chunks/chunk.[hash].mjs', | ||
| assetFileNames: 'assets/asset.[hash][extname]', | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| }); | ||
| await fixture.build(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are we fixing/adding here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the script tests you asked about below, this allows people to customize the client-side output names.