Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core/ssr] Add Node builds that don't explode #3156

Merged
merged 14 commits into from Aug 4, 2022
6 changes: 3 additions & 3 deletions scripts/update-version-variables.js
Expand Up @@ -24,12 +24,12 @@ const updateVersionVariable = async (packageDir, sourcePath, variableName) => {

// Replace version number
const versionVarRegex = new RegExp(
`\\(globalThis\\.${variableName} \\?\\?= \\[\\]\\)\\.push\\('\\d+\\.\\d+\\.\\d+'\\)`
`(\\(global(?:This)?\\.${variableName} \\?\\?= \\[\\]\\)\\.push\\(')\\d+\\.\\d+\\.\\d+[^']*('\\))`
);
let replaced = false;
const newSource = fileSource.replace(versionVarRegex, () => {
const newSource = fileSource.replace(versionVarRegex, (_, pre, post) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh very nice utilization of capture groups.

replaced = true;
return `(globalThis.${variableName} ??= []).push('${version}')`;
return pre + version + post;
});
if (!replaced) {
throw new Error(`Version variable not found: ${filePath} ${variableName}`);
Expand Down