-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(container): compiling error with pnpm (#12934)
- Loading branch information
Showing
14 changed files
with
73 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fixes a regression where the Astro Container didn't work during the build, using `pnpm` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { RoutePart } from '../../../types/public/index.js'; | ||
|
||
// Disable eslint as we're not sure how to improve this regex yet | ||
// eslint-disable-next-line regexp/no-super-linear-backtracking | ||
const ROUTE_DYNAMIC_SPLIT = /\[(.+?\(.+?\)|.+?)\]/; | ||
const ROUTE_SPREAD = /^\.{3}.+$/; | ||
|
||
export function getParts(part: string, file: string) { | ||
const result: RoutePart[] = []; | ||
part.split(ROUTE_DYNAMIC_SPLIT).map((str, i) => { | ||
if (!str) return; | ||
const dynamic = i % 2 === 1; | ||
|
||
const [, content] = dynamic ? /([^(]+)$/.exec(str) || [null, null] : [null, str]; | ||
|
||
if (!content || (dynamic && !/^(?:\.\.\.)?[\w$]+$/.test(content))) { | ||
throw new Error(`Invalid route ${file} — parameter name must match /^[a-zA-Z0-9_$]+$/`); | ||
} | ||
|
||
result.push({ | ||
content, | ||
dynamic, | ||
spread: dynamic && ROUTE_SPREAD.test(content), | ||
}); | ||
}); | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export function validateSegment(segment: string, file = '') { | ||
if (!file) file = segment; | ||
|
||
if (segment.includes('][')) { | ||
throw new Error(`Invalid route ${file} \u2014 parameters must be separated`); | ||
} | ||
if (countOccurrences('[', segment) !== countOccurrences(']', segment)) { | ||
throw new Error(`Invalid route ${file} \u2014 brackets are unbalanced`); | ||
} | ||
if ( | ||
(/.+\[\.\.\.[^\]]+\]/.test(segment) || /\[\.\.\.[^\]]+\].+/.test(segment)) && | ||
file.endsWith('.astro') | ||
) { | ||
throw new Error(`Invalid route ${file} \u2014 rest parameter must be a standalone segment`); | ||
} | ||
} | ||
|
||
function countOccurrences(needle: string, haystack: string) { | ||
let count = 0; | ||
for (const hay of haystack) { | ||
if (hay === needle) count += 1; | ||
} | ||
return count; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters