From 4c44467668045733b4e5c3bbed8a1bde2ba421de Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 3 Dec 2021 09:13:20 -0500 Subject: [PATCH] Remove use of URL module in runtime (#2107) * Remove use of URL module We can't use this module due to Vite not having a shim and this needing to run inside Vite. * Adding a changeset --- .changeset/empty-oranges-provide.md | 7 +++++++ packages/astro/src/runtime/server/index.ts | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/empty-oranges-provide.md diff --git a/.changeset/empty-oranges-provide.md b/.changeset/empty-oranges-provide.md new file mode 100644 index 000000000..6785353a8 --- /dev/null +++ b/.changeset/empty-oranges-provide.md @@ -0,0 +1,7 @@ +--- +'astro': patch +--- + +Fixes regression in build caused by use of URL module + +Using this module breaks the build because Vite tries to shim it, incorrectly. diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts index 010474b2b..9e0d75f48 100644 --- a/packages/astro/src/runtime/server/index.ts +++ b/packages/astro/src/runtime/server/index.ts @@ -2,7 +2,6 @@ import type { AstroComponentMetadata, Renderer } from '../../@types/astro'; import type { AstroGlobalPartial, SSRResult, SSRElement } from '../../@types/astro'; import shorthash from 'shorthash'; -import { pathToFileURL } from 'url'; import { extractDirectives, generateHydrateScript } from './hydration.js'; import { serializeListValue } from './util.js'; export { createMetadata } from './metadata.js'; @@ -289,7 +288,7 @@ function createFetchContentFn(url: URL) { // Inside of getStaticPaths. export function createAstro(fileURLStr: string, site: string, projectRootStr: string): AstroGlobalPartial { const url = new URL(fileURLStr); - const projectRoot = projectRootStr === '.' ? pathToFileURL(process.cwd()) : new URL(projectRootStr); + const projectRoot = new URL(projectRootStr); const fetchContent = createFetchContentFn(url); return { site: new URL(site),