@blinkk/root 2.5.13 → 3.0.1-alpha.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/dist/chunk-3OVMCKPA.js +416 -0
- package/dist/chunk-3OVMCKPA.js.map +1 -0
- package/dist/{chunk-3KGEENDW.js → chunk-6P3B7ZXL.js} +16 -17
- package/dist/chunk-6P3B7ZXL.js.map +1 -0
- package/dist/chunk-CY5IQ4AQ.js +73 -0
- package/dist/chunk-CY5IQ4AQ.js.map +1 -0
- package/dist/{chunk-ISNB54FM.js → chunk-EBE4O463.js} +30 -19
- package/dist/chunk-EBE4O463.js.map +1 -0
- package/dist/{chunk-EWCJOOZN.js → chunk-G7OKXRD3.js} +34 -32
- package/dist/chunk-G7OKXRD3.js.map +1 -0
- package/dist/cli.d.ts +3 -1
- package/dist/cli.js +3 -3
- package/dist/core.d.ts +4 -2
- package/dist/core.js +4 -4
- package/dist/core.js.map +1 -1
- package/dist/functions.js +3 -3
- package/dist/jsx/jsx-dev-runtime.d.ts +1 -0
- package/dist/jsx/jsx-dev-runtime.js +11 -0
- package/dist/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx/jsx-runtime.d.ts +1 -0
- package/dist/jsx/jsx-runtime.js +19 -0
- package/dist/jsx/jsx-runtime.js.map +1 -0
- package/dist/jsx-C8BaDh-4.d.ts +14 -0
- package/dist/jsx-dev-runtime-DUJrvx5P.d.ts +677 -0
- package/dist/jsx.d.ts +2 -0
- package/dist/jsx.js +23 -0
- package/dist/jsx.js.map +1 -0
- package/dist/middleware.d.ts +4 -2
- package/dist/node.d.ts +3 -1
- package/dist/node.js +1 -1
- package/dist/render.d.ts +3 -1
- package/dist/render.js +45 -10
- package/dist/render.js.map +1 -1
- package/dist/{types-BXpvdaTX.d.ts → types-BstdV3Rj.d.ts} +31 -1
- package/package.json +21 -8
- package/dist/chunk-3KGEENDW.js.map +0 -1
- package/dist/chunk-EWCJOOZN.js.map +0 -1
- package/dist/chunk-ISNB54FM.js.map +0 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// src/jsx/jsx-runtime.ts
|
|
2
|
+
var options = {};
|
|
3
|
+
function Fragment(props) {
|
|
4
|
+
return props.children;
|
|
5
|
+
}
|
|
6
|
+
function jsx(type, props, key) {
|
|
7
|
+
const resolvedKey = key !== void 0 ? key : props.key ?? null;
|
|
8
|
+
const vnode = {
|
|
9
|
+
type,
|
|
10
|
+
props,
|
|
11
|
+
key: resolvedKey
|
|
12
|
+
};
|
|
13
|
+
if (props.key !== void 0) {
|
|
14
|
+
const { key: _, ...rest } = props;
|
|
15
|
+
vnode.props = rest;
|
|
16
|
+
}
|
|
17
|
+
if (options.vnode) {
|
|
18
|
+
options.vnode(vnode);
|
|
19
|
+
}
|
|
20
|
+
return vnode;
|
|
21
|
+
}
|
|
22
|
+
function createElement(type, props, ...children) {
|
|
23
|
+
const normalizedProps = { ...props || {} };
|
|
24
|
+
if (children.length === 1) {
|
|
25
|
+
normalizedProps.children = children[0];
|
|
26
|
+
} else if (children.length > 1) {
|
|
27
|
+
normalizedProps.children = children;
|
|
28
|
+
}
|
|
29
|
+
const vnode = {
|
|
30
|
+
type,
|
|
31
|
+
props: normalizedProps,
|
|
32
|
+
key: normalizedProps.key ?? null
|
|
33
|
+
};
|
|
34
|
+
if (normalizedProps.key !== void 0) {
|
|
35
|
+
delete normalizedProps.key;
|
|
36
|
+
}
|
|
37
|
+
if (options.vnode) {
|
|
38
|
+
options.vnode(vnode);
|
|
39
|
+
}
|
|
40
|
+
return vnode;
|
|
41
|
+
}
|
|
42
|
+
function createContext(defaultValue) {
|
|
43
|
+
const ctx = {
|
|
44
|
+
_defaultValue: defaultValue,
|
|
45
|
+
_stack: [],
|
|
46
|
+
Provider: null
|
|
47
|
+
};
|
|
48
|
+
const Provider = () => {
|
|
49
|
+
return null;
|
|
50
|
+
};
|
|
51
|
+
Provider.displayName = "ContextProvider";
|
|
52
|
+
Provider._isProvider = true;
|
|
53
|
+
Provider._context = ctx;
|
|
54
|
+
ctx.Provider = Provider;
|
|
55
|
+
return ctx;
|
|
56
|
+
}
|
|
57
|
+
function useContext(context) {
|
|
58
|
+
const stack = context._stack;
|
|
59
|
+
if (stack.length > 0) {
|
|
60
|
+
return stack[stack.length - 1];
|
|
61
|
+
}
|
|
62
|
+
return context._defaultValue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
options,
|
|
67
|
+
Fragment,
|
|
68
|
+
jsx,
|
|
69
|
+
createElement,
|
|
70
|
+
createContext,
|
|
71
|
+
useContext
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=chunk-CY5IQ4AQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/jsx/jsx-runtime.ts"],"sourcesContent":["/**\n * @module jsx-runtime\n *\n * Server-side JSX runtime for Root.js. Replaces Preact as the JSX renderer\n * for server-side rendering (SSR/SSG). This module provides the automatic\n * JSX transform entry point (`jsxImportSource`).\n *\n * Supports:\n * - Automatic JSX transform (jsx, jsxs, Fragment)\n * - Classic JSX transform (createElement / h)\n * - Context API (createContext, useContext)\n * - Server-side renderToString\n */\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport type Key = string | number | null;\n\n/**\n * A virtual DOM node representing an element, component, or fragment.\n */\nexport interface VNode<P = Record<string, unknown>> {\n type:\n | string\n | FunctionalComponent<P>\n | typeof Fragment\n | (new (...args: any[]) => any);\n props: P;\n key: Key;\n}\n\n/**\n * Valid children types for JSX elements.\n */\nexport type ComponentChildren =\n | VNode<any>\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | ComponentChildren[];\n\nexport type ComponentChild = ComponentChildren;\n\n/**\n * A function component that receives props and returns a VNode or null.\n */\nexport interface FunctionalComponent<P = Record<string, unknown>> {\n (props: P): VNode<any> | null;\n displayName?: string;\n /** @internal Marks this component as a context Provider. */\n _isProvider?: boolean;\n /** @internal Reference to the context object for Provider components. */\n _context?: Context<any>;\n}\n\n/**\n * Generic component type (function components only for SSR).\n */\nexport type ComponentType<P = Record<string, unknown>> = FunctionalComponent<P>;\n\n// =============================================================================\n// Options (vnode lifecycle hook)\n// =============================================================================\n\n/**\n * Global options object. The `vnode` callback is invoked for every VNode\n * created via `jsx()`, `jsxs()`, or `createElement()`. This is used by the\n * renderer to inject nonce values into script/style tags.\n */\nexport const options: {vnode?: (vnode: VNode<any>) => void} = {};\n\n// =============================================================================\n// Fragment\n// =============================================================================\n\n/**\n * Fragment component. Renders its children without a wrapper DOM element.\n * Used as `<>...</>` or `<Fragment>...</Fragment>` in JSX.\n */\nexport function Fragment(props: {children?: ComponentChildren}): any {\n return props.children;\n}\n\n// =============================================================================\n// JSX Automatic Runtime (jsx / jsxs)\n// =============================================================================\n\n/**\n * Creates a VNode. Used by the automatic JSX transform for elements with\n * a single child or no children.\n */\nexport function jsx(\n type: string | FunctionalComponent<any> | typeof Fragment,\n props: Record<string, any>,\n key?: Key\n): VNode {\n const resolvedKey = key !== undefined ? key : props.key ?? null;\n const vnode: VNode = {\n type,\n props,\n key: resolvedKey,\n };\n\n // Strip `key` from props (it's stored on the VNode directly).\n if (props.key !== undefined) {\n const {key: _, ...rest} = props;\n vnode.props = rest;\n }\n\n if (options.vnode) {\n options.vnode(vnode);\n }\n\n return vnode;\n}\n\n/**\n * Creates a VNode with static children. Used by the automatic JSX transform\n * for elements with multiple children. Identical to `jsx()` for SSR since\n * we don't need to diff children.\n */\nexport {jsx as jsxs};\n\n// =============================================================================\n// Classic Runtime (createElement / h)\n// =============================================================================\n\n/**\n * Creates a VNode. Compatible with the classic `React.createElement` API.\n *\n * ```ts\n * createElement('div', {className: 'foo'}, 'Hello', ' ', 'World');\n * ```\n */\nexport function createElement(\n type: string | FunctionalComponent<any> | typeof Fragment,\n props?: Record<string, any> | null,\n ...children: any[]\n): VNode {\n const normalizedProps: Record<string, any> = {...(props || {})};\n\n if (children.length === 1) {\n normalizedProps.children = children[0];\n } else if (children.length > 1) {\n normalizedProps.children = children;\n }\n\n const vnode: VNode = {\n type,\n props: normalizedProps,\n key: normalizedProps.key ?? null,\n };\n\n if (normalizedProps.key !== undefined) {\n delete normalizedProps.key;\n }\n\n if (options.vnode) {\n options.vnode(vnode);\n }\n\n return vnode;\n}\n\nexport {createElement as h};\n\n// =============================================================================\n// Context API\n// =============================================================================\n\n/**\n * A context object created by `createContext()`. Provides a `Provider`\n * component and can be read via `useContext()`.\n */\nexport interface Context<T> {\n /** @internal Default value for this context. */\n _defaultValue: T;\n /** @internal Stack of provided values (managed by renderToString). */\n _stack: T[];\n /** Provider component that supplies a context value to descendants. */\n Provider: FunctionalComponent<{value: T; children?: ComponentChildren}>;\n}\n\n/**\n * Creates a new context with an optional default value. Returns a context\n * object with a `Provider` component.\n *\n * ```ts\n * const ThemeContext = createContext('light');\n *\n * // In a parent component:\n * <ThemeContext.Provider value=\"dark\">\n * <App />\n * </ThemeContext.Provider>\n *\n * // In a child component:\n * const theme = useContext(ThemeContext);\n * ```\n */\nexport function createContext<T>(defaultValue: T): Context<T> {\n const ctx: Context<T> = {\n _defaultValue: defaultValue,\n _stack: [],\n Provider: null as any,\n };\n\n const Provider: FunctionalComponent<{\n value: T;\n children?: ComponentChildren;\n }> = () => {\n // Provider rendering is handled specially by renderToString, which\n // pushes/pops the context value around rendering children. This function\n // body is never actually called during normal SSR rendering.\n return null;\n };\n Provider.displayName = 'ContextProvider';\n Provider._isProvider = true;\n Provider._context = ctx;\n ctx.Provider = Provider;\n\n return ctx;\n}\n\n/**\n * Reads the current value of a context. Must be called during the render\n * of a function component that is a descendant of a matching Provider.\n * Returns the default value if no Provider is found.\n *\n * ```ts\n * const theme = useContext(ThemeContext);\n * ```\n */\nexport function useContext<T>(context: Context<T>): T {\n const stack = context._stack;\n if (stack.length > 0) {\n return stack[stack.length - 1];\n }\n return context._defaultValue;\n}\n\n// Re-export JSX namespace for the automatic transform.\n// TypeScript resolves JSX types from `{jsxImportSource}/jsx-runtime`.\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AAG;AACpB,WAAO,MAAM,MAAM,SAAS,CAAC;AAAA,EAC/B;AACA,SAAO,QAAQ;AACjB;","names":[]}
|
|
@@ -275,6 +275,33 @@ function esbuildExternalsPlugin(options) {
|
|
|
275
275
|
|
|
276
276
|
// src/node/vite.ts
|
|
277
277
|
import { createServer } from "vite";
|
|
278
|
+
|
|
279
|
+
// src/node/vite-plugin-preact-alias.ts
|
|
280
|
+
function preactToRootJsxPlugin() {
|
|
281
|
+
return {
|
|
282
|
+
name: "root:preact-to-jsx",
|
|
283
|
+
config() {
|
|
284
|
+
return {
|
|
285
|
+
resolve: {
|
|
286
|
+
alias: [
|
|
287
|
+
{ find: /^preact\/hooks$/, replacement: "@blinkk/root/jsx" },
|
|
288
|
+
{
|
|
289
|
+
find: /^preact\/jsx-runtime$/,
|
|
290
|
+
replacement: "@blinkk/root/jsx/jsx-runtime"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
find: /^preact\/jsx-dev-runtime$/,
|
|
294
|
+
replacement: "@blinkk/root/jsx/jsx-dev-runtime"
|
|
295
|
+
},
|
|
296
|
+
{ find: /^preact$/, replacement: "@blinkk/root/jsx" }
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// src/node/vite.ts
|
|
278
305
|
async function createViteServer(rootConfig, options) {
|
|
279
306
|
const rootDir = rootConfig.rootDir;
|
|
280
307
|
const viteConfig = rootConfig.vite || {};
|
|
@@ -299,19 +326,6 @@ async function createViteServer(rootConfig, options) {
|
|
|
299
326
|
},
|
|
300
327
|
appType: "custom",
|
|
301
328
|
optimizeDeps: {
|
|
302
|
-
// As of vite v5 / esbuild v19, experimentalDecorators need to be
|
|
303
|
-
// explicitly set, and for some reason this option isn't read from the
|
|
304
|
-
// project's tsconfig.json file by default.
|
|
305
|
-
// See: https://vitejs.dev/blog/announcing-vite5
|
|
306
|
-
esbuildOptions: {
|
|
307
|
-
tsconfigRaw: {
|
|
308
|
-
compilerOptions: {
|
|
309
|
-
target: "esnext",
|
|
310
|
-
experimentalDecorators: true,
|
|
311
|
-
useDefineForClassFields: false
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
329
|
...viteConfig.optimizeDeps || {},
|
|
316
330
|
include: [
|
|
317
331
|
...options?.optimizeDeps || [],
|
|
@@ -323,13 +337,9 @@ async function createViteServer(rootConfig, options) {
|
|
|
323
337
|
...viteConfig.ssr || {},
|
|
324
338
|
noExternal: ["@blinkk/root", "@blinkk/root-cms/richtext"]
|
|
325
339
|
},
|
|
326
|
-
esbuild: {
|
|
327
|
-
...viteConfig.esbuild || {},
|
|
328
|
-
jsx: "automatic",
|
|
329
|
-
jsxImportSource: "preact"
|
|
330
|
-
},
|
|
331
340
|
plugins: [
|
|
332
341
|
hmrSSRReload(),
|
|
342
|
+
...rootConfig.jsxRenderer?.mode ? [preactToRootJsxPlugin()] : [],
|
|
333
343
|
...viteConfig.plugins || [],
|
|
334
344
|
...getVitePlugins(rootConfig.plugins || [])
|
|
335
345
|
]
|
|
@@ -400,7 +410,8 @@ export {
|
|
|
400
410
|
loadRootConfigWithDeps,
|
|
401
411
|
bundleRootConfig,
|
|
402
412
|
loadBundledConfig,
|
|
413
|
+
preactToRootJsxPlugin,
|
|
403
414
|
createViteServer,
|
|
404
415
|
viteSsrLoadModule
|
|
405
416
|
};
|
|
406
|
-
//# sourceMappingURL=chunk-
|
|
417
|
+
//# sourceMappingURL=chunk-EBE4O463.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node/monorepo.ts","../src/utils/fsutils.ts","../src/node/load-config.ts","../src/node/vite.ts","../src/node/vite-plugin-preact-alias.ts"],"sourcesContent":["import path from 'node:path';\nimport {getWorkspaces, getWorkspaceRoot, PackageInfo} from 'workspace-tools';\nimport {fileExistsSync, loadJsonSync} from '../utils/fsutils.js';\n\ninterface WorkspacePackage {\n name: string;\n path: string;\n packageJson: PackageInfo;\n}\n\nexport function loadPackageJson(filepath: string): PackageInfo | null {\n if (!fileExistsSync(filepath)) {\n return null;\n }\n return loadJsonSync(filepath);\n}\n\n/**\n * Returns a map of all packages in the monorepo and the corresponding\n * package.json path.\n */\nfunction getMonorepoPackages(\n rootDir: string\n): Record<string, WorkspacePackage> {\n const monorepoRoot = getWorkspaceRoot(rootDir);\n if (!monorepoRoot) {\n return {};\n }\n\n const workspaces = getWorkspaces(monorepoRoot);\n const packages: Record<string, WorkspacePackage> = {};\n workspaces.forEach((workspaceInfo) => {\n packages[workspaceInfo.name] = workspaceInfo;\n });\n return packages;\n}\n\n/**\n * Returns the top-level monorepo package's deps, if any.\n */\nexport function getMonorepoPackageDeps(\n rootDir: string\n): Record<string, string> {\n const monorepoRoot = getWorkspaceRoot(rootDir);\n if (!monorepoRoot) {\n return {};\n }\n\n const packageJsonPath = path.join(monorepoRoot, 'package.json');\n const packageJson = loadPackageJson(packageJsonPath);\n return packageJson?.dependencies || {};\n}\n\n/**\n * Flattens package.json deps from the root project dir, taking into account any\n * deps from the monorepo root as well as any `workspace:` deps from within the\n * monorepo.\n */\nexport function flattenPackageDepsFromMonorepo(\n rootDir: string,\n options?: {ignore?: Set<string>}\n): Record<string, string> {\n const packageJsonPath = path.resolve(rootDir, 'package.json');\n const packageJson = loadPackageJson(packageJsonPath);\n const monorepoDeps = getMonorepoPackageDeps(rootDir);\n\n // Flatten `peerDependencies` and `dependencies`.\n const projectDeps = {\n ...packageJson?.peerDependencies,\n ...packageJson?.dependencies,\n };\n\n const allDeps: Record<string, string> = {};\n const workspacePackages = getMonorepoPackages(rootDir);\n const ignore = options?.ignore || new Set();\n Object.entries(projectDeps).forEach(([depName, depVersion]) => {\n if (\n depName.startsWith('@blinkk/root') &&\n depVersion.startsWith('workspace:')\n ) {\n const packageInfo = workspacePackages[depName];\n if (packageInfo) {\n allDeps[depName] = packageInfo.packageJson.version;\n }\n } else if (depVersion.startsWith('workspace:')) {\n // For internal packages within the workspace, recursively collect the\n // deps from those packages.\n if (ignore.has(depName)) {\n return;\n }\n ignore.add(depName);\n const packageInfo = workspacePackages[depName];\n if (packageInfo) {\n const workspacePackageDir = packageInfo.path;\n const deps = flattenPackageDepsFromMonorepo(workspacePackageDir, {\n ignore: ignore,\n });\n for (const key in deps) {\n const currentValue = allDeps[key];\n if (\n deps[key] &&\n deps[key] !== '*' &&\n (!currentValue || currentValue === '*')\n ) {\n allDeps[key] = deps[key];\n }\n }\n }\n } else if (depVersion === '*' && monorepoDeps[depName]) {\n // For any dependencies using a wildcard version `*`, if the top-level\n // package.json has the depdenency defined, overwrite the version.\n allDeps[depName] = monorepoDeps[depName];\n } else {\n allDeps[depName] = depVersion;\n }\n });\n return sortDeps(allDeps);\n}\n\nfunction sortDeps(deps: Record<string, string>): Record<string, string> {\n const keys = Object.keys(deps).sort();\n const sortedDeps: Record<string, string> = {};\n for (const key of keys) {\n sortedDeps[key] = deps[key];\n }\n return sortedDeps;\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nimport fsExtra from 'fs-extra';\nimport glob from 'tiny-glob';\n\nexport function isJsFile(filename: string) {\n return !!filename.match(/\\.(j|t)sx?$/);\n}\n\nexport async function writeFile(filepath: string, content: string) {\n const dirPath = path.dirname(filepath);\n await makeDir(dirPath);\n await fs.promises.writeFile(filepath, content);\n}\n\nexport async function makeDir(dirpath: string) {\n try {\n await fs.promises.access(dirpath);\n } catch (e) {\n await fs.promises.mkdir(dirpath, {recursive: true});\n }\n}\n\nexport async function copyDir(srcdir: string, dstdir: string) {\n if (!fsExtra.existsSync(srcdir)) {\n return;\n }\n fsExtra.copySync(srcdir, dstdir, {overwrite: true});\n}\n\n/**\n * Copies a glob of files from one directory to another.\n *\n * Example:\n *\n * ```\n * await copyGlob('*.css', 'src/styles', 'dist/html/styles');\n * ```\n */\nexport async function copyGlob(\n pattern: string,\n srcdir: string,\n dstdir: string\n) {\n const files = await glob(pattern, {cwd: srcdir});\n if (files.length > 0) {\n await makeDir(dstdir);\n }\n files.forEach((file) => {\n fsExtra.copySync(path.resolve(srcdir, file), path.resolve(dstdir, file));\n });\n}\n\nexport async function rmDir(dirpath: string) {\n await fs.promises.rm(dirpath, {recursive: true, force: true});\n}\n\nexport async function loadJson<T = unknown>(filepath: string): Promise<T> {\n const content = await fs.promises.readFile(filepath, 'utf-8');\n return JSON.parse(content);\n}\n\nexport function loadJsonSync<T = unknown>(filepath: string): T {\n const content = fs.readFileSync(filepath, 'utf-8');\n return JSON.parse(content);\n}\n\nexport async function writeJson(filepath: string, data: any) {\n const content = JSON.stringify(data, null, 2);\n await writeFile(filepath, content);\n}\n\nexport async function isDirectory(dirpath: string) {\n return fs.promises\n .stat(dirpath)\n .then((fsStat) => {\n return fsStat.isDirectory();\n })\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return false;\n }\n throw err;\n });\n}\n\nexport function fileExists(filepath: string): Promise<boolean> {\n return fs.promises\n .access(filepath)\n .then(() => true)\n .catch(() => false);\n}\n\nexport function fileExistsSync(filepath: string): boolean {\n try {\n fs.accessSync(filepath);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function dirExists(dirpath: string): Promise<boolean> {\n try {\n const stat = await fs.promises.stat(dirpath);\n return stat.isDirectory();\n } catch (error) {\n if (error.code === 'ENOENT') {\n return false;\n }\n throw error;\n }\n}\n\nexport async function directoryContains(\n dirpath: string,\n subpath: string\n): Promise<boolean> {\n const outer = await fs.promises.realpath(dirpath);\n const inner = await fs.promises.realpath(subpath);\n const rel = path.relative(outer, inner);\n return !rel.startsWith('..');\n}\n\nexport async function listFilesRecursive(dirPath: string): Promise<string[]> {\n const files: string[] = [];\n const entries = await fs.promises.readdir(dirPath, {withFileTypes: true});\n for (const entry of entries) {\n const fullPath = path.join(dirPath, entry.name);\n if (entry.isDirectory()) {\n const subFiles = await listFilesRecursive(fullPath);\n files.push(...subFiles);\n } else {\n files.push(fullPath);\n }\n }\n return files;\n}\n","import path from 'node:path';\nimport {bundleRequire} from 'bundle-require';\nimport {build, Plugin as EsbuildPlugin} from 'esbuild';\nimport {RootConfig} from '../core/config.js';\nimport {fileExists} from '../utils/fsutils.js';\nimport {flattenPackageDepsFromMonorepo} from './monorepo.js';\n\nexport interface ConfigOptions {\n command: string;\n}\n\nexport async function loadRootConfig(\n rootDir: string,\n options: ConfigOptions\n): Promise<RootConfig> {\n const {rootConfig} = await loadRootConfigWithDeps(rootDir, options);\n return rootConfig;\n}\n\nexport async function loadRootConfigWithDeps(\n rootDir: string,\n options: ConfigOptions\n): Promise<{rootConfig: RootConfig; dependencies: string[]}> {\n const configPath = path.resolve(rootDir, 'root.config.ts');\n const exists = await fileExists(configPath);\n if (!exists) {\n throw new Error(`${configPath} does not exist`);\n }\n const configBundle = await bundleRequire({\n filepath: configPath,\n esbuildOptions: {plugins: [esbuildExternalsPlugin({rootDir})]},\n });\n let config = configBundle.mod.default || {};\n if (typeof config === 'function') {\n config = (await config(options)) || {};\n }\n const rootConfig = Object.assign({}, config, {rootDir});\n validateRootconfig(rootConfig);\n return {rootConfig, dependencies: configBundle.dependencies};\n}\n\nfunction validateRootconfig(rootConfig: RootConfig) {\n // Update vite legacy config options.\n const scss: any = rootConfig.vite?.css?.preprocessorOptions?.scss;\n if (scss?.includePaths) {\n console.warn(\n '[deprecation warning] root.config.ts: vite.css.preprocessorOptions.scss.includePaths is deprecated. rename \"includePaths\" -> \"loadPaths\"'\n );\n scss.loadPaths = scss.includePaths;\n }\n}\n\n/**\n * Compiles a root.config.ts file to root.config.js.\n */\nexport async function bundleRootConfig(rootDir: string, outPath: string) {\n const configPath = path.resolve(rootDir, 'root.config.ts');\n const configExists = await fileExists(configPath);\n if (!configExists) {\n throw new Error(`${configPath} does not exist`);\n }\n await build({\n entryPoints: [configPath],\n bundle: true,\n minify: true,\n platform: 'node',\n outfile: outPath,\n sourcemap: 'inline',\n metafile: true,\n format: 'esm',\n plugins: [esbuildExternalsPlugin({rootDir})],\n });\n}\n\n/**\n * Loads a pre-bundled config file from dist/root.config.js.\n */\nexport async function loadBundledConfig(\n rootDir: string,\n options: ConfigOptions\n): Promise<RootConfig> {\n const configPath = path.resolve(rootDir, 'dist/root.config.js');\n const exists = await fileExists(configPath);\n if (!exists) {\n throw new Error(`${configPath} does not exist`);\n }\n const module = await import(configPath);\n let config = module.default || {};\n if (typeof config === 'function') {\n config = (await config(options)) || {};\n }\n return Object.assign({}, config, {rootDir});\n}\n\n/**\n * Externalizes node_modules deps from the package and any dependent packages\n * from the monorepo.\n */\nfunction esbuildExternalsPlugin(options: {rootDir: string}): EsbuildPlugin {\n const rootDir = options.rootDir;\n const allDeps = flattenPackageDepsFromMonorepo(rootDir);\n\n function getPackageName(id: string): string {\n const segments = id.split('/');\n if (segments.length > 1) {\n // Check if package is an org path like `@blinkk/root`.\n if (segments[0].startsWith('@') && segments[0].length > 1) {\n return `${segments[0]}/${segments[1]}`;\n }\n // For imports like `my-package/subpackage`, return `my-package`.\n return segments[0];\n }\n return id;\n }\n\n return {\n name: 'root-externals-plugin',\n setup(build) {\n build.onResolve({filter: /.*/}, (args) => {\n const id = args.path;\n if (id[0] !== '.' && !id.startsWith('@/')) {\n const packageName = getPackageName(id);\n if (packageName in allDeps) {\n return {\n external: true,\n };\n }\n }\n return null;\n });\n },\n };\n}\n","import {createServer, ViteDevServer} from 'vite';\nimport type {Plugin, EnvironmentModuleNode} from 'vite';\nimport {RootConfig} from '../core/config.js';\nimport {getVitePlugins} from '../core/plugin.js';\nimport {preactToRootJsxPlugin} from './vite-plugin-preact-alias.js';\n\nexport interface CreateViteServerOptions {\n /** Override HMR settings. */\n hmr?: boolean;\n /** The port the server will run on. */\n port?: number;\n /** List of files to include in the optimizeDeps.include config. */\n optimizeDeps?: string[];\n}\n\n/**\n * Returns a vite dev server.\n */\nexport async function createViteServer(\n rootConfig: RootConfig,\n options?: CreateViteServerOptions\n): Promise<ViteDevServer> {\n const rootDir = rootConfig.rootDir;\n const viteConfig = rootConfig.vite || {};\n\n let hmrOptions = viteConfig.server?.hmr;\n if (options?.hmr === false) {\n hmrOptions = false;\n } else if (typeof hmrOptions === 'undefined' && options?.port) {\n // Automatically set the HMR port to `port + 10`. This allows multiple\n // root.js dev servers to run without conflicts.\n hmrOptions = {port: options.port + 10};\n }\n\n const viteServer = await createServer({\n ...viteConfig,\n mode: 'development',\n root: rootDir,\n // publicDir is disabled from the vite dev server since it's handled by the\n // root dev server directly, which allows user middlewares to override\n // files in the public dir.\n publicDir: false,\n server: {\n ...(viteConfig.server || {}),\n middlewareMode: true,\n hmr: hmrOptions,\n },\n appType: 'custom',\n optimizeDeps: {\n ...(viteConfig.optimizeDeps || {}),\n include: [\n ...(options?.optimizeDeps || []),\n ...(viteConfig.optimizeDeps?.include || []),\n ],\n extensions: [...(viteConfig.optimizeDeps?.extensions || []), '.tsx'],\n },\n ssr: {\n ...(viteConfig.ssr || {}),\n noExternal: ['@blinkk/root', '@blinkk/root-cms/richtext'],\n },\n plugins: [\n hmrSSRReload(),\n ...(rootConfig.jsxRenderer?.mode ? [preactToRootJsxPlugin()] : []),\n ...(viteConfig.plugins || []),\n ...getVitePlugins(rootConfig.plugins || []),\n ],\n });\n return viteServer;\n}\n\n/**\n * Shortcut `viteServer.ssrLoadModule()` without starting an actual dev server.\n */\nexport async function viteSsrLoadModule<T = Record<string, any>>(\n rootConfig: RootConfig,\n file: string\n): Promise<T> {\n const viteServer = await createViteServer(rootConfig, {hmr: false});\n const module = await viteServer.ssrLoadModule(file);\n await viteServer.close();\n return module as T;\n}\n\n/**\n * Vite plugin to reload the page when SSR modules change.\n * https://github.com/vitejs/vite/issues/19114\n */\nfunction hmrSSRReload(): Plugin {\n return {\n name: 'hmr-ssr-reload',\n enforce: 'post',\n hotUpdate: {\n order: 'post',\n handler({modules, server, timestamp}) {\n if (this.environment.name !== 'ssr') {\n return;\n }\n\n let hasSsrOnlyModules = false;\n const invalidatedModules = new Set<EnvironmentModuleNode>();\n for (const mod of modules) {\n if (mod.id === null) {\n continue;\n }\n const clientModule =\n server.environments.client.moduleGraph.getModuleById(mod.id);\n if (clientModule) {\n continue;\n }\n\n hasSsrOnlyModules = true;\n this.environment.moduleGraph.invalidateModule(\n mod,\n invalidatedModules,\n timestamp,\n true\n );\n }\n\n if (hasSsrOnlyModules) {\n server.ws.send({type: 'full-reload'});\n return [];\n }\n\n return;\n },\n },\n };\n}\n","import type {Plugin} from 'vite';\n\n/**\n * Vite plugin that aliases `preact` imports to `@blinkk/root/jsx`.\n *\n * When `jsxRenderer.mode` is configured, the project uses Root's built-in JSX\n * runtime instead of Preact. This plugin redirects all `preact` imports\n * (including `preact/hooks`, `preact/jsx-runtime`, etc.) so that Root's\n * built-in hooks and components use Root's context API rather than Preact's.\n */\nexport function preactToRootJsxPlugin(): Plugin {\n return {\n name: 'root:preact-to-jsx',\n config() {\n return {\n resolve: {\n alias: [\n {find: /^preact\\/hooks$/, replacement: '@blinkk/root/jsx'},\n {\n find: /^preact\\/jsx-runtime$/,\n replacement: '@blinkk/root/jsx/jsx-runtime',\n },\n {\n find: /^preact\\/jsx-dev-runtime$/,\n replacement: '@blinkk/root/jsx/jsx-dev-runtime',\n },\n {find: /^preact$/, replacement: '@blinkk/root/jsx'},\n ],\n },\n };\n },\n };\n}\n"],"mappings":";;;;;AAAA,OAAOA,WAAU;AACjB,SAAQ,eAAe,wBAAoC;;;ACD3D,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,OAAO,aAAa;AACpB,OAAO,UAAU;AAEV,SAAS,SAAS,UAAkB;AACzC,SAAO,CAAC,CAAC,SAAS,MAAM,aAAa;AACvC;AAEA,eAAsB,UAAU,UAAkB,SAAiB;AACjE,QAAM,UAAU,KAAK,QAAQ,QAAQ;AACrC,QAAM,QAAQ,OAAO;AACrB,QAAM,GAAG,SAAS,UAAU,UAAU,OAAO;AAC/C;AAEA,eAAsB,QAAQ,SAAiB;AAC7C,MAAI;AACF,UAAM,GAAG,SAAS,OAAO,OAAO;AAAA,EAClC,SAAS,GAAG;AACV,UAAM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C3B;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAEA,YAAI,mBAAmB;AACrB,iBAAO,GAAG,KAAK,EAAC,MAAM,cAAa,CAAC;AACpC,iBAAO,CAAC;AAAA,QACV;AAEA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["path","path","path","path","build"]}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RouteTrie,
|
|
3
|
+
htmlMinify,
|
|
4
|
+
htmlPretty,
|
|
5
|
+
isValidTagName,
|
|
6
|
+
parseTagNames
|
|
7
|
+
} from "./chunk-6P3B7ZXL.js";
|
|
1
8
|
import {
|
|
2
9
|
headersMiddleware,
|
|
3
10
|
rootProjectMiddleware,
|
|
@@ -20,21 +27,15 @@ import {
|
|
|
20
27
|
loadRootConfig,
|
|
21
28
|
loadRootConfigWithDeps,
|
|
22
29
|
makeDir,
|
|
30
|
+
preactToRootJsxPlugin,
|
|
23
31
|
rmDir,
|
|
24
32
|
writeFile,
|
|
25
33
|
writeJson
|
|
26
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-EBE4O463.js";
|
|
27
35
|
import {
|
|
28
36
|
configureServerPlugins,
|
|
29
37
|
getVitePlugins
|
|
30
38
|
} from "./chunk-6FDF3DXT.js";
|
|
31
|
-
import {
|
|
32
|
-
RouteTrie,
|
|
33
|
-
htmlMinify,
|
|
34
|
-
htmlPretty,
|
|
35
|
-
isValidTagName,
|
|
36
|
-
parseTagNames
|
|
37
|
-
} from "./chunk-3KGEENDW.js";
|
|
38
39
|
|
|
39
40
|
// src/cli/cli.ts
|
|
40
41
|
import { Command, InvalidArgumentError } from "commander";
|
|
@@ -319,14 +320,20 @@ var BuildAsset = class {
|
|
|
319
320
|
};
|
|
320
321
|
|
|
321
322
|
// src/utils/batch.ts
|
|
322
|
-
async function batchAsyncCalls(data,
|
|
323
|
-
const result =
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
323
|
+
async function batchAsyncCalls(data, concurrency, asyncFunction) {
|
|
324
|
+
const result = new Array(data.length);
|
|
325
|
+
let nextIndex = 0;
|
|
326
|
+
async function worker() {
|
|
327
|
+
while (nextIndex < data.length) {
|
|
328
|
+
const index = nextIndex++;
|
|
329
|
+
result[index] = await asyncFunction(data[index]);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const workers = Array.from(
|
|
333
|
+
{ length: Math.min(concurrency, data.length) },
|
|
334
|
+
() => worker()
|
|
335
|
+
);
|
|
336
|
+
await Promise.all(workers);
|
|
330
337
|
return result;
|
|
331
338
|
}
|
|
332
339
|
|
|
@@ -378,6 +385,7 @@ async function build(rootProjectDir, options) {
|
|
|
378
385
|
}
|
|
379
386
|
}
|
|
380
387
|
const vitePlugins = [
|
|
388
|
+
...rootConfig.jsxRenderer?.mode ? [preactToRootJsxPlugin()] : [],
|
|
381
389
|
...viteConfig.plugins || [],
|
|
382
390
|
...getVitePlugins(rootPlugins)
|
|
383
391
|
];
|
|
@@ -385,12 +393,6 @@ async function build(rootProjectDir, options) {
|
|
|
385
393
|
...viteConfig,
|
|
386
394
|
root: rootDir,
|
|
387
395
|
mode,
|
|
388
|
-
esbuild: {
|
|
389
|
-
...viteConfig.esbuild,
|
|
390
|
-
jsx: "automatic",
|
|
391
|
-
jsxImportSource: "preact",
|
|
392
|
-
treeShaking: true
|
|
393
|
-
},
|
|
394
396
|
plugins: vitePlugins
|
|
395
397
|
};
|
|
396
398
|
const ssrInput = {
|
|
@@ -415,8 +417,8 @@ async function build(rootProjectDir, options) {
|
|
|
415
417
|
publicDir: false,
|
|
416
418
|
build: {
|
|
417
419
|
...viteConfig?.build,
|
|
418
|
-
|
|
419
|
-
...viteConfig?.build?.
|
|
420
|
+
rolldownOptions: {
|
|
421
|
+
...viteConfig?.build?.rolldownOptions,
|
|
420
422
|
input: ssrInput,
|
|
421
423
|
output: {
|
|
422
424
|
format: "esm",
|
|
@@ -438,7 +440,7 @@ async function build(rootProjectDir, options) {
|
|
|
438
440
|
ssr: {
|
|
439
441
|
...viteConfig.ssr,
|
|
440
442
|
target: "node",
|
|
441
|
-
noExternal: ["@blinkk/root",
|
|
443
|
+
noExternal: ["@blinkk/root", ...noExternal]
|
|
442
444
|
}
|
|
443
445
|
});
|
|
444
446
|
await viteBuild({
|
|
@@ -446,8 +448,8 @@ async function build(rootProjectDir, options) {
|
|
|
446
448
|
publicDir: false,
|
|
447
449
|
build: {
|
|
448
450
|
...viteConfig?.build,
|
|
449
|
-
|
|
450
|
-
...viteConfig?.build?.
|
|
451
|
+
rolldownOptions: {
|
|
452
|
+
...viteConfig?.build?.rolldownOptions,
|
|
451
453
|
input: [...routeFiles],
|
|
452
454
|
output: {
|
|
453
455
|
format: "esm",
|
|
@@ -455,7 +457,7 @@ async function build(rootProjectDir, options) {
|
|
|
455
457
|
assetFileNames: "assets/[hash][extname]",
|
|
456
458
|
chunkFileNames: "chunks/[hash].min.js",
|
|
457
459
|
sanitizeFileName,
|
|
458
|
-
...viteConfig?.build?.
|
|
460
|
+
...viteConfig?.build?.rolldownOptions?.output
|
|
459
461
|
}
|
|
460
462
|
},
|
|
461
463
|
outDir: path3.join(distDir, ".build/routes"),
|
|
@@ -477,8 +479,8 @@ async function build(rootProjectDir, options) {
|
|
|
477
479
|
publicDir: false,
|
|
478
480
|
build: {
|
|
479
481
|
...viteConfig?.build,
|
|
480
|
-
|
|
481
|
-
...viteConfig?.build?.
|
|
482
|
+
rolldownOptions: {
|
|
483
|
+
...viteConfig?.build?.rolldownOptions,
|
|
482
484
|
input: [...elements, ...bundleScripts],
|
|
483
485
|
output: {
|
|
484
486
|
format: "esm",
|
|
@@ -486,7 +488,7 @@ async function build(rootProjectDir, options) {
|
|
|
486
488
|
assetFileNames: "assets/[hash][extname]",
|
|
487
489
|
chunkFileNames: "chunks/[hash].min.js",
|
|
488
490
|
sanitizeFileName,
|
|
489
|
-
...viteConfig?.build?.
|
|
491
|
+
...viteConfig?.build?.rolldownOptions?.output
|
|
490
492
|
}
|
|
491
493
|
},
|
|
492
494
|
outDir: path3.join(distDir, ".build/client"),
|
|
@@ -2103,4 +2105,4 @@ export {
|
|
|
2103
2105
|
createProdServer,
|
|
2104
2106
|
CliRunner
|
|
2105
2107
|
};
|
|
2106
|
-
//# sourceMappingURL=chunk-
|
|
2108
|
+
//# sourceMappingURL=chunk-G7OKXRD3.js.map
|