@octanejs/tanstack-start 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +52 -0
- package/THIRD_PARTY_NOTICES.md +11 -0
- package/package.json +149 -0
- package/src/client-only.d.ts +1 -0
- package/src/client-only.js +0 -0
- package/src/client-rpc.d.ts +1 -0
- package/src/client-rpc.js +1 -0
- package/src/client.d.ts +3 -0
- package/src/client.js +2 -0
- package/src/default-entry/client.js +12 -0
- package/src/default-entry/server.js +13 -0
- package/src/default-entry/start.js +1 -0
- package/src/default-entry-paths.d.ts +5 -0
- package/src/default-entry-paths.js +11 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +22 -0
- package/src/internal/README.md +15 -0
- package/src/internal/router-generator/config.d.ts +255 -0
- package/src/internal/router-generator/config.js +134 -0
- package/src/internal/router-generator/filesystem/physical/getRouteNodes.d.ts +53 -0
- package/src/internal/router-generator/filesystem/physical/getRouteNodes.js +335 -0
- package/src/internal/router-generator/filesystem/physical/rootPathId.d.ts +1 -0
- package/src/internal/router-generator/filesystem/physical/rootPathId.js +4 -0
- package/src/internal/router-generator/filesystem/virtual/config.d.ts +3 -0
- package/src/internal/router-generator/filesystem/virtual/config.js +36 -0
- package/src/internal/router-generator/filesystem/virtual/getRouteNodes.d.ts +31 -0
- package/src/internal/router-generator/filesystem/virtual/getRouteNodes.js +272 -0
- package/src/internal/router-generator/filesystem/virtual/loadConfigFile.d.ts +1 -0
- package/src/internal/router-generator/filesystem/virtual/loadConfigFile.js +10 -0
- package/src/internal/router-generator/generator.d.ts +119 -0
- package/src/internal/router-generator/generator.js +1080 -0
- package/src/internal/router-generator/index.d.ts +40 -0
- package/src/internal/router-generator/index.js +49 -0
- package/src/internal/router-generator/logger.d.ts +8 -0
- package/src/internal/router-generator/logger.js +30 -0
- package/src/internal/router-generator/plugin/types.d.ts +37 -0
- package/src/internal/router-generator/template.d.ts +38 -0
- package/src/internal/router-generator/template.js +220 -0
- package/src/internal/router-generator/transform/transform.d.ts +8 -0
- package/src/internal/router-generator/transform/transform.js +385 -0
- package/src/internal/router-generator/transform/types.d.ts +34 -0
- package/src/internal/router-generator/types.d.ts +73 -0
- package/src/internal/router-generator/utils.d.ts +270 -0
- package/src/internal/router-generator/utils.js +864 -0
- package/src/internal/router-generator/validate-route-params.d.ts +13 -0
- package/src/internal/router-generator/validate-route-params.js +75 -0
- package/src/internal/router-plugin/context.d.ts +2 -0
- package/src/internal/router-plugin/context.js +2 -0
- package/src/internal/router-plugin/core/code-splitter/compilers.d.ts +69 -0
- package/src/internal/router-plugin/core/code-splitter/compilers.js +1042 -0
- package/src/internal/router-plugin/core/code-splitter/framework-options.d.ts +11 -0
- package/src/internal/router-plugin/core/code-splitter/framework-options.js +41 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/framework-plugins.d.ts +12 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/framework-plugins.js +35 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/octane-hmr-split-route-components.d.ts +5 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/octane-hmr-split-route-components.js +106 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/octane-split-route-components.d.ts +8 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/octane-split-route-components.js +85 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-ignored-route-exports.d.ts +2 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-ignored-route-exports.js +55 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-route-components.d.ts +2 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-route-components.js +50 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/react-stable-hmr-split-route-components.d.ts +5 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/react-stable-hmr-split-route-components.js +54 -0
- package/src/internal/router-plugin/core/code-splitter/plugins.d.ts +62 -0
- package/src/internal/router-plugin/core/code-splitter/types.d.ts +9 -0
- package/src/internal/router-plugin/core/config.d.ts +294 -0
- package/src/internal/router-plugin/core/config.js +56 -0
- package/src/internal/router-plugin/core/constants.d.ts +12 -0
- package/src/internal/router-plugin/core/constants.js +13 -0
- package/src/internal/router-plugin/core/framework-plugin-order.d.ts +8 -0
- package/src/internal/router-plugin/core/framework-plugin-order.js +78 -0
- package/src/internal/router-plugin/core/hmr/handle-route-update.d.ts +1 -0
- package/src/internal/router-plugin/core/hmr/handle-route-update.js +126 -0
- package/src/internal/router-plugin/core/hmr/index.d.ts +5 -0
- package/src/internal/router-plugin/core/hmr/select-adapter.d.ts +17 -0
- package/src/internal/router-plugin/core/hmr/select-adapter.js +24 -0
- package/src/internal/router-plugin/core/hmr/vite-adapter.d.ts +18 -0
- package/src/internal/router-plugin/core/hmr/vite-adapter.js +73 -0
- package/src/internal/router-plugin/core/hmr/webpack-adapter.d.ts +22 -0
- package/src/internal/router-plugin/core/hmr/webpack-adapter.js +78 -0
- package/src/internal/router-plugin/core/router-code-splitter-plugin.d.ts +10 -0
- package/src/internal/router-plugin/core/router-code-splitter-plugin.js +244 -0
- package/src/internal/router-plugin/core/router-composed-plugin.d.ts +5 -0
- package/src/internal/router-plugin/core/router-composed-plugin.js +62 -0
- package/src/internal/router-plugin/core/router-generator-plugin.d.ts +10 -0
- package/src/internal/router-plugin/core/router-generator-plugin.js +125 -0
- package/src/internal/router-plugin/core/router-hmr-plugin.d.ts +13 -0
- package/src/internal/router-plugin/core/router-hmr-plugin.js +101 -0
- package/src/internal/router-plugin/core/router-plugin-context.d.ts +5 -0
- package/src/internal/router-plugin/core/router-plugin-context.js +6 -0
- package/src/internal/router-plugin/core/utils.d.ts +17 -0
- package/src/internal/router-plugin/core/utils.js +47 -0
- package/src/internal/router-plugin/esbuild.d.ts +197 -0
- package/src/internal/router-plugin/esbuild.js +58 -0
- package/src/internal/router-plugin/index.d.ts +19 -0
- package/src/internal/router-plugin/index.js +17 -0
- package/src/internal/router-plugin/rspack.d.ts +61 -0
- package/src/internal/router-plugin/rspack.js +92 -0
- package/src/internal/router-plugin/vite.d.ts +201 -0
- package/src/internal/router-plugin/vite.js +62 -0
- package/src/internal/router-plugin/webpack.d.ts +50 -0
- package/src/internal/router-plugin/webpack.js +77 -0
- package/src/internal/start-plugin-core/build-sitemap.d.ts +34 -0
- package/src/internal/start-plugin-core/build-sitemap.js +125 -0
- package/src/internal/start-plugin-core/config-context.d.ts +30 -0
- package/src/internal/start-plugin-core/config-context.js +89 -0
- package/src/internal/start-plugin-core/constants.d.ts +20 -0
- package/src/internal/start-plugin-core/constants.js +24 -0
- package/src/internal/start-plugin-core/debug.d.ts +1 -0
- package/src/internal/start-plugin-core/hydrate-when-transform.d.ts +5 -0
- package/src/internal/start-plugin-core/hydrate-when-transform.js +661 -0
- package/src/internal/start-plugin-core/hydration-constants.d.ts +1 -0
- package/src/internal/start-plugin-core/hydration-constants.js +4 -0
- package/src/internal/start-plugin-core/import-protection/adapterUtils.d.ts +40 -0
- package/src/internal/start-plugin-core/import-protection/adapterUtils.js +42 -0
- package/src/internal/start-plugin-core/import-protection/analysis.d.ts +63 -0
- package/src/internal/start-plugin-core/import-protection/analysis.js +533 -0
- package/src/internal/start-plugin-core/import-protection/constants.d.ts +11 -0
- package/src/internal/start-plugin-core/import-protection/constants.js +39 -0
- package/src/internal/start-plugin-core/import-protection/defaults.d.ts +19 -0
- package/src/internal/start-plugin-core/import-protection/defaults.js +34 -0
- package/src/internal/start-plugin-core/import-protection/extensionlessAbsoluteIdResolver.d.ts +22 -0
- package/src/internal/start-plugin-core/import-protection/extensionlessAbsoluteIdResolver.js +94 -0
- package/src/internal/start-plugin-core/import-protection/matchers.d.ts +18 -0
- package/src/internal/start-plugin-core/import-protection/matchers.js +39 -0
- package/src/internal/start-plugin-core/import-protection/rewrite.d.ts +29 -0
- package/src/internal/start-plugin-core/import-protection/rewrite.js +184 -0
- package/src/internal/start-plugin-core/import-protection/sourceLocation.d.ts +170 -0
- package/src/internal/start-plugin-core/import-protection/sourceLocation.js +376 -0
- package/src/internal/start-plugin-core/import-protection/trace.d.ts +89 -0
- package/src/internal/start-plugin-core/import-protection/trace.js +186 -0
- package/src/internal/start-plugin-core/import-protection/utils.d.ts +78 -0
- package/src/internal/start-plugin-core/import-protection/utils.js +171 -0
- package/src/internal/start-plugin-core/import-protection/virtualModules.d.ts +38 -0
- package/src/internal/start-plugin-core/import-protection/virtualModules.js +241 -0
- package/src/internal/start-plugin-core/index.d.ts +8 -0
- package/src/internal/start-plugin-core/index.js +2 -0
- package/src/internal/start-plugin-core/planning.d.ts +44 -0
- package/src/internal/start-plugin-core/planning.js +98 -0
- package/src/internal/start-plugin-core/post-build.d.ts +12 -0
- package/src/internal/start-plugin-core/post-build.js +40 -0
- package/src/internal/start-plugin-core/prerender.d.ts +17 -0
- package/src/internal/start-plugin-core/prerender.js +172 -0
- package/src/internal/start-plugin-core/queue.d.ts +37 -0
- package/src/internal/start-plugin-core/queue.js +118 -0
- package/src/internal/start-plugin-core/resolve-entries.d.ts +10 -0
- package/src/internal/start-plugin-core/resolve-entries.js +32 -0
- package/src/internal/start-plugin-core/schema.d.ts +1799 -0
- package/src/internal/start-plugin-core/schema.js +252 -0
- package/src/internal/start-plugin-core/serialization-adapters-module.d.ts +18 -0
- package/src/internal/start-plugin-core/serialization-adapters-module.js +37 -0
- package/src/internal/start-plugin-core/start-compiler/compiler.d.ts +181 -0
- package/src/internal/start-plugin-core/start-compiler/compiler.js +1078 -0
- package/src/internal/start-plugin-core/start-compiler/config.d.ts +20 -0
- package/src/internal/start-plugin-core/start-compiler/config.js +84 -0
- package/src/internal/start-plugin-core/start-compiler/handleClientOnlyJSX.d.ts +24 -0
- package/src/internal/start-plugin-core/start-compiler/handleClientOnlyJSX.js +25 -0
- package/src/internal/start-plugin-core/start-compiler/handleCreateIsomorphicFn.d.ts +11 -0
- package/src/internal/start-plugin-core/start-compiler/handleCreateIsomorphicFn.js +24 -0
- package/src/internal/start-plugin-core/start-compiler/handleCreateMiddleware.d.ts +11 -0
- package/src/internal/start-plugin-core/start-compiler/handleCreateMiddleware.js +35 -0
- package/src/internal/start-plugin-core/start-compiler/handleCreateServerFn.d.ts +22 -0
- package/src/internal/start-plugin-core/start-compiler/handleCreateServerFn.js +292 -0
- package/src/internal/start-plugin-core/start-compiler/handleEnvOnly.d.ts +14 -0
- package/src/internal/start-plugin-core/start-compiler/handleEnvOnly.js +41 -0
- package/src/internal/start-plugin-core/start-compiler/host.d.ts +44 -0
- package/src/internal/start-plugin-core/start-compiler/host.js +75 -0
- package/src/internal/start-plugin-core/start-compiler/server-fn-resolver-module.d.ts +10 -0
- package/src/internal/start-plugin-core/start-compiler/server-fn-resolver-module.js +87 -0
- package/src/internal/start-plugin-core/start-compiler/types.d.ts +119 -0
- package/src/internal/start-plugin-core/start-compiler/utils.d.ts +27 -0
- package/src/internal/start-plugin-core/start-compiler/utils.js +36 -0
- package/src/internal/start-plugin-core/start-manifest-plugin/inlineCss.d.ts +16 -0
- package/src/internal/start-plugin-core/start-manifest-plugin/inlineCss.js +131 -0
- package/src/internal/start-plugin-core/start-manifest-plugin/manifestBuilder.d.ts +64 -0
- package/src/internal/start-plugin-core/start-manifest-plugin/manifestBuilder.js +441 -0
- package/src/internal/start-plugin-core/start-router-plugin/constants.d.ts +1 -0
- package/src/internal/start-plugin-core/start-router-plugin/constants.js +4 -0
- package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/compose-generator-plugins.d.ts +6 -0
- package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/compose-generator-plugins.js +6 -0
- package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/prerender-routes-plugin.d.ts +6 -0
- package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/prerender-routes-plugin.js +27 -0
- package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/routes-manifest-plugin.d.ts +6 -0
- package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/routes-manifest-plugin.js +34 -0
- package/src/internal/start-plugin-core/start-router-plugin/pruneServerOnlySubtrees.d.ts +11 -0
- package/src/internal/start-plugin-core/start-router-plugin/pruneServerOnlySubtrees.js +42 -0
- package/src/internal/start-plugin-core/start-router-plugin/route-tree-footer.d.ts +6 -0
- package/src/internal/start-plugin-core/start-router-plugin/route-tree-footer.js +59 -0
- package/src/internal/start-plugin-core/types.d.ts +135 -0
- package/src/internal/start-plugin-core/types.js +4 -0
- package/src/internal/start-plugin-core/utils.d.ts +13 -0
- package/src/internal/start-plugin-core/utils.js +42 -0
- package/src/internal/start-plugin-core/vite/createVirtualModule.d.ts +15 -0
- package/src/internal/start-plugin-core/vite/createVirtualModule.js +27 -0
- package/src/internal/start-plugin-core/vite/dev-server-plugin/dev-styles.d.ts +26 -0
- package/src/internal/start-plugin-core/vite/dev-server-plugin/dev-styles.js +165 -0
- package/src/internal/start-plugin-core/vite/dev-server-plugin/plugin.d.ts +11 -0
- package/src/internal/start-plugin-core/vite/dev-server-plugin/plugin.js +170 -0
- package/src/internal/start-plugin-core/vite/import-protection-plugin/plugin.d.ts +4 -0
- package/src/internal/start-plugin-core/vite/import-protection-plugin/plugin.js +1553 -0
- package/src/internal/start-plugin-core/vite/import-protection-plugin/types.d.ts +103 -0
- package/src/internal/start-plugin-core/vite/import-protection-plugin/virtualModules.d.ts +40 -0
- package/src/internal/start-plugin-core/vite/import-protection-plugin/virtualModules.js +68 -0
- package/src/internal/start-plugin-core/vite/index.d.ts +13 -0
- package/src/internal/start-plugin-core/vite/index.js +4 -0
- package/src/internal/start-plugin-core/vite/load-env-plugin/plugin.d.ts +2 -0
- package/src/internal/start-plugin-core/vite/load-env-plugin/plugin.js +13 -0
- package/src/internal/start-plugin-core/vite/output-directory.d.ts +7 -0
- package/src/internal/start-plugin-core/vite/output-directory.js +18 -0
- package/src/internal/start-plugin-core/vite/planning.d.ts +112 -0
- package/src/internal/start-plugin-core/vite/planning.js +152 -0
- package/src/internal/start-plugin-core/vite/plugin.d.ts +7 -0
- package/src/internal/start-plugin-core/vite/plugin.js +208 -0
- package/src/internal/start-plugin-core/vite/plugins.d.ts +17 -0
- package/src/internal/start-plugin-core/vite/plugins.js +72 -0
- package/src/internal/start-plugin-core/vite/post-server-build.d.ts +9 -0
- package/src/internal/start-plugin-core/vite/post-server-build.js +22 -0
- package/src/internal/start-plugin-core/vite/prerender.d.ts +9 -0
- package/src/internal/start-plugin-core/vite/prerender.js +52 -0
- package/src/internal/start-plugin-core/vite/preview-server-plugin/plugin.d.ts +2 -0
- package/src/internal/start-plugin-core/vite/preview-server-plugin/plugin.js +54 -0
- package/src/internal/start-plugin-core/vite/schema.d.ts +2423 -0
- package/src/internal/start-plugin-core/vite/schema.js +17 -0
- package/src/internal/start-plugin-core/vite/serialization-adapters-plugin.d.ts +5 -0
- package/src/internal/start-plugin-core/vite/serialization-adapters-plugin.js +63 -0
- package/src/internal/start-plugin-core/vite/start-compiler-plugin/hot-update.d.ts +5 -0
- package/src/internal/start-plugin-core/vite/start-compiler-plugin/hot-update.js +14 -0
- package/src/internal/start-plugin-core/vite/start-compiler-plugin/module-specifier.d.ts +5 -0
- package/src/internal/start-plugin-core/vite/start-compiler-plugin/module-specifier.js +25 -0
- package/src/internal/start-plugin-core/vite/start-compiler-plugin/plugin.d.ts +29 -0
- package/src/internal/start-plugin-core/vite/start-compiler-plugin/plugin.js +380 -0
- package/src/internal/start-plugin-core/vite/start-manifest-plugin/normalized-client-build.d.ts +11 -0
- package/src/internal/start-plugin-core/vite/start-manifest-plugin/normalized-client-build.js +114 -0
- package/src/internal/start-plugin-core/vite/start-manifest-plugin/plugin.d.ts +3 -0
- package/src/internal/start-plugin-core/vite/start-manifest-plugin/plugin.js +103 -0
- package/src/internal/start-plugin-core/vite/start-router-plugin/plugin.d.ts +9 -0
- package/src/internal/start-plugin-core/vite/start-router-plugin/plugin.js +143 -0
- package/src/internal/start-plugin-core/vite/types.d.ts +17 -0
- package/src/package-names.js +10 -0
- package/src/plugin-vite.d.ts +23 -0
- package/src/plugin-vite.js +62 -0
- package/src/runtime/client/StartClient.d.ts +11 -0
- package/src/runtime/client/StartClient.js +16 -0
- package/src/runtime/client/hydrateStart.d.ts +4 -0
- package/src/runtime/client/hydrateStart.js +30 -0
- package/src/runtime/server/StartServer.d.ts +10 -0
- package/src/runtime/server/StartServer.js +6 -0
- package/src/runtime/server/defaultRenderHandler.d.ts +3 -0
- package/src/runtime/server/defaultRenderHandler.js +11 -0
- package/src/runtime/server/defaultStreamHandler.d.ts +3 -0
- package/src/runtime/server/defaultStreamHandler.js +13 -0
- package/src/server-entry.d.ts +11 -0
- package/src/server-entry.js +13 -0
- package/src/server-only.d.ts +1 -0
- package/src/server-only.js +0 -0
- package/src/server-rpc.d.ts +1 -0
- package/src/server-rpc.js +1 -0
- package/src/server.d.ts +6 -0
- package/src/server.js +4 -0
- package/src/ssr-rpc.d.ts +1 -0
- package/src/ssr-rpc.js +1 -0
- package/src/use-server-fn.d.ts +3 -0
- package/src/use-server-fn.js +18 -0
- package/src/validate-options.js +7 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { CompileStartFrameworkOptions, GetConfigFn } from '../../types.js';
|
|
2
|
+
import { ImportProtectionBehavior } from '../../schema.js';
|
|
3
|
+
import { CompiledMatcher } from '../../import-protection/matchers.js';
|
|
4
|
+
import { ImportGraph, ViolationInfo } from '../../import-protection/trace.js';
|
|
5
|
+
import {
|
|
6
|
+
ImportLocCache,
|
|
7
|
+
TransformResult,
|
|
8
|
+
TransformResultProvider,
|
|
9
|
+
} from '../../import-protection/sourceLocation.js';
|
|
10
|
+
/** Compiled deny/exclude patterns for one environment (client or server). */
|
|
11
|
+
export interface EnvRules {
|
|
12
|
+
specifiers: Array<CompiledMatcher>;
|
|
13
|
+
files: Array<CompiledMatcher>;
|
|
14
|
+
excludeFiles: Array<CompiledMatcher>;
|
|
15
|
+
}
|
|
16
|
+
export interface PluginConfig {
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
root: string;
|
|
19
|
+
command: 'build' | 'serve';
|
|
20
|
+
bundledDev: boolean;
|
|
21
|
+
srcDirectory: string;
|
|
22
|
+
framework: CompileStartFrameworkOptions;
|
|
23
|
+
effectiveBehavior: ImportProtectionBehavior;
|
|
24
|
+
mockAccess: 'error' | 'warn' | 'off';
|
|
25
|
+
logMode: 'once' | 'always';
|
|
26
|
+
maxTraceDepth: number;
|
|
27
|
+
compiledRules: {
|
|
28
|
+
client: EnvRules;
|
|
29
|
+
server: EnvRules;
|
|
30
|
+
};
|
|
31
|
+
includeMatchers: Array<CompiledMatcher>;
|
|
32
|
+
excludeMatchers: Array<CompiledMatcher>;
|
|
33
|
+
ignoreImporterMatchers: Array<CompiledMatcher>;
|
|
34
|
+
markerSpecifiers: {
|
|
35
|
+
serverOnly: Set<string>;
|
|
36
|
+
clientOnly: Set<string>;
|
|
37
|
+
};
|
|
38
|
+
envTypeMap: Map<string, 'client' | 'server'>;
|
|
39
|
+
onViolation?: (info: ViolationInfo) => boolean | void | Promise<boolean | void>;
|
|
40
|
+
}
|
|
41
|
+
export interface EnvState {
|
|
42
|
+
graph: ImportGraph;
|
|
43
|
+
mockExportsByImporter: Map<string, Map<string, Array<string>>>;
|
|
44
|
+
resolveCache: Map<string, string | null>;
|
|
45
|
+
resolveCacheByFile: Map<string, Set<string>>;
|
|
46
|
+
importLocCache: ImportLocCache;
|
|
47
|
+
seenViolations: Set<string>;
|
|
48
|
+
serverFnLookupModules: Set<string>;
|
|
49
|
+
transformResultCache: Map<string, TransformResult>;
|
|
50
|
+
transformResultKeysByFile: Map<string, Set<string>>;
|
|
51
|
+
transformResultProvider: TransformResultProvider;
|
|
52
|
+
postTransformImports: Map<string, Set<string>>;
|
|
53
|
+
pendingViolations: Map<string, Array<PendingViolation>>;
|
|
54
|
+
deferredBuildViolations: Array<DeferredBuildViolation>;
|
|
55
|
+
}
|
|
56
|
+
export interface PendingViolation {
|
|
57
|
+
info: ViolationInfo;
|
|
58
|
+
/** True when the violation originates from a pre-transform resolveId call
|
|
59
|
+
* (e.g. server-fn lookup). These need edge-survival verification because
|
|
60
|
+
* the Start compiler may strip the import later. */
|
|
61
|
+
fromPreTransformResolve?: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface DeferredBuildViolation {
|
|
64
|
+
info: ViolationInfo;
|
|
65
|
+
mockModuleId: string;
|
|
66
|
+
checkModuleId?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface SharedState {
|
|
69
|
+
fileMarkerKind: Map<string, 'server' | 'client'>;
|
|
70
|
+
}
|
|
71
|
+
export interface ImportProtectionPluginOptions {
|
|
72
|
+
getConfig: GetConfigFn;
|
|
73
|
+
framework: CompileStartFrameworkOptions;
|
|
74
|
+
environments: Array<{
|
|
75
|
+
name: string;
|
|
76
|
+
type: 'client' | 'server';
|
|
77
|
+
}>;
|
|
78
|
+
providerEnvName: string;
|
|
79
|
+
}
|
|
80
|
+
export type ModuleGraphNode = {
|
|
81
|
+
id?: string | null;
|
|
82
|
+
url?: string;
|
|
83
|
+
importers: Set<ModuleGraphNode>;
|
|
84
|
+
};
|
|
85
|
+
export type ViolationReporter = {
|
|
86
|
+
warn: (msg: string) => void;
|
|
87
|
+
error: (msg: string) => never;
|
|
88
|
+
resolve?: (
|
|
89
|
+
source: string,
|
|
90
|
+
importer?: string,
|
|
91
|
+
options?: {
|
|
92
|
+
skipSelf?: boolean;
|
|
93
|
+
custom?: Record<string, unknown>;
|
|
94
|
+
},
|
|
95
|
+
) => Promise<{
|
|
96
|
+
id: string;
|
|
97
|
+
external?: boolean | 'absolute';
|
|
98
|
+
} | null>;
|
|
99
|
+
getModuleInfo?: (id: string) => {
|
|
100
|
+
code?: string | null;
|
|
101
|
+
} | null;
|
|
102
|
+
};
|
|
103
|
+
export type HandleViolationResult = string | undefined;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MARKER_PREFIX,
|
|
3
|
+
MOCK_BUILD_PREFIX,
|
|
4
|
+
MOCK_EDGE_PREFIX,
|
|
5
|
+
MOCK_MODULE_ID,
|
|
6
|
+
MOCK_RUNTIME_PREFIX,
|
|
7
|
+
RUNTIME_SUGGESTION_TEXT,
|
|
8
|
+
generateDevSelfDenialModule,
|
|
9
|
+
generateSelfContainedMockModule,
|
|
10
|
+
loadMarkerModule,
|
|
11
|
+
loadMockEdgeModule,
|
|
12
|
+
loadMockRuntimeModule,
|
|
13
|
+
loadSilentMockModule,
|
|
14
|
+
makeMockEdgeModuleId,
|
|
15
|
+
mockRuntimeModuleIdFromViolation,
|
|
16
|
+
} from '../../import-protection/virtualModules.js';
|
|
17
|
+
export declare function resolvedMarkerVirtualModuleId(kind: 'server' | 'client'): string;
|
|
18
|
+
export declare function getResolvedVirtualModuleMatchers(): ReadonlyArray<string>;
|
|
19
|
+
export declare function resolveInternalVirtualModuleId(source: string): string | undefined;
|
|
20
|
+
export declare function loadResolvedVirtualModule(id: string):
|
|
21
|
+
| {
|
|
22
|
+
code: string;
|
|
23
|
+
}
|
|
24
|
+
| undefined;
|
|
25
|
+
export {
|
|
26
|
+
MARKER_PREFIX,
|
|
27
|
+
MOCK_BUILD_PREFIX,
|
|
28
|
+
MOCK_EDGE_PREFIX,
|
|
29
|
+
MOCK_MODULE_ID,
|
|
30
|
+
MOCK_RUNTIME_PREFIX,
|
|
31
|
+
RUNTIME_SUGGESTION_TEXT,
|
|
32
|
+
generateDevSelfDenialModule,
|
|
33
|
+
generateSelfContainedMockModule,
|
|
34
|
+
loadMarkerModule,
|
|
35
|
+
loadMockEdgeModule,
|
|
36
|
+
loadMockRuntimeModule,
|
|
37
|
+
loadSilentMockModule,
|
|
38
|
+
makeMockEdgeModuleId,
|
|
39
|
+
mockRuntimeModuleIdFromViolation,
|
|
40
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { resolveViteId } from '../../utils.js';
|
|
2
|
+
import {
|
|
3
|
+
MARKER_PREFIX,
|
|
4
|
+
MOCK_BUILD_PREFIX,
|
|
5
|
+
MOCK_EDGE_PREFIX,
|
|
6
|
+
MOCK_MODULE_ID,
|
|
7
|
+
MOCK_RUNTIME_PREFIX,
|
|
8
|
+
VITE_BROWSER_VIRTUAL_PREFIX,
|
|
9
|
+
} from '../../import-protection/constants.js';
|
|
10
|
+
import {
|
|
11
|
+
loadMarkerModule,
|
|
12
|
+
loadMockEdgeModule,
|
|
13
|
+
loadMockRuntimeModule,
|
|
14
|
+
loadSilentMockModule,
|
|
15
|
+
} from '../../import-protection/virtualModules.js';
|
|
16
|
+
//#region src/vite/import-protection-plugin/virtualModules.ts
|
|
17
|
+
var RESOLVED_MOCK_MODULE_ID = resolveViteId(MOCK_MODULE_ID);
|
|
18
|
+
var RESOLVED_MOCK_BUILD_PREFIX = resolveViteId(MOCK_BUILD_PREFIX);
|
|
19
|
+
var RESOLVED_MOCK_EDGE_PREFIX = resolveViteId(MOCK_EDGE_PREFIX);
|
|
20
|
+
var RESOLVED_MOCK_RUNTIME_PREFIX = resolveViteId(MOCK_RUNTIME_PREFIX);
|
|
21
|
+
var RESOLVED_MARKER_PREFIX = resolveViteId(MARKER_PREFIX);
|
|
22
|
+
var RESOLVED_MARKER_SERVER_ONLY = resolveViteId(`${MARKER_PREFIX}server-only`);
|
|
23
|
+
var RESOLVED_MARKER_CLIENT_ONLY = resolveViteId(`${MARKER_PREFIX}client-only`);
|
|
24
|
+
function resolvedMarkerVirtualModuleId(kind) {
|
|
25
|
+
return kind === 'server' ? RESOLVED_MARKER_SERVER_ONLY : RESOLVED_MARKER_CLIENT_ONLY;
|
|
26
|
+
}
|
|
27
|
+
function getResolvedVirtualModuleMatchers() {
|
|
28
|
+
return RESOLVED_VIRTUAL_MODULE_MATCHERS;
|
|
29
|
+
}
|
|
30
|
+
var RESOLVED_VIRTUAL_MODULE_MATCHERS = [
|
|
31
|
+
RESOLVED_MOCK_MODULE_ID,
|
|
32
|
+
RESOLVED_MOCK_BUILD_PREFIX,
|
|
33
|
+
RESOLVED_MOCK_EDGE_PREFIX,
|
|
34
|
+
RESOLVED_MOCK_RUNTIME_PREFIX,
|
|
35
|
+
RESOLVED_MARKER_PREFIX,
|
|
36
|
+
];
|
|
37
|
+
var RESOLVE_PREFIX_PAIRS = [
|
|
38
|
+
[MOCK_EDGE_PREFIX, RESOLVED_MOCK_EDGE_PREFIX],
|
|
39
|
+
[MOCK_RUNTIME_PREFIX, RESOLVED_MOCK_RUNTIME_PREFIX],
|
|
40
|
+
[MOCK_BUILD_PREFIX, RESOLVED_MOCK_BUILD_PREFIX],
|
|
41
|
+
[MARKER_PREFIX, RESOLVED_MARKER_PREFIX],
|
|
42
|
+
];
|
|
43
|
+
function resolveInternalVirtualModuleId(source) {
|
|
44
|
+
if (source.startsWith('/@id/__x00__'))
|
|
45
|
+
return resolveInternalVirtualModuleId(`\0${source.slice(VITE_BROWSER_VIRTUAL_PREFIX.length)}`);
|
|
46
|
+
if (source === 'tanstack-start-import-protection:mock' || source === RESOLVED_MOCK_MODULE_ID)
|
|
47
|
+
return RESOLVED_MOCK_MODULE_ID;
|
|
48
|
+
for (const [unresolvedPrefix, resolvedPrefix] of RESOLVE_PREFIX_PAIRS) {
|
|
49
|
+
if (source.startsWith(unresolvedPrefix)) return resolveViteId(source);
|
|
50
|
+
if (source.startsWith(resolvedPrefix)) return source;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function loadResolvedVirtualModule(id) {
|
|
54
|
+
if (id === RESOLVED_MOCK_MODULE_ID) return loadSilentMockModule();
|
|
55
|
+
if (id.startsWith(RESOLVED_MOCK_BUILD_PREFIX)) return loadSilentMockModule();
|
|
56
|
+
if (id.startsWith(RESOLVED_MOCK_EDGE_PREFIX))
|
|
57
|
+
return loadMockEdgeModule(id.slice(RESOLVED_MOCK_EDGE_PREFIX.length));
|
|
58
|
+
if (id.startsWith(RESOLVED_MOCK_RUNTIME_PREFIX))
|
|
59
|
+
return loadMockRuntimeModule(id.slice(RESOLVED_MOCK_RUNTIME_PREFIX.length));
|
|
60
|
+
if (id.startsWith(RESOLVED_MARKER_PREFIX)) return loadMarkerModule();
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export {
|
|
64
|
+
getResolvedVirtualModuleMatchers,
|
|
65
|
+
loadResolvedVirtualModule,
|
|
66
|
+
resolveInternalVirtualModuleId,
|
|
67
|
+
resolvedMarkerVirtualModuleId,
|
|
68
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
TanStackStartVitePluginCoreOptions,
|
|
3
|
+
ViteRscForwardSsrResolverStrategy,
|
|
4
|
+
} from './types.js';
|
|
5
|
+
export type { TanStackStartViteInputConfig } from './schema.js';
|
|
6
|
+
export type {
|
|
7
|
+
StartCompilerImportTransform,
|
|
8
|
+
StartCompilerTransformCandidate,
|
|
9
|
+
StartCompilerTransformContext,
|
|
10
|
+
} from '../types.js';
|
|
11
|
+
export { START_ENVIRONMENT_NAMES, VITE_ENVIRONMENT_NAMES } from '../constants.js';
|
|
12
|
+
export { createVirtualModule } from './createVirtualModule.js';
|
|
13
|
+
export { tanStackStartVite } from './plugin.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { START_ENVIRONMENT_NAMES, VITE_ENVIRONMENT_NAMES } from '../constants.js';
|
|
2
|
+
import { createVirtualModule } from './createVirtualModule.js';
|
|
3
|
+
import { tanStackStartVite } from './plugin.js';
|
|
4
|
+
export { START_ENVIRONMENT_NAMES, VITE_ENVIRONMENT_NAMES, createVirtualModule, tanStackStartVite };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { loadEnv } from 'vite';
|
|
2
|
+
//#region src/vite/load-env-plugin/plugin.ts
|
|
3
|
+
function loadEnvPlugin() {
|
|
4
|
+
return {
|
|
5
|
+
name: 'tanstack-start-core:load-env',
|
|
6
|
+
enforce: 'pre',
|
|
7
|
+
configResolved(config) {
|
|
8
|
+
Object.assign(process.env, loadEnv(config.mode, config.root, ''));
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { loadEnvPlugin };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as vite from 'vite';
|
|
2
|
+
export declare function getClientOutputDirectory(
|
|
3
|
+
userConfig: vite.UserConfig | vite.ResolvedConfig,
|
|
4
|
+
): string;
|
|
5
|
+
export declare function getServerOutputDirectory(
|
|
6
|
+
userConfig: vite.UserConfig | vite.ResolvedConfig,
|
|
7
|
+
): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { VITE_ENVIRONMENT_NAMES } from '../constants.js';
|
|
2
|
+
import { join } from 'pathe';
|
|
3
|
+
//#region src/vite/output-directory.ts
|
|
4
|
+
function getClientOutputDirectory(userConfig) {
|
|
5
|
+
return getOutputDirectory(userConfig, VITE_ENVIRONMENT_NAMES.client, 'client');
|
|
6
|
+
}
|
|
7
|
+
function getServerOutputDirectory(userConfig) {
|
|
8
|
+
return getOutputDirectory(userConfig, VITE_ENVIRONMENT_NAMES.server, 'server');
|
|
9
|
+
}
|
|
10
|
+
function getOutputDirectory(userConfig, environmentName, directoryName) {
|
|
11
|
+
const rootOutputDirectory = userConfig.build?.outDir ?? 'dist';
|
|
12
|
+
return (
|
|
13
|
+
userConfig.environments?.[environmentName]?.build?.outDir ??
|
|
14
|
+
join(rootOutputDirectory, directoryName)
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { getClientOutputDirectory, getServerOutputDirectory };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { ENTRY_POINTS } from '../constants.js';
|
|
2
|
+
import { CompileStartFrameworkOptions } from '../types.js';
|
|
3
|
+
import { ResolvedStartEntryPlan } from '../planning.js';
|
|
4
|
+
import type * as vite from 'vite';
|
|
5
|
+
export interface ViteResolvedEntryAliases {
|
|
6
|
+
client: string;
|
|
7
|
+
server: string;
|
|
8
|
+
start: string;
|
|
9
|
+
router: string;
|
|
10
|
+
alias: Record<(typeof ENTRY_POINTS)[keyof typeof ENTRY_POINTS], string>;
|
|
11
|
+
}
|
|
12
|
+
export declare function createViteResolvedEntryAliases(opts: {
|
|
13
|
+
entryPaths: ResolvedStartEntryPlan['entryPaths'];
|
|
14
|
+
}): ViteResolvedEntryAliases;
|
|
15
|
+
export declare function createViteConfigPlan(opts: {
|
|
16
|
+
viteConfig: vite.UserConfig;
|
|
17
|
+
command: 'serve' | 'build';
|
|
18
|
+
framework: CompileStartFrameworkOptions;
|
|
19
|
+
entryAliases: ViteResolvedEntryAliases;
|
|
20
|
+
clientOutputDirectory: string;
|
|
21
|
+
serverOutputDirectory: string;
|
|
22
|
+
serverFnProviderEnv: string;
|
|
23
|
+
optimizeDepsExclude: Array<string>;
|
|
24
|
+
noExternal: Array<string>;
|
|
25
|
+
}): {
|
|
26
|
+
environments: {
|
|
27
|
+
client: {
|
|
28
|
+
consumer: 'client';
|
|
29
|
+
build: {
|
|
30
|
+
rollupOptions: {
|
|
31
|
+
input: {
|
|
32
|
+
index: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
rolldownOptions: {
|
|
36
|
+
input: {
|
|
37
|
+
index: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
outDir: string;
|
|
41
|
+
};
|
|
42
|
+
optimizeDeps: {
|
|
43
|
+
exclude: string[];
|
|
44
|
+
entries: string[];
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
ssr: {
|
|
48
|
+
consumer: 'server';
|
|
49
|
+
build: {
|
|
50
|
+
outDir: string;
|
|
51
|
+
commonjsOptions: {
|
|
52
|
+
include: RegExp[];
|
|
53
|
+
};
|
|
54
|
+
copyPublicDir: boolean;
|
|
55
|
+
rollupOptions: {
|
|
56
|
+
input: any;
|
|
57
|
+
};
|
|
58
|
+
rolldownOptions: {
|
|
59
|
+
input: any;
|
|
60
|
+
};
|
|
61
|
+
ssr: true;
|
|
62
|
+
};
|
|
63
|
+
optimizeDeps: {
|
|
64
|
+
entries: string[];
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
resolve: {
|
|
69
|
+
noExternal: string[];
|
|
70
|
+
alias: {
|
|
71
|
+
'virtual:tanstack-start-client-entry': string;
|
|
72
|
+
'virtual:tanstack-start-server-entry': string;
|
|
73
|
+
'#tanstack-start-entry': string;
|
|
74
|
+
'#tanstack-router-entry': string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export declare function createViteDefineConfig(opts: {
|
|
79
|
+
command: 'serve' | 'build';
|
|
80
|
+
mode: string | undefined;
|
|
81
|
+
serverFnBase: string;
|
|
82
|
+
routerBasepath: string;
|
|
83
|
+
spaEnabled: boolean | undefined;
|
|
84
|
+
devSsrStylesEnabled: boolean;
|
|
85
|
+
devSsrStylesBasepath: string;
|
|
86
|
+
inlineCssEnabled: boolean;
|
|
87
|
+
staticNodeEnv: boolean;
|
|
88
|
+
disableCsrfMiddlewareWarning: boolean;
|
|
89
|
+
}): {
|
|
90
|
+
'process.env.NODE_ENV'?: string | undefined;
|
|
91
|
+
'process.env.TSS_DISABLE_CSRF_MIDDLEWARE_WARNING': 'false' | 'true';
|
|
92
|
+
'import.meta.env.TSS_DISABLE_CSRF_MIDDLEWARE_WARNING': 'false' | 'true';
|
|
93
|
+
'process.env.TSS_INLINE_CSS_ENABLED': 'false' | 'true';
|
|
94
|
+
'import.meta.env.TSS_INLINE_CSS_ENABLED': 'false' | 'true';
|
|
95
|
+
'process.env.TSS_DEV_SSR_STYLES_BASEPATH': string;
|
|
96
|
+
'import.meta.env.TSS_DEV_SSR_STYLES_BASEPATH': string;
|
|
97
|
+
'process.env.TSS_DEV_SSR_STYLES_ENABLED': 'false' | 'true';
|
|
98
|
+
'import.meta.env.TSS_DEV_SSR_STYLES_ENABLED': 'false' | 'true';
|
|
99
|
+
'process.env.TSS_DEV_SERVER': 'false' | 'true';
|
|
100
|
+
'import.meta.env.TSS_DEV_SERVER': 'false' | 'true';
|
|
101
|
+
'process.env.TSS_SHELL'?: 'false' | 'true' | undefined;
|
|
102
|
+
'import.meta.env.TSS_SHELL'?: 'false' | 'true' | undefined;
|
|
103
|
+
'process.env.TSS_ROUTER_BASEPATH': string;
|
|
104
|
+
'import.meta.env.TSS_ROUTER_BASEPATH': string;
|
|
105
|
+
'process.env.TSS_SERVER_FN_BASE': string;
|
|
106
|
+
'import.meta.env.TSS_SERVER_FN_BASE': string;
|
|
107
|
+
};
|
|
108
|
+
export declare function buildStartViteEnvironments(opts: {
|
|
109
|
+
builder: vite.ViteBuilder;
|
|
110
|
+
providerEnvironmentName: string;
|
|
111
|
+
ssrIsProvider: boolean;
|
|
112
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { DEV_CLIENT_ENTRY, ENTRY_POINTS, START_ENVIRONMENT_NAMES } from '../constants.js';
|
|
2
|
+
import { getBundlerOptions } from '../utils.js';
|
|
3
|
+
import { join } from 'pathe';
|
|
4
|
+
import { normalizePath } from 'vite';
|
|
5
|
+
import { escapePath } from 'tinyglobby';
|
|
6
|
+
import { getStartPackage } from '#tanstack-start/package-names';
|
|
7
|
+
//#region src/vite/planning.ts
|
|
8
|
+
function createViteResolvedEntryAliases(opts) {
|
|
9
|
+
const client = normalizePath(opts.entryPaths.client);
|
|
10
|
+
const server = normalizePath(opts.entryPaths.server);
|
|
11
|
+
const start = normalizePath(opts.entryPaths.start);
|
|
12
|
+
const router = normalizePath(opts.entryPaths.router);
|
|
13
|
+
return {
|
|
14
|
+
client,
|
|
15
|
+
server,
|
|
16
|
+
start,
|
|
17
|
+
router,
|
|
18
|
+
alias: {
|
|
19
|
+
[ENTRY_POINTS.client]: client,
|
|
20
|
+
[ENTRY_POINTS.server]: server,
|
|
21
|
+
[ENTRY_POINTS.start]: start,
|
|
22
|
+
[ENTRY_POINTS.router]: router,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function createViteConfigPlan(opts) {
|
|
27
|
+
return {
|
|
28
|
+
environments: {
|
|
29
|
+
[START_ENVIRONMENT_NAMES.client]: {
|
|
30
|
+
consumer: 'client',
|
|
31
|
+
build: (() => {
|
|
32
|
+
const bundlerOptions = {
|
|
33
|
+
input: { index: opts.command === 'serve' ? DEV_CLIENT_ENTRY : ENTRY_POINTS.client },
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
rollupOptions: bundlerOptions,
|
|
37
|
+
rolldownOptions: bundlerOptions,
|
|
38
|
+
outDir: opts.clientOutputDirectory,
|
|
39
|
+
};
|
|
40
|
+
})(),
|
|
41
|
+
optimizeDeps: {
|
|
42
|
+
exclude: opts.optimizeDepsExclude,
|
|
43
|
+
entries: escapeEntries([opts.entryAliases.client, opts.entryAliases.router]),
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
[START_ENVIRONMENT_NAMES.server]: {
|
|
47
|
+
consumer: 'server',
|
|
48
|
+
build: {
|
|
49
|
+
ssr: true,
|
|
50
|
+
...(() => {
|
|
51
|
+
const bundlerOptions = {
|
|
52
|
+
input:
|
|
53
|
+
getBundlerOptions(
|
|
54
|
+
opts.viteConfig.environments?.[START_ENVIRONMENT_NAMES.server]?.build,
|
|
55
|
+
)?.input ?? opts.entryAliases.server,
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
rollupOptions: bundlerOptions,
|
|
59
|
+
rolldownOptions: bundlerOptions,
|
|
60
|
+
};
|
|
61
|
+
})(),
|
|
62
|
+
outDir: opts.serverOutputDirectory,
|
|
63
|
+
commonjsOptions: { include: [/node_modules/] },
|
|
64
|
+
copyPublicDir:
|
|
65
|
+
opts.viteConfig.environments?.[START_ENVIRONMENT_NAMES.server]?.build?.copyPublicDir ??
|
|
66
|
+
false,
|
|
67
|
+
},
|
|
68
|
+
optimizeDeps: {
|
|
69
|
+
entries: escapeEntries([
|
|
70
|
+
opts.entryAliases.server,
|
|
71
|
+
opts.entryAliases.start,
|
|
72
|
+
opts.entryAliases.router,
|
|
73
|
+
]),
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
...(opts.serverFnProviderEnv !== START_ENVIRONMENT_NAMES.server && {
|
|
77
|
+
[opts.serverFnProviderEnv]: {
|
|
78
|
+
build: { outDir: join(opts.serverOutputDirectory, opts.serverFnProviderEnv) },
|
|
79
|
+
optimizeDeps: { entries: escapeEntries([opts.entryAliases.router]) },
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
},
|
|
83
|
+
resolve: {
|
|
84
|
+
noExternal: ['@tanstack/start**', `${getStartPackage(opts.framework)}**`, ...opts.noExternal],
|
|
85
|
+
alias: { ...opts.entryAliases.alias },
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function createViteDefineConfig(opts) {
|
|
90
|
+
return {
|
|
91
|
+
...defineReplaceEnv('TSS_SERVER_FN_BASE', opts.serverFnBase),
|
|
92
|
+
...defineReplaceEnv('TSS_ROUTER_BASEPATH', opts.routerBasepath),
|
|
93
|
+
...(opts.command === 'serve'
|
|
94
|
+
? defineReplaceEnv('TSS_SHELL', opts.spaEnabled ? 'true' : 'false')
|
|
95
|
+
: {}),
|
|
96
|
+
...defineReplaceEnv('TSS_DEV_SERVER', opts.command === 'serve' ? 'true' : 'false'),
|
|
97
|
+
...defineReplaceEnv('TSS_DEV_SSR_STYLES_ENABLED', opts.devSsrStylesEnabled ? 'true' : 'false'),
|
|
98
|
+
...defineReplaceEnv('TSS_DEV_SSR_STYLES_BASEPATH', opts.devSsrStylesBasepath),
|
|
99
|
+
...defineReplaceEnv('TSS_INLINE_CSS_ENABLED', opts.inlineCssEnabled ? 'true' : 'false'),
|
|
100
|
+
...defineReplaceEnv(
|
|
101
|
+
'TSS_DISABLE_CSRF_MIDDLEWARE_WARNING',
|
|
102
|
+
opts.disableCsrfMiddlewareWarning ? 'true' : 'false',
|
|
103
|
+
),
|
|
104
|
+
...(opts.command === 'build' && opts.staticNodeEnv
|
|
105
|
+
? {
|
|
106
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || opts.mode || 'production'),
|
|
107
|
+
}
|
|
108
|
+
: {}),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async function buildStartViteEnvironments(opts) {
|
|
112
|
+
const client = getRequiredBuilderEnvironment(
|
|
113
|
+
opts.builder,
|
|
114
|
+
START_ENVIRONMENT_NAMES.client,
|
|
115
|
+
'Client environment not found',
|
|
116
|
+
);
|
|
117
|
+
const server = getRequiredBuilderEnvironment(
|
|
118
|
+
opts.builder,
|
|
119
|
+
START_ENVIRONMENT_NAMES.server,
|
|
120
|
+
'SSR environment not found',
|
|
121
|
+
);
|
|
122
|
+
if (!client.isBuilt) await opts.builder.build(client);
|
|
123
|
+
if (!server.isBuilt) await opts.builder.build(server);
|
|
124
|
+
if (opts.ssrIsProvider) return;
|
|
125
|
+
const providerEnv = getRequiredBuilderEnvironment(
|
|
126
|
+
opts.builder,
|
|
127
|
+
opts.providerEnvironmentName,
|
|
128
|
+
`Provider environment "${opts.providerEnvironmentName}" not found`,
|
|
129
|
+
);
|
|
130
|
+
if (!providerEnv.isBuilt) await opts.builder.build(providerEnv);
|
|
131
|
+
}
|
|
132
|
+
function escapeEntries(entries) {
|
|
133
|
+
return entries.map((entry) => escapePath(entry));
|
|
134
|
+
}
|
|
135
|
+
function defineReplaceEnv(key, value) {
|
|
136
|
+
return {
|
|
137
|
+
[`process.env.${key}`]: JSON.stringify(value),
|
|
138
|
+
[`import.meta.env.${key}`]: JSON.stringify(value),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function getRequiredBuilderEnvironment(builder, environmentName, errorMessage) {
|
|
142
|
+
const environment = builder.environments[environmentName];
|
|
143
|
+
if (!environment) throw new Error(errorMessage);
|
|
144
|
+
return environment;
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
export {
|
|
148
|
+
buildStartViteEnvironments,
|
|
149
|
+
createViteConfigPlan,
|
|
150
|
+
createViteDefineConfig,
|
|
151
|
+
createViteResolvedEntryAliases,
|
|
152
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TanStackStartVitePluginCoreOptions } from './types.js';
|
|
2
|
+
import { TanStackStartViteInputConfig } from './schema.js';
|
|
3
|
+
import { PluginOption } from 'vite';
|
|
4
|
+
export declare function tanStackStartVite(
|
|
5
|
+
corePluginOpts: TanStackStartVitePluginCoreOptions,
|
|
6
|
+
startPluginOpts: TanStackStartViteInputConfig | undefined,
|
|
7
|
+
): Array<PluginOption>;
|