diff --git a/packages/modular-scripts/src/build-scripts/build-package/makeBundle.ts b/packages/modular-scripts/src/build-scripts/build-package/makeBundle.ts index 1ad18a611..b433c9c1f 100644 --- a/packages/modular-scripts/src/build-scripts/build-package/makeBundle.ts +++ b/packages/modular-scripts/src/build-scripts/build-package/makeBundle.ts @@ -39,7 +39,6 @@ export async function makeBundle( const { rootPackageWorkspaceDefinitions, rootPackageJsonDependencies, - rootPackageJsonEngines, packageJsons, packageJsonsByPackagePath, packageNames, @@ -57,11 +56,6 @@ export async function makeBundle( const packageJson = packageJsonsByPackagePath[packagePath]; - // If engines field is not defined in the package's package.json, inherit it from the root package.json - if (!packageJson.engines) { - packageJson.engines = rootPackageJsonEngines; - } - const main = await getPackageEntryPoints(packagePath, includePrivate); logger.log(`building ${packageName}...`); diff --git a/packages/modular-scripts/src/utils/getPackageMetadata.ts b/packages/modular-scripts/src/utils/getPackageMetadata.ts index 376b6734b..0c7566b58 100644 --- a/packages/modular-scripts/src/utils/getPackageMetadata.ts +++ b/packages/modular-scripts/src/utils/getPackageMetadata.ts @@ -48,6 +48,10 @@ async function getPackageMetadata() { Array.from(workspaces).forEach(([packageName, workspace]) => { packageJsons[packageName] = workspace.rawPackageJson; + if (!packageJsons[packageName].engines) { + // If engines field is not defined in the package's package.json, inherit it from the root package.json + packageJsons[packageName].engines = rootPackageJsonEngines; + } packageJsonsByPackagePath[workspace.location] = workspace.rawPackageJson; });