@octanejs/tanstack-start 0.1.27 → 0.1.29
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/README.md +19 -1
- package/THIRD_PARTY_NOTICES.md +6 -5
- package/package.json +18 -6
- package/src/client-only-server-strip-loader.js +7 -0
- package/src/client-only-server-strip.js +34 -25
- package/src/internal/README.md +7 -7
- package/src/internal/start-plugin-core/rsbuild/import-protection.d.ts +27 -0
- package/src/internal/start-plugin-core/rsbuild/import-protection.js +1193 -0
- package/src/internal/start-plugin-core/rsbuild/index.d.ts +9 -0
- package/src/internal/start-plugin-core/rsbuild/index.js +3 -0
- package/src/internal/start-plugin-core/rsbuild/normalized-client-build.d.ts +20 -0
- package/src/internal/start-plugin-core/rsbuild/normalized-client-build.js +261 -0
- package/src/internal/start-plugin-core/rsbuild/planning.d.ts +56 -0
- package/src/internal/start-plugin-core/rsbuild/planning.js +173 -0
- package/src/internal/start-plugin-core/rsbuild/plugin.d.ts +7 -0
- package/src/internal/start-plugin-core/rsbuild/plugin.js +504 -0
- package/src/internal/start-plugin-core/rsbuild/post-build.d.ts +10 -0
- package/src/internal/start-plugin-core/rsbuild/post-build.js +59 -0
- package/src/internal/start-plugin-core/rsbuild/schema.d.ts +2441 -0
- package/src/internal/start-plugin-core/rsbuild/schema.js +28 -0
- package/src/internal/start-plugin-core/rsbuild/server-middleware.d.ts +32 -0
- package/src/internal/start-plugin-core/rsbuild/server-middleware.js +139 -0
- package/src/internal/start-plugin-core/rsbuild/start-compiler-host.d.ts +36 -0
- package/src/internal/start-plugin-core/rsbuild/start-compiler-host.js +322 -0
- package/src/internal/start-plugin-core/rsbuild/start-compiler-metadata-loader.d.ts +10 -0
- package/src/internal/start-plugin-core/rsbuild/start-compiler-metadata-loader.js +12 -0
- package/src/internal/start-plugin-core/rsbuild/start-compiler-metadata.d.ts +14 -0
- package/src/internal/start-plugin-core/rsbuild/start-compiler-metadata.js +5 -0
- package/src/internal/start-plugin-core/rsbuild/start-router-plugin.d.ts +19 -0
- package/src/internal/start-plugin-core/rsbuild/start-router-plugin.js +69 -0
- package/src/internal/start-plugin-core/rsbuild/swc-rsc.d.ts +17 -0
- package/src/internal/start-plugin-core/rsbuild/swc-rsc.js +118 -0
- package/src/internal/start-plugin-core/rsbuild/types.d.ts +17 -0
- package/src/internal/start-plugin-core/rsbuild/types.js +0 -0
- package/src/internal/start-plugin-core/rsbuild/virtual-modules.d.ts +60 -0
- package/src/internal/start-plugin-core/rsbuild/virtual-modules.js +359 -0
- package/src/plugin-rsbuild.d.ts +25 -0
- package/src/plugin-rsbuild.js +79 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import {
|
|
3
|
+
RSBUILD_ENVIRONMENT_NAMES,
|
|
4
|
+
tanStackStartRsbuild,
|
|
5
|
+
} from '#tanstack-start/plugin-core/rsbuild';
|
|
6
|
+
import { OctaneRspackPlugin } from '@octanejs/rspack-plugin';
|
|
7
|
+
import { octaneRouteGeneratorPlugin } from '@octanejs/tanstack-router/generator-plugin';
|
|
8
|
+
import { octaneStartDefaultEntryPaths } from './default-entry-paths.js';
|
|
9
|
+
import { validateOctaneCompilerOptions } from './validate-options.js';
|
|
10
|
+
|
|
11
|
+
const clientOnlyStripLoaderPath = fileURLToPath(
|
|
12
|
+
new URL('./client-only-server-strip-loader.js', import.meta.url),
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export function tanstackStart(options) {
|
|
16
|
+
const { octane: octaneOptions, ...startOptions } = options ?? {};
|
|
17
|
+
validateOctaneCompilerOptions(octaneOptions);
|
|
18
|
+
|
|
19
|
+
const corePlugin = tanStackStartRsbuild(
|
|
20
|
+
{
|
|
21
|
+
framework: 'octane',
|
|
22
|
+
defaultEntryPaths: octaneStartDefaultEntryPaths,
|
|
23
|
+
providerEnvironmentName: RSBUILD_ENVIRONMENT_NAMES.server,
|
|
24
|
+
ssrIsProvider: true,
|
|
25
|
+
routerGeneratorPlugins: [octaneRouteGeneratorPlugin()],
|
|
26
|
+
},
|
|
27
|
+
startOptions,
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
name: 'octanejs-tanstack-start',
|
|
32
|
+
enforce: 'pre',
|
|
33
|
+
async setup(api) {
|
|
34
|
+
const resolvedOctaneOptions = octaneOptions ? { ...octaneOptions } : {};
|
|
35
|
+
if (resolvedOctaneOptions.profile === undefined && resolvedOctaneOptions.devtools === true) {
|
|
36
|
+
resolvedOctaneOptions.profile = api.context.action !== 'build';
|
|
37
|
+
}
|
|
38
|
+
delete resolvedOctaneOptions.devtools;
|
|
39
|
+
|
|
40
|
+
api.modifyRspackConfig((config, { environment }) => {
|
|
41
|
+
const octaneEnvironment =
|
|
42
|
+
environment.name === RSBUILD_ENVIRONMENT_NAMES.client ? 'client' : 'server';
|
|
43
|
+
config.plugins ??= [];
|
|
44
|
+
config.plugins.push(
|
|
45
|
+
new OctaneRspackPlugin({
|
|
46
|
+
...resolvedOctaneOptions,
|
|
47
|
+
root: api.context.rootPath,
|
|
48
|
+
environment: octaneEnvironment,
|
|
49
|
+
transpile: false,
|
|
50
|
+
...(resolvedOctaneOptions.profile === undefined
|
|
51
|
+
? null
|
|
52
|
+
: {
|
|
53
|
+
profile: octaneEnvironment === 'client' && resolvedOctaneOptions.profile,
|
|
54
|
+
}),
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
if (octaneEnvironment === 'server') {
|
|
58
|
+
config.plugins.push({
|
|
59
|
+
name: 'octanejs-tanstack-start:client-only-server-strip',
|
|
60
|
+
apply(compiler) {
|
|
61
|
+
compiler.options.module ??= {};
|
|
62
|
+
compiler.options.module.rules ??= [];
|
|
63
|
+
compiler.options.module.rules.push({
|
|
64
|
+
test: /\.tsrx$/,
|
|
65
|
+
enforce: 'pre',
|
|
66
|
+
use: [{ loader: clientOnlyStripLoaderPath }],
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return config;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Register Octane's transform before Start's route analysis and
|
|
75
|
+
// environment transforms.
|
|
76
|
+
await corePlugin.setup(api);
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|