Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/astro/src/manifest/virtual-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const cacheDir = new URL(manifest.cacheDir);
const outDir = new URL(manifest.outDir);
const publicDir = new URL(manifest.publicDir);
const srcDir = new URL(manifest.srcDir);
const root = new URL(manifest.hrefRoot);
const root = new URL(manifest.rootDir);
const trailingSlash = manifest.trailingSlash;
const site = manifest.site;
const compressHTML = manifest.compressHTML;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/vite-plugin-hmr-reload/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type EnvironmentModuleNode, type Plugin } from 'vite';
import type { EnvironmentModuleNode, Plugin } from 'vite';

/**
* The very last Vite plugin to reload the browser if any SSR-only module are updated
Expand Down
26 changes: 21 additions & 5 deletions packages/astro/test/units/routing/route-matching.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createContainer } from '../../../dist/core/dev/container.js';
import { createViteLoader } from '../../../dist/core/module-loader/vite.js';
import { createRoutesList, matchAllRoutes } from '../../../dist/core/routing/index.js';
import { getSortedPreloadedMatches } from '../../../dist/prerender/routing.js';
import { DevPipeline } from '../../../dist/vite-plugin-astro-server/pipeline.js';
import { AstroServerPipeline } from '../../../dist/vite-plugin-app/pipeline.js';
import { createDevelopmentManifest } from '../../../dist/vite-plugin-astro-server/plugin.js';
import testAdapter from '../../test-adapter.js';
import {
Expand Down Expand Up @@ -127,6 +127,7 @@ describe('Route matching', () => {
let manifestData;
let container;
let settings;
let manifest;

before(async () => {
const fixture = await createFixture(fileSystem);
Expand All @@ -142,15 +143,20 @@ describe('Route matching', () => {
});

const loader = createViteLoader(container.viteServer);
const manifest = createDevelopmentManifest(container.settings);
pipeline = DevPipeline.create(undefined, { loader, logger: defaultLogger, manifest, settings });
manifest = createDevelopmentManifest(container.settings);
manifestData = await createRoutesList(
{
cwd: fixture.path,
settings,
},
defaultLogger,
);
pipeline = AstroServerPipeline.create(manifestData, {
loader,
logger: defaultLogger,
manifest,
settings,
});
});

after(async () => {
Expand All @@ -160,7 +166,12 @@ describe('Route matching', () => {
describe('Matched routes', () => {
it('should be sorted correctly', async () => {
const matches = matchAllRoutes('/try-matching-a-route', manifestData);
const preloadedMatches = await getSortedPreloadedMatches({ pipeline, matches, settings });
const preloadedMatches = await getSortedPreloadedMatches({
pipeline,
matches,
settings,
manifest,
});
const sortedRouteNames = preloadedMatches.map((match) => match.route.route);

assert.deepEqual(sortedRouteNames, [
Expand All @@ -174,7 +185,12 @@ describe('Route matching', () => {
});
it('nested should be sorted correctly', async () => {
const matches = matchAllRoutes('/nested/try-matching-a-route', manifestData);
const preloadedMatches = await getSortedPreloadedMatches({ pipeline, matches, settings });
const preloadedMatches = await getSortedPreloadedMatches({
pipeline,
matches,
settings,
manifest,
});
const sortedRouteNames = preloadedMatches.map((match) => match.route.route);

assert.deepEqual(sortedRouteNames, [
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/test/units/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function createBasicPipeline(options = {}) {
const pipeline = new Pipeline(
options.logger ?? defaultLogger,
options.manifest ?? {
hrefRoot: import.meta.url,
rootDir: import.meta.url,
},
options.mode ?? 'development',
options.renderers ?? [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { createContainer } from '../../../dist/core/dev/container.js';
import { createLoader } from '../../../dist/core/module-loader/index.js';
import { createRoutesList } from '../../../dist/core/routing/index.js';
import { createComponent, render } from '../../../dist/runtime/server/index.js';
import { createController, DevApp } from '../../../dist/vite-plugin-astro-server/index.js';
import { AstroServerApp } from '../../../dist/vite-plugin-app/app.js';
import { createController } from '../../../dist/vite-plugin-astro-server/index.js';
import { createDevelopmentManifest } from '../../../dist/vite-plugin-astro-server/plugin.js';
import testAdapter from '../../test-adapter.js';
import {
Expand All @@ -18,7 +19,7 @@ import {

async function createDevApp(overrides = {}, root) {
const settings = overrides.settings ?? (await createBasicSettings({ root }));
const loader = overrides.loader ?? createLoader();
const loader = overrides.loader ?? createLoader({});
const manifest = createDevelopmentManifest(settings);
const routesList = await createRoutesList(
{
Expand All @@ -43,7 +44,7 @@ async function createDevApp(overrides = {}, root) {

// TODO: temporarily inject route list inside manifest

return new DevApp(manifest, true, settings, defaultLogger, loader, routesList);
return new AstroServerApp(manifest, true, defaultLogger, routesList, loader, settings);
}

describe('vite-plugin-astro-server', () => {
Expand Down
1 change: 0 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ packages:

# Wait until three days after release to install new versions of packages
minimumReleaseAge: 4320

Loading