fix(nx-plugin): tslib is not set as a dependency when using create-package generator (#22429)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior The linting failed on clean `create-nx-plugin` generation:  ## Expected Behavior After a clean generation, build, test, and lint should be successful Co-authored-by: Emily Xiong <xiongemi@gmail.com>
This commit is contained in:
parent
62baf4f307
commit
23ce6af2cc
@ -13,6 +13,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>
|
||||
@ -128,4 +130,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,
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -13,12 +13,14 @@ 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';
|
||||
import { NormalizedSchema, normalizeSchema } from './utils/normalize-schema';
|
||||
import { hasGenerator } from '../../utils/has-generator';
|
||||
import { join } from 'path';
|
||||
import { tsLibVersion } from '@nx/js/src/utils/versions';
|
||||
|
||||
export async function createPackageGenerator(
|
||||
host: Tree,
|
||||
@ -39,6 +41,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,
|
||||
{
|
||||
@ -112,6 +118,7 @@ async function createCliPackage(
|
||||
};
|
||||
packageJson.dependencies = {
|
||||
'create-nx-workspace': nxVersion,
|
||||
...(options.bundler === 'tsc' && { tslib: tsLibVersion }),
|
||||
};
|
||||
return packageJson;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user