UNPKG

@tanstack/router-plugin

Version:

Modern and scalable routing for React applications

1 lines 2.51 kB
{"version":3,"file":"router-composed-plugin.cjs","sources":["../../../src/core/router-composed-plugin.ts"],"sourcesContent":["import { getConfig } from '@tanstack/router-generator'\nimport { unpluginRouterGeneratorFactory } from './router-generator-plugin'\nimport { unpluginRouterCodeSplitterFactory } from './router-code-splitter-plugin'\nimport { unpluginRouterHmrFactory } from './router-hmr-plugin'\nimport { unpluginRouteAutoImportFactory } from './route-autoimport-plugin'\nimport type { Config } from './config'\nimport type { UnpluginFactory } from 'unplugin'\n\nexport const unpluginRouterComposedFactory: UnpluginFactory<\n Partial<Config> | undefined\n> = (options = {}, meta) => {\n const ROOT: string = process.cwd()\n const userConfig = getConfig(options, ROOT)\n\n const getPlugin = (pluginFactory: UnpluginFactory<Partial<Config>>) => {\n const plugin = pluginFactory(options, meta)\n if (!Array.isArray(plugin)) {\n return [plugin]\n }\n return plugin\n }\n\n const routerGenerator = getPlugin(unpluginRouterGeneratorFactory)\n const routerCodeSplitter = getPlugin(unpluginRouterCodeSplitterFactory)\n const routeAutoImport = getPlugin(unpluginRouteAutoImportFactory)\n\n const result = [...routerGenerator]\n if (userConfig.autoCodeSplitting) {\n result.push(...routerCodeSplitter)\n }\n if (userConfig.verboseFileRoutes === false) {\n result.push(...routeAutoImport)\n }\n\n const isProduction = process.env.NODE_ENV === 'production'\n\n if (!isProduction && !userConfig.autoCodeSplitting) {\n const routerHmr = getPlugin(unpluginRouterHmrFactory)\n result.push(...routerHmr)\n }\n return result\n}\n"],"names":["getConfig","routerGenerator","unpluginRouterGeneratorFactory","unpluginRouterCodeSplitterFactory","unpluginRouteAutoImportFactory","unpluginRouterHmrFactory"],"mappings":";;;;;;;AAQO,MAAM,gCAET,CAAC,UAAU,IAAI,SAAS;AACpB,QAAA,OAAe,QAAQ,IAAI;AAC3B,QAAA,aAAaA,gBAAAA,UAAU,SAAS,IAAI;AAEpC,QAAA,YAAY,CAAC,kBAAoD;AAC/D,UAAA,SAAS,cAAc,SAAS,IAAI;AAC1C,QAAI,CAAC,MAAM,QAAQ,MAAM,GAAG;AAC1B,aAAO,CAAC,MAAM;AAAA,IAAA;AAET,WAAA;AAAA,EACT;AAEM,QAAAC,oBAAkB,UAAUC,oDAA8B;AAC1D,QAAA,qBAAqB,UAAUC,0DAAiC;AAChE,QAAA,kBAAkB,UAAUC,oDAA8B;AAE1D,QAAA,SAAS,CAAC,GAAGH,iBAAe;AAClC,MAAI,WAAW,mBAAmB;AACzB,WAAA,KAAK,GAAG,kBAAkB;AAAA,EAAA;AAE/B,MAAA,WAAW,sBAAsB,OAAO;AACnC,WAAA,KAAK,GAAG,eAAe;AAAA,EAAA;AAG1B,QAAA,eAAe,QAAQ,IAAI,aAAa;AAE9C,MAAI,CAAC,gBAAgB,CAAC,WAAW,mBAAmB;AAC5C,UAAA,YAAY,UAAUI,wCAAwB;AAC7C,WAAA,KAAK,GAAG,SAAS;AAAA,EAAA;AAEnB,SAAA;AACT;;"}