source.include

const defaultInclude = [
  [
    { not: /[\\/]node_modules[\\/]/ },
    /\.(?:ts|tsx|jsx|mts|cts)$/,
  ],
];

source.include is used to specify additional JavaScript files that need to be compiled. By default, the following files will be compiled:

  • TypeScript and JSX files in any directory, with file extensions matching .ts, .tsx, .jsx, .mts, .cts.
  • JavaScript files not in the node_modules directory, with file extensions matching .js, .mjs, .cjs.
TIP

Before Rsbuild version 1.4, the default value of source.include was:

const defaultInclude = [
  [
    {
      and: [
        APP_ROOT,
        { not: /[\\/]node_modules[\\/]/ }
      ]
    },
    /\.(?:ts|tsx|jsx|mts|cts)$/,
  ],
];

The difference from the new version is that .js, .mjs, .cjs files only in the current directory will be compiled.

Rspack

INFO

该配置项的使用方式与 Rsbuild 完全一致。详细信息请参考 Rsbuild - source.include

Webpack

To ensure legacy projects can run properly, when using Webpack, the default value of source.include is the same as before Rsbuild version 1.4.