Skip to content

Commit

Permalink
Remove use of URL module in runtime (#2107)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
matthewp committed Dec 3, 2021
1 parent b098f04 commit 4c44467
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changeset/empty-oranges-provide.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 1 addition & 2 deletions packages/astro/src/runtime/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 4c44467

Please sign in to comment.