source

Options for input source code.

source.assetsInclude source.includesource.include

Include additional files that should be treated as static assets.

source.decorators source.decoratorssource.decorators

Used to configure the decorators syntax.

If experimentalDecorators is enabled in tsconfig.json, Rslib will set source.decorators.version to legacy by default.

source.define source.definesource.define

Replaces variables in your code with other values or expressions at compile time. This can be useful for injecting env variables and other information to the code during build time.

source.entry source.entrysource.entry

Used to set the entry modules for building.

In Rslib, the default value is:

  • bundle mode:
const defaultEntry = {
  // default support for other suffixes such as ts, tsx, jsx, mjs, cjs
  index: 'src/index.js',
};
  • bundleless mode:
const defaultEntry = {
  index: 'src/**',
};
INFO

Check out the lib.bundle to learn more about how to set entry for bundle and bundleless project.

source.exclude source.excludesource.exclude

Exclude JavaScript or TypeScript files that do not need to be transformed by SWC.

NOTE

Files configured in source.exclude will not be transformed by SWC, but the referenced files will still be bundled into the outputs.

If you want certain files not to be bundled into the outputs, you can use the following methods:

  • bundle mode: Use Rspack's IgnorePlugin.
  • bundleless mode: Use source.entry to configure the corresponding glob expression, refer to Set entry.

source.include source.includesource.include

Specify additional JavaScript files that need to be compiled.

source.transformImport source.transformImportsource.transformImport

Transform the import path, which can be used to modularly import the subpath of third-party packages. The functionality is similar to babel-plugin-import.

source.tsconfigPath source.tsconfigPathsource.tsconfigPath

Configure a custom tsconfig.json file path to use, can be a relative or absolute path.

The tsconfig.json configuration file affects the following behavior of Rslib: