diff options
author | 2021-12-03 09:13:20 -0500 | |
---|---|---|
committer | 2021-12-03 09:13:20 -0500 | |
commit | 4c44467668045733b4e5c3bbed8a1bde2ba421de (patch) | |
tree | 59b33e1a859f156664a3d502d613e4268a7abd1e | |
parent | b098f04dc3fa927d9ac6c13e979ca88c1ecff5ef (diff) | |
download | astro-4c44467668045733b4e5c3bbed8a1bde2ba421de.tar.gz astro-4c44467668045733b4e5c3bbed8a1bde2ba421de.tar.zst astro-4c44467668045733b4e5c3bbed8a1bde2ba421de.zip |
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
-rw-r--r-- | .changeset/empty-oranges-provide.md | 7 | ||||
-rw-r--r-- | packages/astro/src/runtime/server/index.ts | 3 |
2 files changed, 8 insertions, 2 deletions
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), |