Skip to content

Commit e4fc2a0

Browse files
authoredJun 12, 2024··
fix: provide a plugin to resolve the virtual module (#11242)
1 parent 769f11f commit e4fc2a0

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed
 

‎.changeset/fair-wasps-hunt.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes a case where the virtual module `astro:container` wasn't resolved
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type * as vite from 'vite';
2+
3+
const virtualModuleId = 'astro:container';
4+
5+
export default function astroContainer(): vite.Plugin {
6+
return {
7+
name: 'astro:container',
8+
enforce: 'pre',
9+
resolveId(id) {
10+
if (id === virtualModuleId) {
11+
return this.resolve('astro/virtual-modules/container.js');
12+
}
13+
},
14+
};
15+
}

‎packages/astro/src/core/create-vite.ts

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { createViteLogger } from './logger/vite.js';
3838
import { vitePluginMiddleware } from './middleware/vite-plugin.js';
3939
import { joinPaths } from './path.js';
4040
import { isObject } from './util.js';
41+
import astroContainer from "../container/vite-plugin-container.js";
4142

4243
interface CreateViteOptions {
4344
settings: AstroSettings;
@@ -157,6 +158,7 @@ export async function createVite(
157158
astroDevToolbar({ settings, logger }),
158159
vitePluginFileURL({}),
159160
astroInternationalization({ settings }),
161+
astroContainer()
160162
],
161163
publicDir: fileURLToPath(settings.config.publicDir),
162164
root: fileURLToPath(settings.config.root),

‎pnpm-lock.yaml

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.