Skip to content

Commit

Permalink
fix(nx-plugin): tslib is not set as a dependency when using create-pa…
Browse files Browse the repository at this point in the history
…ckage generator
  • Loading branch information
jogelin committed Mar 22, 2024
1 parent 2678bdf commit ef45aca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import pluginGenerator from '../plugin/plugin';
import { createPackageGenerator } from './create-package';
import { CreatePackageSchema } from './schema';
import { setCwd } from '@nx/devkit/internal-testing-utils';
import { tsLibVersion } from '@nx/js/src/utils/versions';
import { nxVersion } from 'nx/src/utils/versions';

const getSchema: (
overrides?: Partial<CreatePackageSchema>
Expand Down Expand Up @@ -126,4 +128,21 @@ describe('NxPlugin Create Package Generator', () => {

expect(name).toEqual('create-a-workspace');
});

it("should have valid default package.json's dependencies", async () => {
await createPackageGenerator(tree, getSchema());

const { root } = readProjectConfiguration(tree, 'create-a-workspace');
const { dependencies } = readJson<PackageJson>(
tree,
joinPathFragments(root, 'package.json')
);

expect(dependencies).toEqual(
expect.objectContaining({
'create-nx-workspace': nxVersion,
tslib: tsLibVersion,
})
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
updateProjectConfiguration,
} from '@nx/devkit';
import { libraryGenerator as jsLibraryGenerator } from '@nx/js';
import { addTsLibDependencies } from '@nx/js/src/utils/typescript/add-tslib-dependencies';
import { nxVersion } from 'nx/src/utils/versions';
import generatorGenerator from '../generator/generator';
import { CreatePackageSchema } from './schema';
Expand All @@ -39,6 +40,10 @@ export async function createPackageGeneratorInternal(
const options = await normalizeSchema(host, schema);
const pluginPackageName = await addPresetGenerator(host, options);

if (options.bundler === 'tsc') {
tasks.push(addTsLibDependencies(host));
}

const installTask = addDependenciesToPackageJson(
host,
{
Expand Down

0 comments on commit ef45aca

Please sign in to comment.