212 lines
11 KiB
JSON
212 lines
11 KiB
JSON
{
|
|
"name": "rollup",
|
|
"implementation": "/packages/rollup/src/executors/rollup/rollup.impl.ts",
|
|
"schema": {
|
|
"version": 2,
|
|
"outputCapture": "direct-nodejs",
|
|
"title": "Web Library Rollup Target (Experimental)",
|
|
"description": "Packages a library for different web usages (ESM, CommonJS).",
|
|
"cli": "nx",
|
|
"type": "object",
|
|
"properties": {
|
|
"project": {
|
|
"type": "string",
|
|
"description": "The path to package.json file.",
|
|
"x-priority": "important"
|
|
},
|
|
"main": {
|
|
"type": "string",
|
|
"description": "The path to the entry file, relative to project.",
|
|
"alias": "entryFile",
|
|
"x-completion-type": "file",
|
|
"x-completion-glob": "**/*@(.js|.ts)",
|
|
"x-priority": "important"
|
|
},
|
|
"outputPath": {
|
|
"type": "string",
|
|
"description": "The output path of the generated files.",
|
|
"x-completion-type": "directory",
|
|
"x-priority": "important"
|
|
},
|
|
"outputFileName": {
|
|
"type": "string",
|
|
"description": "Name of the main output file. Defaults same basename as 'main' file."
|
|
},
|
|
"deleteOutputPath": {
|
|
"type": "boolean",
|
|
"description": "Delete the output path before building.",
|
|
"default": true
|
|
},
|
|
"tsConfig": {
|
|
"type": "string",
|
|
"description": "The path to tsconfig file.",
|
|
"x-completion-type": "file",
|
|
"x-completion-glob": "tsconfig.*.json",
|
|
"x-priority": "important"
|
|
},
|
|
"allowJs": {
|
|
"type": "boolean",
|
|
"description": "Allow JavaScript files to be compiled.",
|
|
"default": false
|
|
},
|
|
"format": {
|
|
"type": "array",
|
|
"description": "List of module formats to output. Defaults to matching format from tsconfig (e.g. CJS for CommonJS, and ESM otherwise).",
|
|
"alias": "f",
|
|
"items": { "type": "string", "enum": ["esm", "cjs"] }
|
|
},
|
|
"external": {
|
|
"type": "array",
|
|
"description": "A list of external modules that will not be bundled (`react`, `react-dom`, etc.). Can also be set to `all` (bundle nothing) or `none` (bundle everything).",
|
|
"oneOf": [
|
|
{ "type": "string", "enum": ["all", "none"] },
|
|
{ "type": "array", "items": { "type": "string" } }
|
|
]
|
|
},
|
|
"watch": {
|
|
"type": "boolean",
|
|
"description": "Enable re-building when files change.",
|
|
"default": false
|
|
},
|
|
"updateBuildableProjectDepsInPackageJson": {
|
|
"type": "boolean",
|
|
"description": "Update buildable project dependencies in `package.json`.",
|
|
"default": false,
|
|
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
|
|
},
|
|
"buildableProjectDepsInPackageJsonType": {
|
|
"type": "string",
|
|
"description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.",
|
|
"enum": ["dependencies", "peerDependencies"],
|
|
"default": "peerDependencies",
|
|
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
|
|
},
|
|
"rollupConfig": {
|
|
"oneOf": [
|
|
{
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string",
|
|
"x-completion-type": "file",
|
|
"x-completion-glob": "rollup?(*)@(.js|.ts)"
|
|
}
|
|
},
|
|
{
|
|
"type": "string",
|
|
"x-completion-type": "file",
|
|
"x-completion-glob": "rollup?(*)@(.js|.ts)"
|
|
}
|
|
],
|
|
"description": "Path to a function which takes a rollup config and returns an updated rollup config."
|
|
},
|
|
"extractCss": {
|
|
"type": ["boolean", "string"],
|
|
"description": "CSS files will be extracted to the output folder. Alternatively custom filename can be provided (e.g. styles.css)",
|
|
"default": true
|
|
},
|
|
"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."
|
|
},
|
|
"output": {
|
|
"type": "string",
|
|
"description": "Relative path within the output folder."
|
|
}
|
|
},
|
|
"additionalProperties": false,
|
|
"required": ["glob", "input", "output"]
|
|
},
|
|
{ "type": "string" }
|
|
]
|
|
}
|
|
},
|
|
"compiler": {
|
|
"type": "string",
|
|
"enum": ["babel", "swc", "tsc"],
|
|
"default": "babel",
|
|
"description": "Which compiler to use."
|
|
},
|
|
"babelUpwardRootMode": {
|
|
"type": "boolean",
|
|
"description": "Whether to set rootmode to upward. See https://babeljs.io/docs/en/options#rootmode",
|
|
"default": false
|
|
},
|
|
"javascriptEnabled": {
|
|
"type": "boolean",
|
|
"description": "Sets `javascriptEnabled` option for less loader",
|
|
"default": false
|
|
},
|
|
"generateExportsField": {
|
|
"type": "boolean",
|
|
"alias": "exports",
|
|
"description": "Update the output package.json file's 'exports' field. This field is used by Node and bundles.",
|
|
"default": false,
|
|
"x-priority": "important"
|
|
},
|
|
"additionalEntryPoints": {
|
|
"type": "array",
|
|
"description": "Additional entry-points to add to exports field in the package.json file.",
|
|
"items": { "type": "string" },
|
|
"x-priority": "important"
|
|
},
|
|
"skipTypeCheck": {
|
|
"type": "boolean",
|
|
"description": "Whether to skip TypeScript type checking.",
|
|
"default": false
|
|
},
|
|
"skipTypeField": {
|
|
"type": "boolean",
|
|
"description": "Prevents 'type' field from being added to compiled package.json file. Use this if you are having an issue with this field.",
|
|
"default": false
|
|
}
|
|
},
|
|
"required": ["tsConfig", "main", "outputPath"],
|
|
"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."
|
|
},
|
|
"output": {
|
|
"type": "string",
|
|
"description": "Relative path within the output folder."
|
|
}
|
|
},
|
|
"additionalProperties": false,
|
|
"required": ["glob", "input", "output"]
|
|
},
|
|
{ "type": "string" }
|
|
]
|
|
}
|
|
},
|
|
"examplesFile": "{% tabs %}\n{% tab label=\"Including Dependencies\" %}\nTo include dependencies in the output `package.json`, the dependencies must be installed as a **dependencies** in the root `package.json`\n\n```json {% fileName=\"package.json\" %}\n{\n \"dependencies\": {\n \"some-dependency\": \"^1.0.0\"\n }\n}\n```\n\nTo have dependencies in the be listed in the final `package.json` of your project, set the `updateBuildableProjectDepsInPackageJson` option to `true`. After than dependencies will be added to the `peerDependencies` field of the output `package.json`. You can use `buildableProjectDepsInPackageJsonType` option to change which field the dependencies are output to.\n\n```json {% fileName=\"project.json\" %}\n{\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/rollup:rollup\",\n \"options\": {\n \"buildableProjectDepsInPackageJsonType\": \"dependencies\",\n \"updateBuildableProjectDepsInPackageJson\": true\n }\n }\n }\n}\n```\n\n{% /tab %}\n\n{% tab label=\"Using `babelUpwardRootMode`\" %}\n\nCopying from the [Babel documentation](https://babeljs.io/docs/config-files#root-babelconfigjson-file):\n\n> [...] if you are running your Babel compilation process from within a subpackage, you need to tell Babel where to look for the config. There are a few ways to do that, but the recommended way is the \"rootMode\" option with \"upward\", which will make Babel search from the working directory upward looking for your babel.config.json file, and will use its location as the \"root\" value.\n\nSetting `babelUpwardRootMode` to `true` in your `project.json` will set `rootMode` option to `upward` in the Babel config. You may want the `upward` mode in a monorepo when projects must apply their individual `.babelrc` file. We recommend that you don't set it at all, so it will use the default to `false` as the `upward` mode brings additional complexity to the build process.\n\n```json\n//...\n\"my-app\": {\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/rollup:rollup\",\n \"options\": {\n \"babelUpwardRootMode\": true,\n //...\n },\n //...\n },\n //...\n },\n //...\n}\n```\n\nWhen `babelUpwardRootMode` is `true`, Babel will look for a root `babel.config.json` at the root of the workspace, which should look something like this to include all packages:\n\n```json\n{ \"babelrcRoots\": [\"*\"] }\n```\n\nThen for each package, you must have a `.babelrc` file that will be applied to that package. For example:\n\n```json\n{\n \"presets\": [\"@babel/preset-env\", \"@babel/preset-typescript\"]\n}\n```\n\nAll packages will use its own `.babelrc` file, thus you must ensure the right presets and plugins are set in each config file. This behavior can lead to build discrepancies between packages, so we recommend that you don't set `babelUpwardRootMode` at all.\n\n```treeview\n├── packages\n│ ├── a\n│ │ └── .babelrc\n│ └── b\n│ └── .babelrc\n└── babel.config.json\n```\n\nIn workspace above, if `a` imports `b`, it will apply the config `packages/b/.babelrc` and not apply its own `packages/a/.babelrc` to `b`. Anything in `babel.config.json` will apply to all packages.\n\n{% /tab %}\n\n{% /tabs %}\n",
|
|
"presets": []
|
|
},
|
|
"description": "Bundle a package using Rollup.",
|
|
"aliases": [],
|
|
"hidden": false,
|
|
"path": "/packages/rollup/src/executors/rollup/schema.json",
|
|
"type": "executor"
|
|
}
|