Chau Tran 142ed2eead
feat(js): inline non-buildable libs for tsc and swc (#12280)
Co-authored-by: Chau Tran <chautran@10.0.0.10>
2022-10-07 09:46:43 +07:00

614 lines
24 KiB
JSON

{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "js",
"packageName": "@nrwl/js",
"description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
"root": "/packages/js",
"source": "/packages/js/src",
"documentation": [
{
"name": "Overview",
"id": "overview",
"path": "/packages/js",
"file": "shared/js-plugin",
"content": "The JS plugin contains executors and generators that are useful for JavaScript/TypeScript projects in an Nx workspace.\n\n## Setting Up JS\n\n### Installation\n\nIn any Nx workspace, you can install `@nrwl/js` by running the following commands if `@nrwl/js` package is not installed:\n\n{% tabs %}\n{%tab label=\"npm\"%}\n\n```bash\nnpm i --save-dev @nrwl/js\n```\n\n{% /tab %}\n{%tab label=\"yarn\"%}\n\n```bash\nyarn add --dev @nrwl/js\n```\n\n{% /tab %}\n{% /tabs %}\n\n### `ts` Preset\n\nWhen initializing a new Nx workspace, specifying `--preset=ts` will generate a workspace with `@nrwl/js` pre-installed.\n\n{% tabs %}\n{%tab label=\"npm\"%}\n\n```bash\nnpx create-nx-workspace my-org --preset=ts\n```\n\n{% /tab %}\n{%tab label=\"yarn\"%}\n\n```bash\nyarn create nx-workspace my-org --preset=ts\n```\n\n{% /tab %}\n{% /tabs %}\n\n## Create Libraries\n\nYou can add a new JS/TS library with the following command:\n\n```shell\nnx g @nrwl/js:lib my-lib\n```\n\n## Build\n\nYou can `build` libraries that are generated with `--buildable` flag.\n\n```shell\nnx g @nrwl/js:lib my-buildable-lib --buildable\n```\n\nGenerating a library with `--buildable` will add a `build` target to the library's `project.json` file allows the library to be built.\n\n```shell\nnx build my-buildable-lib\n```\n\n## Test\n\nYou can test a library with the following command:\n\n```shell\nnx test my-lib\n```\n\n## Lint\n\nYou can lint a library with the following command:\n\n```shell\nnx lint my-lib\n```\n\n## Compiler\n\nBy default, `@nrwl/js` uses [TypeScript Compiler (TSC)](https://www.typescriptlang.org/docs/handbook/2/basic-types.html#tsc-the-typescript-compiler), via `@nrwl/js:tsc` executor, to compile your libraries. Optionally, you can switch `tsc` out for a different compiler with `--compiler` flag when executing the generators.\n\nCurrently, `@nrwl/js` supports the following compilers:\n\n- [Speedy Web Compiler (SWC)](https://swc.rs)\n\n### SWC\n\n- Create a buildable library with `swc`\n\n```shell\nnx g @nrwl/js:lib my-swc-lib --compiler=swc --buildable\n```\n\n- Convert a `tsc` library to use `swc`\n\n```shell\nnx g @nrwl/js:convert-to-swc my-buildable-lib\n```\n\nNow the `build` command will use `@nrwl/js:swc` executor to compile your libraries.\n\n> The first time you generate a `swc` library or convert a `tsc` library over to `swc`, `@nrwl/js` will install the necessary dependencies to use `swc`.\n"
}
],
"generators": [
{
"name": "library",
"factory": "./src/generators/library/library#libraryGenerator",
"schema": {
"$schema": "http://json-schema.org/schema",
"$id": "NxTypescriptLibrary",
"cli": "nx",
"title": "Create a TypeScript Library",
"description": "Create a TypeScript Library.",
"type": "object",
"examples": [
{
"command": "nx g lib mylib --directory=myapp",
"description": "Generate libs/myapp/mylib"
}
],
"properties": {
"name": {
"type": "string",
"description": "Library name.",
"$default": { "$source": "argv", "index": 0 },
"x-prompt": "What name would you like to use for the library?",
"pattern": "^[a-zA-Z].*$"
},
"directory": {
"type": "string",
"description": "A directory where the lib is placed."
},
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "none"],
"default": "eslint"
},
"unitTestRunner": {
"type": "string",
"enum": ["jest", "none"],
"description": "Test runner to use for unit tests.",
"default": "jest"
},
"tags": {
"type": "string",
"description": "Add tags to the library (used for linting)."
},
"skipFormat": {
"description": "Skip formatting files.",
"type": "boolean",
"default": false
},
"skipTsConfig": {
"type": "boolean",
"description": "Do not update tsconfig.json for development experience.",
"default": false
},
"includeBabelRc": {
"type": "boolean",
"description": "Include a .babelrc configuration to compile TypeScript files"
},
"testEnvironment": {
"type": "string",
"enum": ["jsdom", "node"],
"description": "The test environment to use if unitTestRunner is set to jest.",
"default": "jsdom"
},
"importPath": {
"type": "string",
"description": "The library name used to import it, like @myorg/my-awesome-lib."
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case file names.",
"alias": "P",
"default": false
},
"js": {
"type": "boolean",
"description": "Generate JavaScript files rather than TypeScript files.",
"default": false
},
"strict": {
"type": "boolean",
"description": "Whether to enable tsconfig strict mode or not.",
"default": true
},
"publishable": {
"type": "boolean",
"default": false,
"description": "Generate a publishable library."
},
"buildable": {
"type": "boolean",
"default": true,
"description": "Generate a buildable library."
},
"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
},
"config": {
"type": "string",
"enum": ["workspace", "project", "npm-scripts"],
"default": "project",
"description": "Determines whether the project's executors should be configured in `workspace.json`, `project.json` or as npm scripts."
},
"compiler": {
"type": "string",
"enum": ["tsc", "swc"],
"default": "tsc",
"description": "The compiler used by the build and test targets"
},
"bundler": {
"description": "The bundler to use.",
"enum": ["none", "esbuild", "rollup", "webpack"],
"default": "none"
},
"skipTypeCheck": {
"type": "boolean",
"description": "Whether to skip TypeScript type checking for SWC compiler.",
"default": false
}
},
"required": ["name"],
"presets": []
},
"aliases": ["lib"],
"x-type": "library",
"description": "Create a library",
"implementation": "/packages/js/src/generators/library/library#libraryGenerator.ts",
"hidden": false,
"path": "/packages/js/src/generators/library/schema.json"
},
{
"name": "init",
"factory": "./src/generators/init/init#initGenerator",
"schema": {
"$schema": "http://json-schema.org/schema",
"$id": "NxTypescriptInit",
"cli": "nx",
"title": "Init nrwl/js",
"description": "Init generator placeholder for nrwl/js.",
"presets": []
},
"aliases": ["lib"],
"x-type": "init",
"description": "Init placeholder.",
"implementation": "/packages/js/src/generators/init/init#initGenerator.ts",
"hidden": false,
"path": "/packages/js/src/generators/init/schema.json"
},
{
"name": "convert-to-swc",
"factory": "./src/generators/convert-to-swc/convert-to-swc#convertToSwcGenerator",
"schema": {
"$schema": "http://json-schema.org/schema",
"$id": "NxTypescriptLibrary",
"cli": "nx",
"title": "Convert a TSC library to SWC",
"description": "Convert a TSC library to SWC.",
"type": "object",
"examples": [
{
"command": "nx g swc mylib",
"description": "Convert `libs/myapp/mylib` to SWC."
}
],
"properties": {
"project": {
"type": "string",
"description": "Library name.",
"$default": { "$source": "argv", "index": 0 },
"x-prompt": "What name would you like to use for the library?",
"pattern": "^[a-zA-Z].*$"
},
"targets": {
"type": "array",
"description": "List of targets to convert.",
"items": { "type": "string", "description": "Target to convert." },
"default": ["build"]
}
},
"required": ["project"],
"presets": []
},
"aliases": ["swc"],
"x-type": "library",
"description": "Convert a TypeScript library to compile with SWC.",
"implementation": "/packages/js/src/generators/convert-to-swc/convert-to-swc#convertToSwcGenerator.ts",
"hidden": false,
"path": "/packages/js/src/generators/convert-to-swc/schema.json"
}
],
"executors": [
{
"name": "tsc",
"implementation": "/packages/js/src/executors/tsc/tsc.impl.ts",
"schema": {
"title": "Typescript Build Target",
"description": "Builds using TypeScript.",
"cli": "nx",
"type": "object",
"properties": {
"main": {
"type": "string",
"description": "The name of the main entry-point file.",
"x-completion-type": "file",
"x-completion-glob": "main@(.js|.ts|.jsx|.tsx)"
},
"rootDir": {
"type": "string",
"description": "Sets the rootDir for TypeScript compilation. When not defined, it uses the root of project."
},
"outputPath": {
"type": "string",
"description": "The output path of the generated files.",
"x-completion-type": "directory"
},
"tsConfig": {
"type": "string",
"description": "The path to the Typescript configuration file.",
"x-completion-type": "file",
"x-completion-glob": "tsconfig.*.json"
},
"assets": {
"type": "array",
"description": "List of static assets.",
"default": [],
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"glob": {
"type": "string",
"description": "The pattern to match."
},
"input": {
"type": "string",
"description": "The input directory path in which to apply 'glob'. Defaults to the project root."
},
"ignore": {
"description": "An array of globs to ignore.",
"type": "array",
"items": { "type": "string" }
},
"output": {
"type": "string",
"description": "Absolute path within the output."
}
},
"additionalProperties": false,
"required": ["glob", "input", "output"]
},
{ "type": "string" }
]
}
},
"watch": {
"type": "boolean",
"description": "Enable re-building when files change.",
"default": false
},
"clean": {
"type": "boolean",
"description": "Remove previous output before build.",
"default": true
},
"transformers": {
"type": "array",
"description": "List of TypeScript Transformer Plugins.",
"default": [],
"items": {
"oneOf": [
{ "type": "string" },
{
"type": "object",
"properties": {
"name": { "type": "string" },
"options": {
"type": "object",
"additionalProperties": true
}
},
"additionalProperties": false,
"required": ["name"]
}
]
}
},
"updateBuildableProjectDepsInPackageJson": {
"type": "boolean",
"description": "Whether to update the buildable project dependencies in `package.json`.",
"default": true
},
"buildableProjectDepsInPackageJsonType": {
"type": "string",
"description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.",
"enum": ["dependencies", "peerDependencies"],
"default": "peerDependencies"
},
"external": {
"description": "A list projects to be treated as external. This feature is experimental",
"oneOf": [
{ "type": "string", "enum": ["all", "none"] },
{ "type": "array", "items": { "type": "string" } }
]
},
"externalBuildTargets": {
"type": "array",
"items": { "type": "string" },
"description": "List of target names that annotate a build target for a project",
"default": ["build"]
}
},
"required": ["main", "outputPath", "tsConfig"],
"definitions": {
"assetPattern": {
"oneOf": [
{
"type": "object",
"properties": {
"glob": {
"type": "string",
"description": "The pattern to match."
},
"input": {
"type": "string",
"description": "The input directory path in which to apply 'glob'. Defaults to the project root."
},
"ignore": {
"description": "An array of globs to ignore.",
"type": "array",
"items": { "type": "string" }
},
"output": {
"type": "string",
"description": "Absolute path within the output."
}
},
"additionalProperties": false,
"required": ["glob", "input", "output"]
},
{ "type": "string" }
]
},
"transformerPattern": {
"oneOf": [
{ "type": "string" },
{
"type": "object",
"properties": {
"name": { "type": "string" },
"options": { "type": "object", "additionalProperties": true }
},
"additionalProperties": false,
"required": ["name"]
}
]
}
},
"presets": []
},
"description": "Build a project using TypeScript.",
"aliases": [],
"hidden": false,
"path": "/packages/js/src/executors/tsc/schema.json"
},
{
"name": "swc",
"implementation": "/packages/js/src/executors/swc/swc.impl.ts",
"schema": {
"$schema": "http://json-schema.org/schema",
"cli": "nx",
"title": "Typescript Build Target",
"description": "Builds using SWC.",
"type": "object",
"properties": {
"main": {
"type": "string",
"description": "The name of the main entry-point file.",
"x-completion-type": "file",
"x-completion-glob": "main@(.js|.ts|.tsx)"
},
"outputPath": {
"type": "string",
"description": "The output path of the generated files.",
"x-completion-type": "directory"
},
"tsConfig": {
"type": "string",
"description": "The path to the Typescript configuration file.",
"x-completion-type": "file",
"x-completion-glob": "tsconfig.*.json"
},
"swcrc": {
"type": "string",
"description": "The path to the SWC configuration file. Default: .lib.swcrc",
"x-completion-type": "file",
"x-completion-glob": ".swcrc"
},
"assets": {
"type": "array",
"description": "List of static assets.",
"default": [],
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"glob": {
"type": "string",
"description": "The pattern to match."
},
"input": {
"type": "string",
"description": "The input directory path in which to apply 'glob'. Defaults to the project root."
},
"ignore": {
"description": "An array of globs to ignore.",
"type": "array",
"items": { "type": "string" }
},
"output": {
"type": "string",
"description": "Absolute path within the output."
}
},
"additionalProperties": false,
"required": ["glob", "input", "output"]
},
{ "type": "string" }
]
}
},
"watch": {
"type": "boolean",
"description": "Enable re-building when files change.",
"default": false
},
"clean": {
"type": "boolean",
"description": "Remove previous output before build.",
"default": true
},
"skipTypeCheck": {
"type": "boolean",
"description": "Whether to skip TypeScript type checking.",
"default": false
},
"swcExclude": {
"type": "array",
"description": "List of SWC Glob/Regex to be excluded from compilation (https://swc.rs/docs/configuration/compilation#exclude).",
"default": [
"./src/**/.*.spec.ts$",
"./**/.*.spec.ts$",
"./src/**/jest-setup.ts$",
"./**/jest-setup.ts$",
"./**/.*.js$"
]
},
"updateBuildableProjectDepsInPackageJson": {
"type": "boolean",
"description": "Whether to update the buildable project dependencies in `package.json`.",
"default": true
},
"buildableProjectDepsInPackageJsonType": {
"type": "string",
"description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.",
"enum": ["dependencies", "peerDependencies"],
"default": "peerDependencies"
},
"external": {
"description": "A list projects to be treated as external. This feature is experimental",
"oneOf": [
{ "type": "string", "enum": ["all", "none"] },
{ "type": "array", "items": { "type": "string" } }
]
},
"externalBuildTargets": {
"type": "array",
"items": { "type": "string" },
"description": "List of target names that annotate a build target for a project",
"default": ["build"]
}
},
"required": ["main", "outputPath", "tsConfig"],
"definitions": {
"assetPattern": {
"oneOf": [
{
"type": "object",
"properties": {
"glob": {
"type": "string",
"description": "The pattern to match."
},
"input": {
"type": "string",
"description": "The input directory path in which to apply 'glob'. Defaults to the project root."
},
"ignore": {
"description": "An array of globs to ignore.",
"type": "array",
"items": { "type": "string" }
},
"output": {
"type": "string",
"description": "Absolute path within the output."
}
},
"additionalProperties": false,
"required": ["glob", "input", "output"]
},
{ "type": "string" }
]
}
},
"presets": []
},
"description": "Build a project using SWC.",
"aliases": [],
"hidden": false,
"path": "/packages/js/src/executors/swc/schema.json"
},
{
"name": "node",
"implementation": "/packages/js/src/executors/node/node.impl.ts",
"schema": {
"$schema": "http://json-schema.org/schema",
"cli": "nx",
"title": "Node executor",
"description": "Execute Nodejs applications.",
"type": "object",
"properties": {
"buildTarget": {
"type": "string",
"description": "The target to run to build you the app."
},
"buildTargetOptions": {
"type": "object",
"description": "Additional options to pass into the build target.",
"default": {}
},
"waitUntilTargets": {
"type": "array",
"description": "The targets to run to before starting the node app.",
"default": [],
"items": { "type": "string" }
},
"host": {
"type": "string",
"default": "localhost",
"description": "The host to inspect the process on."
},
"port": {
"type": "number",
"default": 9229,
"description": "The port to inspect the process on. Setting port to 0 will assign random free ports to all forked processes."
},
"inspect": {
"oneOf": [
{ "type": "string", "enum": ["inspect", "inspect-brk"] },
{ "type": "boolean" }
],
"description": "Ensures the app is starting with debugging.",
"default": "inspect"
},
"runtimeArgs": {
"type": "array",
"description": "Extra args passed to the node process.",
"default": [],
"items": { "type": "string" }
},
"args": {
"type": "array",
"description": "Extra args when starting the app.",
"default": [],
"items": { "type": "string" }
},
"watch": {
"type": "boolean",
"description": "Enable re-building when files change.",
"default": true
}
},
"additionalProperties": false,
"required": ["buildTarget"],
"presets": []
},
"description": "Execute a Node application.",
"aliases": [],
"hidden": false,
"path": "/packages/js/src/executors/node/schema.json"
}
]
}