@ossido-labs/ossido 0.1.4 → 0.1.6
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.
|
@@ -63,7 +63,10 @@ const normalizeConfig = (config) => {
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
dev: { criticalCss: config.dev?.criticalCss ?? true },
|
|
66
|
-
ssr: {
|
|
66
|
+
ssr: {
|
|
67
|
+
renderThreads: config.ssr?.renderThreads ?? null,
|
|
68
|
+
warmupRenders: config.ssr?.warmupRenders ?? null
|
|
69
|
+
},
|
|
67
70
|
output: config.output ?? "server",
|
|
68
71
|
viewTransitions: config.viewTransitions ?? false,
|
|
69
72
|
...config.env !== void 0 ? { env: Array.isArray(config.env) ? config.env : [config.env] } : {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-config.js","names":[],"sources":["../../../../src/build/config/normalize-config.ts"],"sourcesContent":["import path from 'node:path';\n\nimport type { AliasOptions } from 'vite';\n\nimport type { OssidoConfig } from '../../config';\n\nimport type { InternalOssidoConfig } from '../types';\n\nimport { DOT_OSSIDO_FOLDER_NAME, CONFIG_FOLDER_NAME } from '../constants';\n\n/**\n * Normalize vite alias option:\n * - If the path starts with `src` folder, transform it to absolute, prepending the ossido root folder\n * - If the path is absolute, remove the \".ossido/config/\" path from it\n * - Otherwise leave the path untouched\n */\nconst normalizeAliasPath = (aliasPath: string): string => {\n if (aliasPath.startsWith('./src') || aliasPath.startsWith('src')) {\n return path.join(process.cwd(), aliasPath);\n }\n\n if (path.isAbsolute(aliasPath)) {\n return aliasPath.replace(\n path.join(DOT_OSSIDO_FOLDER_NAME, CONFIG_FOLDER_NAME),\n '',\n );\n }\n\n return aliasPath;\n};\n\n/**\n * From a given vite aliasOptions apply {@link normalizeAliasPath} for each alias.\n *\n * The config is bundled by `vite` and emitted inside {@link DOT_OSSIDO_FOLDER_NAME}/{@link CONFIG_FOLDER_NAME}.\n * According to this, we have to ensure that the aliases provided by the user are updated to refer to the right folders.\n *\n * @see https://github.com/Valerioageno/tuono/pull/153#issuecomment-2508142877\n */\nconst normalizeViteAlias = (alias?: AliasOptions): AliasOptions | undefined => {\n if (!alias) return;\n\n if (Array.isArray(alias)) {\n return (alias as Extract<AliasOptions, ReadonlyArray<unknown>>).map(\n ({ replacement, ...userAliasDefinition }) => ({\n ...userAliasDefinition,\n replacement: normalizeAliasPath(replacement),\n }),\n );\n }\n\n if (typeof alias === 'object') {\n const normalizedAlias: AliasOptions = {};\n for (const [key, value] of Object.entries(alias)) {\n normalizedAlias[key] = normalizeAliasPath(value as string);\n }\n return normalizedAlias;\n }\n\n return alias;\n};\n\n/**\n * Wrapper function to normalize the ossido.config.ts file\n *\n * @warning Exported for unit test.\n * There is no easy way to mock the module export and change it in every test\n * and also testing the error\n */\nexport const normalizeConfig = (config: OssidoConfig): InternalOssidoConfig => {\n return {\n server: {\n host: config.server?.host ?? 'localhost',\n origin: config.server?.origin ?? null,\n port: config.server?.port ?? 3000,\n },\n vite: {\n alias: normalizeViteAlias(config.vite?.alias),\n css: config.vite?.css,\n optimizeDeps: config.vite?.optimizeDeps,\n plugins: config.vite?.plugins ?? [],\n },\n logging: {\n format: config.logging?.format ?? 'pretty',\n routeTree: config.logging?.routeTree ?? false,\n browser: {\n enabled: config.logging?.browser?.enabled ?? true,\n level: config.logging?.browser?.level ?? 'info',\n },\n },\n dev: {\n criticalCss: config.dev?.criticalCss ?? true,\n },\n ssr: {\n // `null` = auto: the Rust runtime uses the machine's available\n // parallelism (resolving it here would bake in the build machine's cores).\n renderThreads: config.ssr?.renderThreads ?? null,\n },\n output: config.output ?? 'server',\n viewTransitions: config.viewTransitions ?? false,\n // Coerce a single path to a one-element array so the Rust side always sees\n // `Option<Vec<String>>`. Absent stays absent (default cascade).\n ...(config.env !== undefined\n ? { env: Array.isArray(config.env) ? config.env : [config.env] }\n : {}),\n // Passed through untouched; interpreted by the Vite config (JS-only).\n ...(config.lightningcss !== undefined\n ? { lightningcss: config.lightningcss }\n : {}),\n // Carried through as-is (its `prebuild`/`postbuild` are functions, so they\n // are only reachable via `loadConfig`, never the JSON config). Spread\n // conditionally so an absent `build` isn't materialised as `undefined`.\n ...(config.build ? { build: config.build } : {}),\n };\n};\n"],"mappings":";;;;;;;;;;AAgBA,MAAM,sBAAsB,cAA8B;CACxD,IAAI,UAAU,WAAW,OAAO,KAAK,UAAU,WAAW,KAAK,GAC7D,OAAO,KAAK,KAAK,QAAQ,IAAI,GAAG,SAAS;CAG3C,IAAI,KAAK,WAAW,SAAS,GAC3B,OAAO,UAAU,QACf,KAAK,KAAK,wBAAwB,kBAAkB,GACpD,EACF;CAGF,OAAO;AACT;;;;;;;;;AAUA,MAAM,sBAAsB,UAAmD;CAC7E,IAAI,CAAC,OAAO;CAEZ,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAQ,MAAwD,KAC7D,EAAE,aAAa,GAAG,2BAA2B;EAC5C,GAAG;EACH,aAAa,mBAAmB,WAAW;CAC7C,EACF;CAGF,IAAI,OAAO,UAAU,UAAU;EAC7B,MAAM,kBAAgC,CAAC;EACvC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,GAC7C,gBAAgB,OAAO,mBAAmB,KAAe;EAE3D,OAAO;CACT;CAEA,OAAO;AACT;;;;;;;;AASA,MAAa,mBAAmB,WAA+C;CAC7E,OAAO;EACL,QAAQ;GACN,MAAM,OAAO,QAAQ,QAAQ;GAC7B,QAAQ,OAAO,QAAQ,UAAU;GACjC,MAAM,OAAO,QAAQ,QAAQ;EAC/B;EACA,MAAM;GACJ,OAAO,mBAAmB,OAAO,MAAM,KAAK;GAC5C,KAAK,OAAO,MAAM;GAClB,cAAc,OAAO,MAAM;GAC3B,SAAS,OAAO,MAAM,WAAW,CAAC;EACpC;EACA,SAAS;GACP,QAAQ,OAAO,SAAS,UAAU;GAClC,WAAW,OAAO,SAAS,aAAa;GACxC,SAAS;IACP,SAAS,OAAO,SAAS,SAAS,WAAW;IAC7C,OAAO,OAAO,SAAS,SAAS,SAAS;GAC3C;EACF;EACA,KAAK,EACH,aAAa,OAAO,KAAK,eAAe,KAC1C;EACA,KAAK,
|
|
1
|
+
{"version":3,"file":"normalize-config.js","names":[],"sources":["../../../../src/build/config/normalize-config.ts"],"sourcesContent":["import path from 'node:path';\n\nimport type { AliasOptions } from 'vite';\n\nimport type { OssidoConfig } from '../../config';\n\nimport type { InternalOssidoConfig } from '../types';\n\nimport { DOT_OSSIDO_FOLDER_NAME, CONFIG_FOLDER_NAME } from '../constants';\n\n/**\n * Normalize vite alias option:\n * - If the path starts with `src` folder, transform it to absolute, prepending the ossido root folder\n * - If the path is absolute, remove the \".ossido/config/\" path from it\n * - Otherwise leave the path untouched\n */\nconst normalizeAliasPath = (aliasPath: string): string => {\n if (aliasPath.startsWith('./src') || aliasPath.startsWith('src')) {\n return path.join(process.cwd(), aliasPath);\n }\n\n if (path.isAbsolute(aliasPath)) {\n return aliasPath.replace(\n path.join(DOT_OSSIDO_FOLDER_NAME, CONFIG_FOLDER_NAME),\n '',\n );\n }\n\n return aliasPath;\n};\n\n/**\n * From a given vite aliasOptions apply {@link normalizeAliasPath} for each alias.\n *\n * The config is bundled by `vite` and emitted inside {@link DOT_OSSIDO_FOLDER_NAME}/{@link CONFIG_FOLDER_NAME}.\n * According to this, we have to ensure that the aliases provided by the user are updated to refer to the right folders.\n *\n * @see https://github.com/Valerioageno/tuono/pull/153#issuecomment-2508142877\n */\nconst normalizeViteAlias = (alias?: AliasOptions): AliasOptions | undefined => {\n if (!alias) return;\n\n if (Array.isArray(alias)) {\n return (alias as Extract<AliasOptions, ReadonlyArray<unknown>>).map(\n ({ replacement, ...userAliasDefinition }) => ({\n ...userAliasDefinition,\n replacement: normalizeAliasPath(replacement),\n }),\n );\n }\n\n if (typeof alias === 'object') {\n const normalizedAlias: AliasOptions = {};\n for (const [key, value] of Object.entries(alias)) {\n normalizedAlias[key] = normalizeAliasPath(value as string);\n }\n return normalizedAlias;\n }\n\n return alias;\n};\n\n/**\n * Wrapper function to normalize the ossido.config.ts file\n *\n * @warning Exported for unit test.\n * There is no easy way to mock the module export and change it in every test\n * and also testing the error\n */\nexport const normalizeConfig = (config: OssidoConfig): InternalOssidoConfig => {\n return {\n server: {\n host: config.server?.host ?? 'localhost',\n origin: config.server?.origin ?? null,\n port: config.server?.port ?? 3000,\n },\n vite: {\n alias: normalizeViteAlias(config.vite?.alias),\n css: config.vite?.css,\n optimizeDeps: config.vite?.optimizeDeps,\n plugins: config.vite?.plugins ?? [],\n },\n logging: {\n format: config.logging?.format ?? 'pretty',\n routeTree: config.logging?.routeTree ?? false,\n browser: {\n enabled: config.logging?.browser?.enabled ?? true,\n level: config.logging?.browser?.level ?? 'info',\n },\n },\n dev: {\n criticalCss: config.dev?.criticalCss ?? true,\n },\n ssr: {\n // `null` = auto: the Rust runtime uses the machine's available\n // parallelism (resolving it here would bake in the build machine's cores).\n renderThreads: config.ssr?.renderThreads ?? null,\n // `null` = runtime default (3 warm-up renders per pool thread).\n warmupRenders: config.ssr?.warmupRenders ?? null,\n },\n output: config.output ?? 'server',\n viewTransitions: config.viewTransitions ?? false,\n // Coerce a single path to a one-element array so the Rust side always sees\n // `Option<Vec<String>>`. Absent stays absent (default cascade).\n ...(config.env !== undefined\n ? { env: Array.isArray(config.env) ? config.env : [config.env] }\n : {}),\n // Passed through untouched; interpreted by the Vite config (JS-only).\n ...(config.lightningcss !== undefined\n ? { lightningcss: config.lightningcss }\n : {}),\n // Carried through as-is (its `prebuild`/`postbuild` are functions, so they\n // are only reachable via `loadConfig`, never the JSON config). Spread\n // conditionally so an absent `build` isn't materialised as `undefined`.\n ...(config.build ? { build: config.build } : {}),\n };\n};\n"],"mappings":";;;;;;;;;;AAgBA,MAAM,sBAAsB,cAA8B;CACxD,IAAI,UAAU,WAAW,OAAO,KAAK,UAAU,WAAW,KAAK,GAC7D,OAAO,KAAK,KAAK,QAAQ,IAAI,GAAG,SAAS;CAG3C,IAAI,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,OAAO,GAAG,EAAE,IAC7D,CAAC;EAEL,GAAI,OAAO,iBAAiB,SACxB,EAAE,cAAc,OAAO,aAAa,IACpC,CAAC;EAIL,GAAI,OAAO,QAAQ,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;CAChD;AACF"}
|
|
@@ -11,5 +11,5 @@ declare const buildConfig: () => void;
|
|
|
11
11
|
* deploy `out/static`, server builds `out`. `postbuild` gets the emitted-file
|
|
12
12
|
* manifest; `prebuild` runs before anything is emitted, so its manifest is empty.
|
|
13
13
|
*/
|
|
14
|
-
declare const runBuildHook: (name:
|
|
14
|
+
declare const runBuildHook: (name: 'prebuild' | 'postbuild') => void;
|
|
15
15
|
export { buildProd, buildConfig, developmentCSRWatch, developmentSSRBundle, runBuildHook, };
|
|
@@ -14,10 +14,12 @@ export interface InternalOssidoConfigDev {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Fully-resolved SSR config. `renderThreads` is `null` when unset — the Rust
|
|
17
|
-
* runtime then defaults it to the machine's available parallelism.
|
|
17
|
+
* runtime then defaults it to the machine's available parallelism. Likewise
|
|
18
|
+
* `warmupRenders` is `null` when unset (runtime default: 3).
|
|
18
19
|
*/
|
|
19
20
|
export interface InternalOssidoConfigSsr {
|
|
20
21
|
renderThreads: number | null;
|
|
22
|
+
warmupRenders: number | null;
|
|
21
23
|
}
|
|
22
24
|
export interface InternalOssidoConfig extends Omit<OssidoConfig, 'server' | 'logging' | 'dev' | 'ssr' | 'output' | 'viewTransitions' | 'env'> {
|
|
23
25
|
server: OssidoConfigServer;
|
|
@@ -149,6 +149,16 @@ export interface OssidoConfigSsr {
|
|
|
149
149
|
* runtime with the `OSSIDO_SSR_THREADS` environment variable.
|
|
150
150
|
*/
|
|
151
151
|
renderThreads?: number;
|
|
152
|
+
/**
|
|
153
|
+
* Number of throwaway warm-up renders each render-pool thread performs at
|
|
154
|
+
* server start, before serving traffic. Repeated renders let V8's tiering
|
|
155
|
+
* compilers (Sparkplug → Maglev → TurboFan) optimise the hot render path, so
|
|
156
|
+
* the first real requests hit already-optimised code instead of paying the
|
|
157
|
+
* interpreter-speed first render. Defaults to `3`; set `0` to disable.
|
|
158
|
+
* Overridable at runtime with the `OSSIDO_SSR_WARMUP_RENDERS` environment
|
|
159
|
+
* variable.
|
|
160
|
+
*/
|
|
161
|
+
warmupRenders?: number;
|
|
152
162
|
}
|
|
153
163
|
/** Development-only tweaks. */
|
|
154
164
|
export interface OssidoConfigDev {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossido-labs/ossido",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -87,9 +87,9 @@
|
|
|
87
87
|
"browserslist": "^4.28.8",
|
|
88
88
|
"fast-text-encoding": "^1.0.6",
|
|
89
89
|
"lightningcss": "^1.33.0",
|
|
90
|
-
"@ossido-labs/ossido-react-vite-plugin": "0.1.
|
|
91
|
-
"@ossido-labs/ossido-router": "0.1.
|
|
92
|
-
"@ossido-labs/ossido-ui": "0.1.
|
|
90
|
+
"@ossido-labs/ossido-react-vite-plugin": "0.1.6",
|
|
91
|
+
"@ossido-labs/ossido-router": "0.1.6",
|
|
92
|
+
"@ossido-labs/ossido-ui": "0.1.6",
|
|
93
93
|
"url-search-params-polyfill": "^8.2.5",
|
|
94
94
|
"web-streams-polyfill": "^4.0.0"
|
|
95
95
|
},
|