Jack Hsu 8bd0bcdd97
fix(js): generate pacakge.json for non-buildable nest and expo libs (#29891)
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 #
2025-02-05 16:27:56 -05:00

150 lines
4.7 KiB
JSON

{
"name": "library",
"factory": "./src/generators/library/library#libraryGeneratorInternal",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestLibraryGenerator",
"title": "Create a NestJS Library for Nx",
"description": "Create a NestJS Library for Nx.",
"cli": "nx",
"type": "object",
"examples": [
{
"command": "nx g lib mylib --directory=myapp",
"description": "Generate libs/myapp/mylib"
}
],
"properties": {
"directory": {
"description": "A directory where the library is placed.",
"type": "string",
"alias": "dir",
"$default": { "$source": "argv", "index": 0 },
"x-prompt": "Which directory do you want to create the library in?"
},
"name": {
"description": "Library name.",
"pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$",
"type": "string"
},
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "none"],
"default": "none",
"x-prompt": "Which linter would you like to use?",
"x-priority": "important"
},
"unitTestRunner": {
"description": "Test runner to use for unit tests.",
"type": "string",
"enum": ["jest", "none"],
"default": "none",
"x-prompt": "Which unit test runner would you like to use?",
"x-priority": "important"
},
"tags": {
"description": "Add tags to the library (used for linting).",
"type": "string",
"alias": "t"
},
"skipFormat": {
"description": "Skip formatting files.",
"type": "boolean",
"default": false,
"x-priority": "internal"
},
"skipTsConfig": {
"description": "Do not update tsconfig.base.json for development experience.",
"type": "boolean",
"default": false,
"x-priority": "internal"
},
"publishable": {
"description": "Create a publishable library.",
"type": "boolean",
"x-priority": "important"
},
"buildable": {
"description": "Generate a buildable library.",
"type": "boolean",
"default": false,
"x-priority": "important"
},
"importPath": {
"description": "The library name used to import it, like @myorg/my-awesome-lib. Must be a valid npm name.",
"type": "string"
},
"global": {
"description": "Add the Global decorator to the generated module.",
"type": "boolean",
"default": false
},
"service": {
"description": "Include a service with the library.",
"type": "boolean",
"default": false
},
"controller": {
"description": "Include a controller with the library.",
"type": "boolean",
"default": false
},
"testEnvironment": {
"description": "The test environment for jest, for node applications this should stay as node unless doing DOM testing.",
"type": "string",
"enum": ["jsdom", "node"],
"default": "node"
},
"target": {
"description": "The ES target, Nest suggest using es2021 or higher.",
"type": "string",
"default": "es2021",
"enum": [
"es5",
"es6",
"esnext",
"es2015",
"es2016",
"es2017",
"es2018",
"es2019",
"es2020",
"es2021"
]
},
"strict": {
"description": "Whether to enable tsconfig strict mode or not.",
"type": "boolean",
"default": true
},
"setParserOptionsProject": {
"type": "boolean",
"description": "Whether or not to configure the ESLint \"parserOptions.project\" option. We do not do this by default for lint performance reasons.",
"default": false
},
"skipPackageJson": {
"description": "Do not add dependencies to `package.json`.",
"type": "boolean",
"default": false,
"x-priority": "internal"
},
"simpleName": {
"description": "Don't include the directory in the name of the module of the library.",
"type": "boolean",
"default": false
}
},
"additionalProperties": false,
"required": ["directory"],
"presets": []
},
"aliases": ["lib"],
"x-type": "library",
"description": "Create a new NestJS library.",
"implementation": "/packages/nest/src/generators/library/library#libraryGeneratorInternal.ts",
"hidden": false,
"path": "/packages/nest/src/generators/library/schema.json",
"type": "generator"
}