fix(js): generate correct build options for rollup bundler; by defaul… (#15184)

This commit is contained in:
Chau Tran 2023-02-23 09:01:15 -06:00 committed by GitHub
parent 16023ea679
commit 2f4f28760f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 1 deletions

View File

@ -810,6 +810,35 @@ describe('lib', () => {
});
});
describe('bundler=rollup', () => {
it('should generate correct options for build', async () => {
await libraryGenerator(tree, {
...defaultOptions,
name: 'myLib',
buildable: true,
bundler: 'rollup',
});
const config = readProjectConfiguration(tree, 'my-lib');
expect(config.targets.build.options.project).toEqual(
`libs/my-lib/package.json`
);
});
it('should set compiler to swc', async () => {
await libraryGenerator(tree, {
...defaultOptions,
name: 'myLib',
buildable: true,
bundler: 'rollup',
compiler: 'swc',
});
const config = readProjectConfiguration(tree, 'my-lib');
expect(config.targets.build.options.compiler).toEqual('swc');
});
});
describe('--publishable', () => {
it('should generate the build target', async () => {
await libraryGenerator(tree, {

View File

@ -83,7 +83,7 @@ export async function projectGenerator(
});
tasks.push(viteTask);
}
if (schema.bundler === 'rollup') {
if (options.bundler === 'rollup') {
ensureBabelRootConfigExists(tree);
}
@ -160,6 +160,13 @@ function addProject(
},
};
if (options.bundler === 'rollup') {
projectConfiguration.targets.build.options.project = `${options.projectRoot}/package.json`;
if (options.compiler === 'swc') {
projectConfiguration.targets.build.options.compiler = 'swc';
}
}
if (options.compiler === 'swc' && options.skipTypeCheck) {
projectConfiguration.targets.build.options.skipTypeCheck = true;
}