@tanstack/start-plugin-core 1.121.0-alpha.2 → 1.121.0-alpha.21
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/dist/cjs/constants.cjs +4 -0
- package/dist/cjs/constants.cjs.map +1 -1
- package/dist/cjs/constants.d.cts +2 -0
- package/dist/cjs/{extractHtmlScripts.cjs → dev-server-plugin/extract-html-scripts.cjs} +1 -1
- package/dist/cjs/dev-server-plugin/extract-html-scripts.cjs.map +1 -0
- package/dist/cjs/{nitro/dev-server-plugin.cjs → dev-server-plugin/plugin.cjs} +2 -2
- package/dist/cjs/dev-server-plugin/plugin.cjs.map +1 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -0
- package/dist/cjs/load-env-plugin/plugin.cjs +34 -0
- package/dist/cjs/load-env-plugin/plugin.cjs.map +1 -0
- package/dist/cjs/load-env-plugin/plugin.d.cts +3 -0
- package/dist/cjs/nitro-plugin/build-sitemap.cjs +138 -0
- package/dist/cjs/nitro-plugin/build-sitemap.cjs.map +1 -0
- package/dist/cjs/nitro-plugin/build-sitemap.d.cts +31 -0
- package/dist/cjs/{nitro/nitro-plugin.cjs → nitro-plugin/plugin.cjs} +77 -54
- package/dist/cjs/nitro-plugin/plugin.cjs.map +1 -0
- package/dist/cjs/{prerender.cjs → nitro-plugin/prerender.cjs} +12 -17
- package/dist/cjs/nitro-plugin/prerender.cjs.map +1 -0
- package/dist/cjs/{prerender.d.cts → nitro-plugin/prerender.d.cts} +1 -1
- package/dist/cjs/nitro-plugin/queue.cjs.map +1 -0
- package/dist/cjs/plugin.cjs +38 -27
- package/dist/cjs/plugin.cjs.map +1 -1
- package/dist/cjs/plugin.d.cts +25 -3064
- package/dist/cjs/resolve-virtual-entries-plugin/plugin.cjs +66 -0
- package/dist/cjs/resolve-virtual-entries-plugin/plugin.cjs.map +1 -0
- package/dist/cjs/resolve-virtual-entries-plugin/plugin.d.cts +3 -0
- package/dist/cjs/schema.cjs +6 -4
- package/dist/cjs/schema.cjs.map +1 -1
- package/dist/cjs/schema.d.cts +530 -1656
- package/dist/cjs/start-compiler-plugin.cjs +2 -2
- package/dist/cjs/start-compiler-plugin.cjs.map +1 -1
- package/dist/cjs/start-compiler-plugin.d.cts +1 -1
- package/dist/cjs/{routesManifestPlugin.cjs → start-routes-manifest-plugin/plugin.cjs} +86 -44
- package/dist/cjs/start-routes-manifest-plugin/plugin.cjs.map +1 -0
- package/dist/cjs/start-routes-manifest-plugin/plugin.d.cts +3 -0
- package/dist/cjs/start-server-routes-plugin/plugin.cjs +4 -2
- package/dist/cjs/start-server-routes-plugin/plugin.cjs.map +1 -1
- package/dist/cjs/utils.cjs +18 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/utils.d.cts +8 -0
- package/dist/esm/constants.d.ts +2 -0
- package/dist/esm/constants.js +4 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/{extractHtmlScripts.js → dev-server-plugin/extract-html-scripts.js} +1 -1
- package/dist/esm/dev-server-plugin/extract-html-scripts.js.map +1 -0
- package/dist/esm/{nitro/dev-server-plugin.js → dev-server-plugin/plugin.js} +2 -2
- package/dist/esm/dev-server-plugin/plugin.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/load-env-plugin/plugin.d.ts +3 -0
- package/dist/esm/load-env-plugin/plugin.js +17 -0
- package/dist/esm/load-env-plugin/plugin.js.map +1 -0
- package/dist/esm/nitro-plugin/build-sitemap.d.ts +31 -0
- package/dist/esm/nitro-plugin/build-sitemap.js +138 -0
- package/dist/esm/nitro-plugin/build-sitemap.js.map +1 -0
- package/dist/esm/nitro-plugin/plugin.js +181 -0
- package/dist/esm/nitro-plugin/plugin.js.map +1 -0
- package/dist/esm/{prerender.d.ts → nitro-plugin/prerender.d.ts} +1 -1
- package/dist/esm/{prerender.js → nitro-plugin/prerender.js} +12 -17
- package/dist/esm/nitro-plugin/prerender.js.map +1 -0
- package/dist/esm/nitro-plugin/queue.js.map +1 -0
- package/dist/esm/plugin.d.ts +25 -3064
- package/dist/esm/plugin.js +39 -28
- package/dist/esm/plugin.js.map +1 -1
- package/dist/esm/resolve-virtual-entries-plugin/plugin.d.ts +3 -0
- package/dist/esm/resolve-virtual-entries-plugin/plugin.js +49 -0
- package/dist/esm/resolve-virtual-entries-plugin/plugin.js.map +1 -0
- package/dist/esm/schema.d.ts +530 -1656
- package/dist/esm/schema.js +6 -4
- package/dist/esm/schema.js.map +1 -1
- package/dist/esm/start-compiler-plugin.d.ts +1 -1
- package/dist/esm/start-compiler-plugin.js +2 -2
- package/dist/esm/start-compiler-plugin.js.map +1 -1
- package/dist/esm/start-routes-manifest-plugin/plugin.d.ts +3 -0
- package/dist/esm/{routesManifestPlugin.js → start-routes-manifest-plugin/plugin.js} +87 -45
- package/dist/esm/start-routes-manifest-plugin/plugin.js.map +1 -0
- package/dist/esm/start-server-routes-plugin/plugin.js +4 -2
- package/dist/esm/start-server-routes-plugin/plugin.js.map +1 -1
- package/dist/esm/utils.d.ts +8 -0
- package/dist/esm/utils.js +18 -0
- package/dist/esm/utils.js.map +1 -0
- package/package.json +6 -6
- package/src/constants.ts +3 -0
- package/src/{nitro/dev-server-plugin.ts → dev-server-plugin/plugin.ts} +11 -1
- package/src/index.ts +1 -0
- package/src/load-env-plugin/plugin.ts +17 -0
- package/src/nitro-plugin/build-sitemap.ts +213 -0
- package/src/nitro-plugin/plugin.ts +244 -0
- package/src/{prerender.ts → nitro-plugin/prerender.ts} +14 -21
- package/src/plugin.ts +57 -29
- package/src/resolve-virtual-entries-plugin/plugin.ts +63 -0
- package/src/schema.ts +11 -9
- package/src/start-compiler-plugin.ts +1 -1
- package/src/{routesManifestPlugin.ts → start-routes-manifest-plugin/plugin.ts} +111 -45
- package/src/start-server-routes-plugin/plugin.ts +4 -2
- package/src/utils.ts +14 -0
- package/dist/cjs/extractHtmlScripts.cjs.map +0 -1
- package/dist/cjs/nitro/build-nitro.cjs +0 -18
- package/dist/cjs/nitro/build-nitro.cjs.map +0 -1
- package/dist/cjs/nitro/build-nitro.d.cts +0 -2
- package/dist/cjs/nitro/build-sitemap.d.cts +0 -9
- package/dist/cjs/nitro/dev-server-plugin.cjs.map +0 -1
- package/dist/cjs/nitro/nitro-plugin.cjs.map +0 -1
- package/dist/cjs/prerender.cjs.map +0 -1
- package/dist/cjs/queue.cjs.map +0 -1
- package/dist/cjs/routesManifestPlugin.cjs.map +0 -1
- package/dist/cjs/routesManifestPlugin.d.cts +0 -3
- package/dist/esm/extractHtmlScripts.js.map +0 -1
- package/dist/esm/nitro/build-nitro.d.ts +0 -2
- package/dist/esm/nitro/build-nitro.js +0 -18
- package/dist/esm/nitro/build-nitro.js.map +0 -1
- package/dist/esm/nitro/build-sitemap.d.ts +0 -9
- package/dist/esm/nitro/dev-server-plugin.js.map +0 -1
- package/dist/esm/nitro/nitro-plugin.js +0 -158
- package/dist/esm/nitro/nitro-plugin.js.map +0 -1
- package/dist/esm/prerender.js.map +0 -1
- package/dist/esm/queue.js.map +0 -1
- package/dist/esm/routesManifestPlugin.d.ts +0 -3
- package/dist/esm/routesManifestPlugin.js.map +0 -1
- package/src/nitro/build-nitro.ts +0 -27
- package/src/nitro/build-sitemap.ts +0 -79
- package/src/nitro/nitro-plugin.ts +0 -199
- /package/dist/cjs/{extractHtmlScripts.d.cts → dev-server-plugin/extract-html-scripts.d.cts} +0 -0
- /package/dist/cjs/{nitro/dev-server-plugin.d.cts → dev-server-plugin/plugin.d.cts} +0 -0
- /package/dist/cjs/{nitro/nitro-plugin.d.cts → nitro-plugin/plugin.d.cts} +0 -0
- /package/dist/cjs/{queue.cjs → nitro-plugin/queue.cjs} +0 -0
- /package/dist/cjs/{queue.d.cts → nitro-plugin/queue.d.cts} +0 -0
- /package/dist/esm/{extractHtmlScripts.d.ts → dev-server-plugin/extract-html-scripts.d.ts} +0 -0
- /package/dist/esm/{nitro/dev-server-plugin.d.ts → dev-server-plugin/plugin.d.ts} +0 -0
- /package/dist/esm/{nitro/nitro-plugin.d.ts → nitro-plugin/plugin.d.ts} +0 -0
- /package/dist/esm/{queue.d.ts → nitro-plugin/queue.d.ts} +0 -0
- /package/dist/esm/{queue.js → nitro-plugin/queue.js} +0 -0
- /package/src/{extractHtmlScripts.ts → dev-server-plugin/extract-html-scripts.ts} +0 -0
- /package/src/{queue.ts → nitro-plugin/queue.ts} +0 -0
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
import { rmSync } from 'node:fs'
|
|
3
|
-
import { build, createNitro } from 'nitropack'
|
|
4
|
-
import { dirname, resolve } from 'pathe'
|
|
5
|
-
import { clientDistDir, ssrEntryFile } from '../plugin'
|
|
6
|
-
import { prerender } from '../prerender'
|
|
7
|
-
import { VITE_ENVIRONMENT_NAMES } from '../constants'
|
|
8
|
-
import { devServerPlugin } from './dev-server-plugin'
|
|
9
|
-
import { buildNitroEnvironment } from './build-nitro'
|
|
10
|
-
import type { EnvironmentOptions, PluginOption, Rollup } from 'vite'
|
|
11
|
-
import type { NitroConfig } from 'nitropack'
|
|
12
|
-
import type { TanStackStartOutputConfig } from '../plugin'
|
|
13
|
-
|
|
14
|
-
export function nitroPlugin(
|
|
15
|
-
options: TanStackStartOutputConfig,
|
|
16
|
-
getSsrBundle: () => Rollup.OutputBundle,
|
|
17
|
-
): Array<PluginOption> {
|
|
18
|
-
const buildPreset =
|
|
19
|
-
process.env['START_TARGET'] ?? (options.target as string | undefined)
|
|
20
|
-
|
|
21
|
-
return [
|
|
22
|
-
devServerPlugin(),
|
|
23
|
-
{
|
|
24
|
-
name: 'tanstack-vite-plugin-nitro',
|
|
25
|
-
configEnvironment(name) {
|
|
26
|
-
if (name === VITE_ENVIRONMENT_NAMES.server) {
|
|
27
|
-
return {
|
|
28
|
-
build: {
|
|
29
|
-
commonjsOptions: {
|
|
30
|
-
include: [],
|
|
31
|
-
},
|
|
32
|
-
ssr: true,
|
|
33
|
-
sourcemap: true,
|
|
34
|
-
rollupOptions: {
|
|
35
|
-
input: '/~start/server-entry',
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
} satisfies EnvironmentOptions
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return null
|
|
42
|
-
},
|
|
43
|
-
config() {
|
|
44
|
-
return {
|
|
45
|
-
builder: {
|
|
46
|
-
sharedPlugins: true,
|
|
47
|
-
async buildApp(builder) {
|
|
48
|
-
const clientEnv =
|
|
49
|
-
builder.environments[VITE_ENVIRONMENT_NAMES.client]
|
|
50
|
-
const serverEnv =
|
|
51
|
-
builder.environments[VITE_ENVIRONMENT_NAMES.server]
|
|
52
|
-
|
|
53
|
-
if (!clientEnv) {
|
|
54
|
-
throw new Error('Client environment not found')
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (!serverEnv) {
|
|
58
|
-
throw new Error('SSR environment not found')
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const clientOutputDir = resolve(options.root, clientDistDir)
|
|
62
|
-
rmSync(clientOutputDir, { recursive: true, force: true })
|
|
63
|
-
await builder.build(clientEnv)
|
|
64
|
-
|
|
65
|
-
await builder.build(serverEnv)
|
|
66
|
-
|
|
67
|
-
const nitroConfig: NitroConfig = {
|
|
68
|
-
dev: false,
|
|
69
|
-
// TODO do we need this? should this be made configurable?
|
|
70
|
-
compatibilityDate: '2024-11-19',
|
|
71
|
-
logLevel: 3,
|
|
72
|
-
preset: buildPreset,
|
|
73
|
-
publicAssets: [
|
|
74
|
-
{
|
|
75
|
-
dir: path.resolve(options.root, clientDistDir),
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
typescript: {
|
|
79
|
-
generateTsConfig: false,
|
|
80
|
-
},
|
|
81
|
-
prerender: undefined,
|
|
82
|
-
renderer: ssrEntryFile,
|
|
83
|
-
rollupConfig: {
|
|
84
|
-
plugins: [virtualBundlePlugin(getSsrBundle())],
|
|
85
|
-
},
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const nitro = await createNitro(nitroConfig)
|
|
89
|
-
|
|
90
|
-
await buildNitroEnvironment(nitro, () => build(nitro))
|
|
91
|
-
|
|
92
|
-
// If the user has not set a prerender option, we need to set it to true
|
|
93
|
-
// if the pages array is not empty and has sub options requiring for prerendering
|
|
94
|
-
if (options.prerender?.enabled !== false) {
|
|
95
|
-
options.prerender = {
|
|
96
|
-
...options.prerender,
|
|
97
|
-
enabled: options.pages.some((d) =>
|
|
98
|
-
typeof d === 'string' ? false : !!d.prerender?.enabled,
|
|
99
|
-
),
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Setup the options for prerendering the SPA shell (i.e `src/routes/__root.tsx`)
|
|
104
|
-
if (options.spa?.enabled) {
|
|
105
|
-
options.prerender = {
|
|
106
|
-
...options.prerender,
|
|
107
|
-
enabled: true,
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const maskUrl = new URL(
|
|
111
|
-
options.spa.maskPath,
|
|
112
|
-
'http://localhost',
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
maskUrl.searchParams.set('__TSS_SHELL', 'true')
|
|
116
|
-
|
|
117
|
-
options.pages.push({
|
|
118
|
-
path: maskUrl.toString().replace('http://localhost', ''),
|
|
119
|
-
prerender: options.spa.prerender,
|
|
120
|
-
sitemap: {
|
|
121
|
-
exclude: true,
|
|
122
|
-
},
|
|
123
|
-
})
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Start prerendering!!!
|
|
127
|
-
if (options.prerender.enabled) {
|
|
128
|
-
await prerender({
|
|
129
|
-
options,
|
|
130
|
-
nitro,
|
|
131
|
-
builder,
|
|
132
|
-
})
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// if (nitroConfig.prerender?.routes?.length && options.sitemap) {
|
|
136
|
-
// console.log('Building Sitemap...')
|
|
137
|
-
// // sitemap needs to be built after all directories are built
|
|
138
|
-
// await buildSitemap({
|
|
139
|
-
// host: options.sitemap.host,
|
|
140
|
-
// routes: nitroConfig.prerender.routes,
|
|
141
|
-
// outputDir: resolve(options.root, 'dist/public'),
|
|
142
|
-
// })
|
|
143
|
-
// }
|
|
144
|
-
|
|
145
|
-
// console.log(
|
|
146
|
-
// `\n\n✅ Client and server bundles successfully built.`,
|
|
147
|
-
// )
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
]
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function virtualBundlePlugin(ssrBundle: Rollup.OutputBundle): Rollup.Plugin {
|
|
157
|
-
type VirtualModule = { code: string; map: string | null }
|
|
158
|
-
const _modules = new Map<string, VirtualModule>()
|
|
159
|
-
|
|
160
|
-
// group chunks and source maps
|
|
161
|
-
for (const [fileName, content] of Object.entries(ssrBundle)) {
|
|
162
|
-
if (content.type === 'chunk') {
|
|
163
|
-
const virtualModule: VirtualModule = {
|
|
164
|
-
code: content.code,
|
|
165
|
-
map: null,
|
|
166
|
-
}
|
|
167
|
-
const maybeMap = ssrBundle[`${fileName}.map`]
|
|
168
|
-
if (maybeMap && maybeMap.type === 'asset') {
|
|
169
|
-
virtualModule.map = maybeMap.source as string
|
|
170
|
-
}
|
|
171
|
-
_modules.set(fileName, virtualModule)
|
|
172
|
-
_modules.set(resolve(fileName), virtualModule)
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
name: 'virtual-bundle',
|
|
178
|
-
resolveId(id, importer) {
|
|
179
|
-
if (_modules.has(id)) {
|
|
180
|
-
return resolve(id)
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (importer) {
|
|
184
|
-
const resolved = resolve(dirname(importer), id)
|
|
185
|
-
if (_modules.has(resolved)) {
|
|
186
|
-
return resolved
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return null
|
|
190
|
-
},
|
|
191
|
-
load(id) {
|
|
192
|
-
const m = _modules.get(id)
|
|
193
|
-
if (!m) {
|
|
194
|
-
return null
|
|
195
|
-
}
|
|
196
|
-
return m
|
|
197
|
-
},
|
|
198
|
-
}
|
|
199
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|