Skip to content

Commit

Permalink
fix(js): generate correct build options for rollup bundler; by defaul… (
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Feb 23, 2023
1 parent 16023ea commit 2f4f287
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
29 changes: 29 additions & 0 deletions packages/js/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
9 changes: 8 additions & 1 deletion packages/js/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function projectGenerator(
});
tasks.push(viteTask);
}
if (schema.bundler === 'rollup') {
if (options.bundler === 'rollup') {
ensureBabelRootConfigExists(tree);
}

Expand Down Expand Up @@ -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;
}
Expand Down

1 comment on commit 2f4f287

@vercel
Copy link

@vercel vercel bot commented on 2f4f287 Feb 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx.dev
nx-dev-git-master-nrwl.vercel.app

Please sign in to comment.