Type Alias: CodeSplittingGroup
type CodeSplittingGroup = objectDefined in: node_modules/.pnpm/rolldown@1.0.0-beta.60/node_modules/rolldown/dist/shared/define-config-BgCyRzGF.d.mts:822
Properties
maxModuleSize?
optional maxModuleSize: number;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.60/node_modules/rolldown/dist/shared/define-config-BgCyRzGF.d.mts:941
Controls whether a module can only be captured if its size in bytes is smaller than or equal to this value.
Default
InfinitymaxSize?
optional maxSize: number;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.60/node_modules/rolldown/dist/shared/define-config-BgCyRzGF.d.mts:935
If the accumulated size in bytes of the captured modules by this group is larger than this value, this group will be split into multiple groups that each has size close to this value.
Default
InfinityminModuleSize?
optional minModuleSize: number;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.60/node_modules/rolldown/dist/shared/define-config-BgCyRzGF.d.mts:947
Controls whether a module can only be captured if its size in bytes is larger than or equal to this value.
Default
0minShareCount?
optional minShareCount: number;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.60/node_modules/rolldown/dist/shared/define-config-BgCyRzGF.d.mts:929
Controls if a module should be captured based on how many entry chunks reference it.
Default
1minSize?
optional minSize: number;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.60/node_modules/rolldown/dist/shared/define-config-BgCyRzGF.d.mts:923
Minimum size in bytes of the desired chunk. If the accumulated size of the captured modules by this group is smaller than this value, it will be ignored. Modules in this group will fall back to the automatic chunking if they are not captured by any other group.
Default
0name
name: string | (moduleId, ctx) => string | NullValue<void>;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.60/node_modules/rolldown/dist/shared/define-config-BgCyRzGF.d.mts:873
Name of the group. It will be also used as the name of the chunk and replace the [name] placeholder in the output.chunkFileNames option.
For example,
import { defineConfig } from 'rolldown'
export default defineConfig({
advancedChunks: {
groups: [
{
name: 'libs',
test: /node_modules/,
},
],
},
})will create a chunk named libs-[hash].js in the end.
It's ok to have the same name for different groups. Rolldown will deduplicate the chunk names if necessary.
Dynamic name()
If name is a function, it will be called with the module id as the argument. The function should return a string or null. If it returns null, the module will be ignored by this group.
Notice, each returned new name will be treated as a separate group.
For example,
import { defineConfig } from 'rolldown'
export default defineConfig({
advancedChunks: {
groups: [
{
name: (moduleId) =>
moduleId.includes('node_modules') ? 'libs' : 'app',
minSize: 100 * 1024,
},
],
},
})WARNING
Constraints like minSize, maxSize, etc. are applied separately for different names returned by the function.
priority?
optional priority: number;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.60/node_modules/rolldown/dist/shared/define-config-BgCyRzGF.d.mts:917
Priority of the group. Group with higher priority will be chosen first to match modules and create chunks. When converting the group to a chunk, modules of that group will be removed from other groups.
If two groups have the same priority, the group whose index is smaller will be chosen.
Example
import { defineConfig } from 'rolldown';
export default defineConfig({
advancedChunks: {
groups: [
{
name: 'react',
test: /node_modules[\\/]react/,
priority: 2,
},
{
name: 'other-libs',
test: /node_modules/,
priority: 1,
},
],
});Default
0test?
optional test: StringOrRegExp | (id) => boolean | void | undefined;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.60/node_modules/rolldown/dist/shared/define-config-BgCyRzGF.d.mts:888
Controls which modules are captured in this group.
- If
testis a string, the module whose id contains the string will be captured. - If
testis a regular expression, the module whose id matches the regular expression will be captured. - If
testis a function, modules for whichtest(id)returnstruewill be captured. - If
testis empty, any module will be considered as matched.
WARNING
When using regular expression, it's recommended to use [\\/] to match the path separator instead of / to avoid potential issues on Windows.
- ✅ Recommended:
/node_modules[\\/]react/ - ❌ Not recommended:
/node_modules/react/