@nx/rollup:rollup

Packages a library for different web usages (ESM, CommonJS).

Options can be configured in project.json when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/reference/project-configuration#targets.

To include dependencies in the output package.json, the dependencies must be installed as a dependencies in the root package.json

package.json
1{ 2 "dependencies": { 3 "some-dependency": "^1.0.0" 4 } 5} 6

Options

main

entryFileRequired
string

The path to the entry file, relative to project.

outputPath

Required
string

The output path of the generated files.

tsConfig

Required
string

The path to tsconfig file.

additionalEntryPoints

Array<string>

Additional entry-points to add to exports field in the package.json file.

generateExportsField

exports
boolean
Default: false

Update the output package.json file's 'exports' field. This field is used by Node and bundles.

project

string

The path to package.json file.

allowJs

boolean
Default: false

Allow JavaScript files to be compiled.

assets

Array<oneOf [object , string]>
Default: []

List of static assets.

babelUpwardRootMode

boolean
Default: false

Whether to set rootmode to upward. See https://babeljs.io/docs/en/options#rootmode

compiler

string
Default: babel
Accepted values: babel, swc, tsc

Which compiler to use.

deleteOutputPath

boolean
Default: true

Delete the output path before building.

external

oneOf [string, Array<string>]

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).

extractCss

boolean ∪ string
Default: true

CSS files will be extracted to the output folder. Alternatively custom filename can be provided (e.g. styles.css)

format

f
Array<string>
Accepted values: esm, cjs

List of module formats to output. Defaults to matching format from tsconfig (e.g. CJS for CommonJS, and ESM otherwise).

javascriptEnabled

boolean
Default: false

Sets javascriptEnabled option for less loader

outputFileName

string

Name of the main output file. Defaults same basename as 'main' file.

rollupConfig

oneOf [Array<string>, string]

Path to a function which takes a rollup config and returns an updated rollup config.

skipTypeCheck

boolean
Default: false

Whether to skip TypeScript type checking.

skipTypeField

boolean
Default: false

Prevents 'type' field from being added to compiled package.json file. Use this if you are having an issue with this field.

sourceMap

boolean

Output sourcemaps.

watch

boolean
Default: false

Enable re-building when files change.