Skip to content

Commit

Permalink
fix: provide a plugin to resolve the virtual module (#11242)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored Jun 12, 2024
1 parent 769f11f commit e4fc2a0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fair-wasps-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes a case where the virtual module `astro:container` wasn't resolved
15 changes: 15 additions & 0 deletions packages/astro/src/container/vite-plugin-container.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type * as vite from 'vite';

const virtualModuleId = 'astro:container';

export default function astroContainer(): vite.Plugin {
return {
name: 'astro:container',
enforce: 'pre',
resolveId(id) {
if (id === virtualModuleId) {
return this.resolve('astro/virtual-modules/container.js');
}
},
};
}
2 changes: 2 additions & 0 deletions packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { createViteLogger } from './logger/vite.js';
import { vitePluginMiddleware } from './middleware/vite-plugin.js';
import { joinPaths } from './path.js';
import { isObject } from './util.js';
import astroContainer from "../container/vite-plugin-container.js";

interface CreateViteOptions {
settings: AstroSettings;
Expand Down Expand Up @@ -157,6 +158,7 @@ export async function createVite(
astroDevToolbar({ settings, logger }),
vitePluginFileURL({}),
astroInternationalization({ settings }),
astroContainer()
],
publicDir: fileURLToPath(settings.config.publicDir),
root: fileURLToPath(settings.config.root),
Expand Down
1 change: 0 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e4fc2a0

Please sign in to comment.