fix(bundling): fix regression with --thirdParty option for esbuild (#19835)

This commit is contained in:
Jack Hsu 2023-10-25 08:18:30 -04:00 committed by GitHub
parent 8932b069f5
commit 75062ef4e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -156,6 +156,13 @@ describe('EsBuild Plugin', () => {
// Bundle only child lib
runCLI(`build ${parentLib} --third-party=false`);
expect(
readJson(`dist/libs/${parentLib}/package.json`).dependencies
).toEqual({
// Don't care about the versions, just that they exist
rambda: expect.any(String),
lodash: expect.any(String),
});
runResult = runCommand(`node dist/libs/${parentLib}/index.cjs`);
expect(runResult).toMatch(/Hello world/);
expect(runResult).toMatch(/Hello from child lib/);

View File

@ -87,6 +87,10 @@ export async function* esbuildExecutor(
generateLockfile: true,
outputFileExtensionForCjs: getOutExtension('cjs', options),
excludeLibsInPackageJson: !options.thirdParty,
// TODO(jack): Remove the need to pass updateBuildableProjectDepsInPackageJson option when overrideDependencies or extraDependencies are passed.
// Add this back to fix a regression.
// See: https://github.com/nrwl/nx/issues/19773
updateBuildableProjectDepsInPackageJson: externalDependencies.length > 0,
};
// If we're bundling third-party packages, then any extra deps from external should be the only deps in package.json