fix(bundling): support additionalEntryPoints properly (#14773)
This commit is contained in:
parent
0d33bb076b
commit
2d566593c0
@ -172,4 +172,22 @@ describe('EsBuild Plugin', () => {
|
|||||||
// Check that the build is correct
|
// Check that the build is correct
|
||||||
expect(runCommand(`node dist/libs/${myPkg}`)).toMatch(/new API/);
|
expect(runCommand(`node dist/libs/${myPkg}`)).toMatch(/new API/);
|
||||||
}, 120_000);
|
}, 120_000);
|
||||||
|
|
||||||
|
it('should support additional entry points', () => {
|
||||||
|
const myPkg = uniq('my-pkg');
|
||||||
|
runCLI(`generate @nrwl/js:lib ${myPkg} --bundler=esbuild`);
|
||||||
|
updateFile(`libs/${myPkg}/src/index.ts`, `console.log('main');\n`);
|
||||||
|
updateFile(`libs/${myPkg}/src/extra.ts`, `console.log('extra');\n`);
|
||||||
|
updateProjectConfig(myPkg, (json) => {
|
||||||
|
json.targets.build.options.additionalEntryPoints = [
|
||||||
|
`libs/${myPkg}/src/extra.ts`,
|
||||||
|
];
|
||||||
|
return json;
|
||||||
|
});
|
||||||
|
|
||||||
|
runCommand(`build ${myPkg}`);
|
||||||
|
|
||||||
|
expect(runCommand(`node dist/libs/${myPkg}/main.js`)).toMatch(/main/);
|
||||||
|
expect(runCommand(`node dist/libs/${myPkg}/extra.js`)).toMatch(/extra/);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -179,6 +179,7 @@ export async function* esbuildExecutor(
|
|||||||
yield {
|
yield {
|
||||||
success: buildResult.errors.length === 0,
|
success: buildResult.errors.length === 0,
|
||||||
// Need to call getOutfile directly in the case of bundle=false and outfile is not set for esbuild.
|
// Need to call getOutfile directly in the case of bundle=false and outfile is not set for esbuild.
|
||||||
|
// This field is needed for `@nrwl/js:node` executor to work.
|
||||||
outfile: join(context.root, getOutfile(format, options, context)),
|
outfile: join(context.root, getOutfile(format, options, context)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -223,6 +224,7 @@ export async function* esbuildExecutor(
|
|||||||
next({
|
next({
|
||||||
success,
|
success,
|
||||||
// Need to call getOutfile directly in the case of bundle=false and outfile is not set for esbuild.
|
// Need to call getOutfile directly in the case of bundle=false and outfile is not set for esbuild.
|
||||||
|
// This field is needed for `@nrwl/js:node` executor to work.
|
||||||
outfile: join(
|
outfile: join(
|
||||||
context.root,
|
context.root,
|
||||||
getOutfile(format, options, context)
|
getOutfile(format, options, context)
|
||||||
|
|||||||
@ -38,6 +38,7 @@ describe('normalizeOptions', () => {
|
|||||||
tsConfig: 'apps/myapp/tsconfig.app.json',
|
tsConfig: 'apps/myapp/tsconfig.app.json',
|
||||||
project: 'apps/myapp/package.json',
|
project: 'apps/myapp/package.json',
|
||||||
assets: [],
|
assets: [],
|
||||||
|
outputFileName: 'index.js',
|
||||||
additionalEntryPoints: ['apps/myapp/src/extra-entry.ts'],
|
additionalEntryPoints: ['apps/myapp/src/extra-entry.ts'],
|
||||||
singleEntry: false,
|
singleEntry: false,
|
||||||
external: [],
|
external: [],
|
||||||
|
|||||||
@ -18,6 +18,10 @@ export function normalizeOptions(
|
|||||||
...rest,
|
...rest,
|
||||||
external: options.external ?? [],
|
external: options.external ?? [],
|
||||||
singleEntry: false,
|
singleEntry: false,
|
||||||
|
// Use the `main` file name as the output file name.
|
||||||
|
// This is needed for `@nrwl/js:node` to know the main file to execute.
|
||||||
|
// NOTE: The .js default extension may be replaced later in getOutfile() call.
|
||||||
|
outputFileName: `${parse(options.main).name}.js`,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
@ -25,6 +29,7 @@ export function normalizeOptions(
|
|||||||
external: options.external ?? [],
|
external: options.external ?? [],
|
||||||
singleEntry: true,
|
singleEntry: true,
|
||||||
outputFileName:
|
outputFileName:
|
||||||
|
// NOTE: The .js default extension may be replaced later in getOutfile() call.
|
||||||
options.outputFileName ?? `${parse(options.main).name}.js`,
|
options.outputFileName ?? `${parse(options.main).name}.js`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user