Skip to content

Commit

Permalink
fix: assign correct dependency versions for published packages (#3102)
Browse files Browse the repository at this point in the history
Closes #3100
  • Loading branch information
kyubisation authored Sep 20, 2024
1 parent 42d12d9 commit ed99ce9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tools/vite/package-json-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ export function packageJsonTemplate(
const rootPackageJsonPath = './package.json';
const packageJsonTemplatePath = options.templatePath ?? './package.json';
const rootPackageJson = JSON.parse(readFileSync(new URL(rootPackageJsonPath, root), 'utf8'));
const litMajorVersion = +rootPackageJson.dependencies.lit.match(/\d+/);
const litObserversMajorVersion =
+rootPackageJson.devDependencies['@lit-labs/observers'].match(/\d+/);
const litVersion = rootPackageJson.dependencies.lit.match(/\d+\.\d+\.\d+/);
const litObserversVersion =
rootPackageJson.devDependencies['@lit-labs/observers'].match(/\d+\.\d+\.\d+/);
const reactMajorVersion = +rootPackageJson.devDependencies.react.match(/\d+/);
const litReactMajorVersion = +rootPackageJson.devDependencies['@lit/react'].match(/\d+/);
const litReactVersion = rootPackageJson.devDependencies['@lit/react'].match(/\d+\.\d+\.\d+/);
const packageJsonTemplate = readFileSync(
join(viteConfig.root, packageJsonTemplatePath),
'utf8',
);
const packageJsonContent = packageJsonTemplate
.replaceAll('0.0.0-PLACEHOLDER', rootPackageJson.version)
.replaceAll('0.0.0-LITREACT', `^${litReactMajorVersion}.0.0`)
.replaceAll('0.0.0-LITOBSERVERS', `^${litObserversVersion}`)
.replaceAll('0.0.0-LITREACT', `^${litReactVersion}`)
.replaceAll('0.0.0-REACT', `^${reactMajorVersion}.0.0`)
.replaceAll('0.0.0-LIT', `^${litMajorVersion}.0.0`)
.replaceAll('0.0.0-LITOBSERVERS', `^${litObserversMajorVersion}.0.0`);
.replaceAll('0.0.0-LIT', `^${litVersion}`);
const packageJson = JSON.parse(packageJsonContent);
for (const key of ['author', 'license', 'repository', 'bugs']) {
packageJson[key] = rootPackageJson[key];
Expand Down

0 comments on commit ed99ce9

Please sign in to comment.