source
Options for input source code.
source.assetsInclude
source.include
Include additional files that should be treated as static assets.
source.decorators
source.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.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.entry
-
CLI:
--entry <path>(repeatable, e.g.,--entry index=src/index.tsor--entry src/index.ts)The CLI argument supports two formats:
key=value: Explicitly specify the entry name, e.g.,--entry main=src/main.ts.value: Only specify the path, in which case the basename of the file (without extension) will be automatically used as the entry name. For example,--entry src/index.tswill generate an entry namedindex. If there are name conflicts, numeric suffixes (starting from 0) will be added to all conflicting entries, e.g.,index0,index1.
Used to set the entry modules for building.
In Rslib, the default value is:
- bundle mode:
- bundleless mode:
Check out the lib.bundle to learn more about how to set entry for bundle and bundleless project.
source.exclude
source.exclude
Exclude JavaScript or TypeScript files that do not need to be transformed by SWC.
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.entryto configure the corresponding glob expression, refer to Set entry.
source.include
source.include
Specify additional JavaScript files that need to be compiled.
source.transformImport
source.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.tsconfigPath
- CLI:
--tsconfig <path>(e.g.--tsconfig tsconfig.build.json)
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:
- The
pathsfield is used to configure Path alias. - The
experimentalDecoratorsfield is used to configure Decorators version. - Used to configure the effective scope, rules, and output directory during TypeScript declaration file generation.
