This PR fixes a couple of issues for TS solution setup: 1. Expo library should generate with correct `package.json` file (e.g. `exports` maps either to source or dist). See [spec file](https://github.com/nrwl/nx/pull/29891/files#diff-ae2eb3d10d58786c17aa21f5603043b68043faaebafaec77912f3d69ac0c5295). 2. Nest library should generate `package.json` when non-buildable. See [spec file](https://github.com/nrwl/nx/pull/29891/files#diff-368467bcd2215def98ef14aaff9dcb056a915b0a724d0eb857f3a0badef8b40a). **Notes:** - Also removed an unsupported `standaloneConfig` option from `@nx/nest:lib` generator. This was removed a long time ago in other generators. - Expo lib generator isn't crystalized when using Rollup for build. This is a separate issue and we'll handle it in another task. ## Current Behavior - Non-buildable Expo libs generate without `exports` - Buildable Expo libs fail to generate due to error - Non-buildable Nest libs do not generate `package.json` ## Expected Behavior Expo and Nest libs generate correct `package.json` files depending on whether they are build or non-buildable. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
66 lines
1.8 KiB
TypeScript
66 lines
1.8 KiB
TypeScript
import { readNxJson, Tree } from '@nx/devkit';
|
|
import {
|
|
determineProjectNameAndRootOptions,
|
|
ensureProjectName,
|
|
} from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
import { Schema } from '../schema';
|
|
import { isUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';
|
|
import { getImportPath } from '@nx/js/src/utils/get-import-path';
|
|
|
|
export interface NormalizedSchema extends Schema {
|
|
name: string;
|
|
fileName: string;
|
|
projectName: string;
|
|
projectRoot: string;
|
|
routePath: string;
|
|
parsedTags: string[];
|
|
appMain: string;
|
|
isUsingTsSolutionConfig: boolean;
|
|
}
|
|
|
|
export async function normalizeOptions(
|
|
host: Tree,
|
|
options: Schema
|
|
): Promise<NormalizedSchema> {
|
|
await ensureProjectName(host, options, 'library');
|
|
const {
|
|
projectName,
|
|
names: projectNames,
|
|
projectRoot,
|
|
importPath,
|
|
} = await determineProjectNameAndRootOptions(host, {
|
|
name: options.name,
|
|
projectType: 'library',
|
|
directory: options.directory,
|
|
importPath: options.importPath,
|
|
});
|
|
const nxJson = readNxJson(host);
|
|
const addPluginDefault =
|
|
process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
nxJson.useInferencePlugins !== false;
|
|
options.addPlugin ??= addPluginDefault;
|
|
|
|
const parsedTags = options.tags
|
|
? options.tags.split(',').map((s) => s.trim())
|
|
: [];
|
|
const appMain = options.js ? 'src/index.js' : 'src/index.ts';
|
|
|
|
const isUsingTsSolutionConfig = isUsingTsSolutionSetup(host);
|
|
const normalized: NormalizedSchema = {
|
|
...options,
|
|
fileName: projectName,
|
|
routePath: `/${projectNames.projectSimpleName}`,
|
|
name: projectName,
|
|
projectName: isUsingTsSolutionConfig
|
|
? getImportPath(host, projectName)
|
|
: projectName,
|
|
projectRoot,
|
|
parsedTags,
|
|
importPath,
|
|
appMain,
|
|
isUsingTsSolutionConfig,
|
|
};
|
|
|
|
return normalized;
|
|
}
|