Skip to content

Commit aa1fb5d

Browse files
authored
fix(router-plugin): composed plugin to consider options from json config (#4654)
1 parent 51307bb commit aa1fb5d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/router-plugin/src/core/router-composed-plugin.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getConfig } from '@tanstack/router-generator'
12
import { unpluginRouterGeneratorFactory } from './router-generator-plugin'
23
import { unpluginRouterCodeSplitterFactory } from './router-code-splitter-plugin'
34
import { unpluginRouterHmrFactory } from './router-hmr-plugin'
@@ -8,6 +9,9 @@ import type { UnpluginFactory } from 'unplugin'
89
export const unpluginRouterComposedFactory: UnpluginFactory<
910
Partial<Config> | undefined
1011
> = (options = {}, meta) => {
12+
const ROOT: string = process.cwd()
13+
const userConfig = getConfig(options, ROOT)
14+
1115
const getPlugin = (pluginFactory: UnpluginFactory<Partial<Config>>) => {
1216
const plugin = pluginFactory(options, meta)
1317
if (!Array.isArray(plugin)) {
@@ -21,16 +25,16 @@ export const unpluginRouterComposedFactory: UnpluginFactory<
2125
const routeAutoImport = getPlugin(unpluginRouteAutoImportFactory)
2226

2327
const result = [...routerGenerator]
24-
if (options.autoCodeSplitting) {
28+
if (userConfig.autoCodeSplitting) {
2529
result.push(...routerCodeSplitter)
2630
}
27-
if (options.verboseFileRoutes === false) {
31+
if (userConfig.verboseFileRoutes === false) {
2832
result.push(...routeAutoImport)
2933
}
3034

3135
const isProduction = process.env.NODE_ENV === 'production'
3236

33-
if (!isProduction && !options.autoCodeSplitting) {
37+
if (!isProduction && !userConfig.autoCodeSplitting) {
3438
const routerHmr = getPlugin(unpluginRouterHmrFactory)
3539
result.push(...routerHmr)
3640
}

0 commit comments

Comments
 (0)