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

fix(js): remove thirdParty default so that package.json will be generated by default #16015

Merged
merged 1 commit into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/generated/packages/esbuild/executors/esbuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@
},
"thirdParty": {
"type": "boolean",
"description": "Includes third-party packages in the bundle (i.e. npm packages).",
"default": true
"description": "Includes third-party packages in the bundle (i.e. npm packages)."
},
"dependenciesFieldType": {
"type": "string",
Expand Down
22 changes: 22 additions & 0 deletions packages/esbuild/src/executors/esbuild/lib/normalize.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('normalizeOptions', () => {
outputFileName: 'index.js',
singleEntry: true,
external: [],
thirdParty: false,
});
});

Expand All @@ -69,6 +70,7 @@ describe('normalizeOptions', () => {
additionalEntryPoints: ['apps/myapp/src/extra-entry.ts'],
singleEntry: false,
external: [],
thirdParty: false,
});
});

Expand All @@ -94,6 +96,7 @@ describe('normalizeOptions', () => {
outputFileName: 'test.js',
singleEntry: true,
external: [],
thirdParty: false,
});
});

Expand All @@ -108,6 +111,7 @@ describe('normalizeOptions', () => {
generatePackageJson: true,
additionalEntryPoints: ['apps/myapp/src/extra-entry.ts'],
outputFileName: 'test.js',
thirdParty: false,
},
context
)
Expand Down Expand Up @@ -135,6 +139,24 @@ describe('normalizeOptions', () => {
outputFileName: 'index.js',
singleEntry: true,
external: [],
thirdParty: false,
});
});

it('should override thirdParty if bundle:false', () => {
expect(
normalizeOptions(
{
main: 'apps/myapp/src/index.ts',
outputPath: 'dist/apps/myapp',
tsConfig: 'apps/myapp/tsconfig.app.json',
generatePackageJson: true,
bundle: false,
thirdParty: true,
assets: [],
},
context
)
).toEqual(expect.objectContaining({ thirdParty: false }));
});
});
20 changes: 19 additions & 1 deletion packages/esbuild/src/executors/esbuild/lib/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
EsBuildExecutorOptions,
NormalizedEsBuildExecutorOptions,
} from '../schema';
import { ExecutorContext, joinPathFragments } from '@nrwl/devkit';
import { ExecutorContext, joinPathFragments, logger } from '@nrwl/devkit';
import chalk = require('chalk');

export function normalizeOptions(
options: EsBuildExecutorOptions,
Expand All @@ -20,6 +21,21 @@ export function normalizeOptions(
),
];

if (!options.bundle && options.thirdParty) {
logger.info(
chalk.yellow(
`Your build has conflicting options, ${chalk.bold(
'bundle:false'
)} and ${chalk.bold(
'thirdParty:true'
)}. Your package.json depedencies might not be generated correctly so we added an update ${chalk.bold(
'thirdParty:false'
)}`
)
);
}

const thirdParty = !options.bundle ? false : options.thirdParty;
if (options.additionalEntryPoints?.length > 0) {
const { outputFileName, ...rest } = options;
if (outputFileName) {
Expand All @@ -29,6 +45,7 @@ export function normalizeOptions(
}
return {
...rest,
thirdParty,
assets,
external: options.external ?? [],
singleEntry: false,
Expand All @@ -40,6 +57,7 @@ export function normalizeOptions(
} else {
return {
...options,
thirdParty,
assets,
external: options.external ?? [],
singleEntry: true,
Expand Down
3 changes: 1 addition & 2 deletions packages/esbuild/src/executors/esbuild/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@
},
"thirdParty": {
"type": "boolean",
"description": "Includes third-party packages in the bundle (i.e. npm packages).",
"default": true
"description": "Includes third-party packages in the bundle (i.e. npm packages)."
},
"dependenciesFieldType": {
"type": "string",
Expand Down