@eserstack/laroux-bundler 0.0.0-stage → 5.0.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 +13 -0
- package/README.md +431 -2
- package/dist/adapters/fonts/font-optimizer.d.ts +28 -0
- package/dist/adapters/fonts/font-optimizer.js +74 -0
- package/dist/adapters/fonts/index.d.ts +18 -0
- package/dist/adapters/fonts/index.js +78 -0
- package/dist/adapters/fonts/mod.d.ts +6 -0
- package/dist/adapters/fonts/mod.js +7 -0
- package/dist/adapters/lightningcss/css-processor.d.ts +39 -0
- package/dist/adapters/lightningcss/css-processor.js +103 -0
- package/dist/adapters/lightningcss/mod.d.ts +5 -0
- package/dist/adapters/lightningcss/mod.js +6 -0
- package/dist/adapters/mod.d.ts +13 -0
- package/dist/adapters/mod.js +21 -0
- package/dist/adapters/prebuilt-bundler/mod.d.ts +5 -0
- package/dist/adapters/prebuilt-bundler/mod.js +6 -0
- package/dist/adapters/prebuilt-bundler/prebuilt-bundler.d.ts +22 -0
- package/dist/adapters/prebuilt-bundler/prebuilt-bundler.js +60 -0
- package/dist/adapters/react/mod.d.ts +10 -0
- package/dist/adapters/react/mod.js +16 -0
- package/dist/adapters/react/plugin.d.ts +17 -0
- package/dist/adapters/react/plugin.js +62 -0
- package/dist/adapters/react/rsc-analyze.d.ts +29 -0
- package/dist/adapters/react/rsc-analyze.js +116 -0
- package/dist/adapters/react/rsc-client-entry.d.ts +26 -0
- package/dist/adapters/react/rsc-client-entry.js +145 -0
- package/dist/adapters/react/rsc-module-map.d.ts +41 -0
- package/dist/adapters/react/rsc-module-map.js +81 -0
- package/dist/adapters/react/rsc-rewrite-imports.d.ts +38 -0
- package/dist/adapters/react/rsc-rewrite-imports.js +409 -0
- package/dist/adapters/react/rsc-transform.d.ts +26 -0
- package/dist/adapters/react/rsc-transform.js +101 -0
- package/dist/adapters/runtime-bundler/mod.d.ts +6 -0
- package/dist/adapters/runtime-bundler/mod.js +6 -0
- package/dist/adapters/runtime-bundler/runtime-bundler.d.ts +85 -0
- package/dist/adapters/runtime-bundler/runtime-bundler.js +244 -0
- package/dist/adapters/sharp/image-optimizer.d.ts +52 -0
- package/dist/adapters/sharp/image-optimizer.js +261 -0
- package/dist/adapters/sharp/mod.d.ts +6 -0
- package/dist/adapters/sharp/mod.js +6 -0
- package/dist/adapters/tailwindcss/compile.d.ts +22 -0
- package/dist/adapters/tailwindcss/compile.js +29 -0
- package/dist/adapters/tailwindcss/critical-css-config.d.ts +46 -0
- package/dist/adapters/tailwindcss/critical-css-config.js +78 -0
- package/dist/adapters/tailwindcss/critical-page-css.d.ts +61 -0
- package/dist/adapters/tailwindcss/critical-page-css.js +431 -0
- package/dist/adapters/tailwindcss/critical-universal-css.d.ts +68 -0
- package/dist/adapters/tailwindcss/critical-universal-css.js +250 -0
- package/dist/adapters/tailwindcss/mod.d.ts +10 -0
- package/dist/adapters/tailwindcss/mod.js +11 -0
- package/dist/adapters/tailwindcss/plugin.d.ts +16 -0
- package/dist/adapters/tailwindcss/plugin.js +107 -0
- package/dist/adapters/tailwindcss/stylesheet-loader.d.ts +15 -0
- package/dist/adapters/tailwindcss/stylesheet-loader.js +83 -0
- package/dist/config.d.ts +27 -0
- package/dist/config.js +31 -0
- package/dist/css-modules.d.ts +49 -0
- package/dist/css-modules.js +146 -0
- package/dist/domain/build-cache.d.ts +107 -0
- package/dist/domain/build-cache.js +128 -0
- package/dist/domain/build-validator.d.ts +68 -0
- package/dist/domain/build-validator.js +207 -0
- package/dist/domain/bundler.d.ts +136 -0
- package/dist/domain/bundler.js +225 -0
- package/dist/domain/chunk-manifest.d.ts +40 -0
- package/dist/domain/chunk-manifest.js +188 -0
- package/dist/domain/client-action-stub.d.ts +30 -0
- package/dist/domain/client-action-stub.js +167 -0
- package/dist/domain/copy-path.d.ts +15 -0
- package/dist/domain/copy-path.js +29 -0
- package/dist/domain/css-plugin.d.ts +91 -0
- package/dist/domain/css-plugin.js +6 -0
- package/dist/domain/css-processor.d.ts +57 -0
- package/dist/domain/css-processor.js +33 -0
- package/dist/domain/font-optimizer.d.ts +46 -0
- package/dist/domain/font-optimizer.js +17 -0
- package/dist/domain/framework-plugin.d.ts +106 -0
- package/dist/domain/framework-plugin.js +20 -0
- package/dist/domain/image-optimizer.d.ts +74 -0
- package/dist/domain/image-optimizer.js +16 -0
- package/dist/domain/import-map.d.ts +90 -0
- package/dist/domain/import-map.js +187 -0
- package/dist/domain/mod.d.ts +32 -0
- package/dist/domain/mod.js +20 -0
- package/dist/domain/route-generator.d.ts +34 -0
- package/dist/domain/route-generator.js +305 -0
- package/dist/domain/route-scanner.d.ts +72 -0
- package/dist/domain/route-scanner.js +282 -0
- package/dist/domain/server-action-transform.d.ts +28 -0
- package/dist/domain/server-action-transform.js +147 -0
- package/dist/domain/virtual-source.d.ts +63 -0
- package/dist/domain/virtual-source.js +238 -0
- package/dist/import-map-resolver-plugin.d.ts +47 -0
- package/dist/import-map-resolver-plugin.js +109 -0
- package/dist/mod.d.ts +57 -0
- package/dist/mod.js +56 -0
- package/dist/server-externals-plugin.d.ts +29 -0
- package/dist/server-externals-plugin.js +63 -0
- package/dist/system.d.ts +157 -0
- package/dist/system.js +1401 -0
- package/dist/types.d.ts +60 -0
- package/dist/types.js +38 -0
- package/package.json +83 -3
package/dist/system.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Build System
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic build orchestration.
|
|
5
|
+
* Framework-specific functionality (like React Server Components) is provided
|
|
6
|
+
* through the FrameworkPlugin interface.
|
|
7
|
+
*/
|
|
8
|
+
import type { FsWatcher } from "@eserstack/standards/cross-runtime";
|
|
9
|
+
import type { FrameworkPlugin, ModuleMap } from "./domain/framework-plugin.ts";
|
|
10
|
+
import type { BundlerBackend } from "./config.ts";
|
|
11
|
+
import * as types from "./types.ts";
|
|
12
|
+
import type { CssPlugin } from "./domain/css-plugin.ts";
|
|
13
|
+
import type { CssProcessor } from "./domain/css-processor.ts";
|
|
14
|
+
import type { FontOptimizer } from "./domain/font-optimizer.ts";
|
|
15
|
+
import type { ImageOptimizer } from "./domain/image-optimizer.ts";
|
|
16
|
+
import type { BuildCache } from "./domain/build-cache.ts";
|
|
17
|
+
/**
|
|
18
|
+
* Build context with all necessary dependencies
|
|
19
|
+
*/
|
|
20
|
+
export type BuildContext = {
|
|
21
|
+
/** Build configuration */
|
|
22
|
+
config: types.BuildConfig;
|
|
23
|
+
/** Project root directory */
|
|
24
|
+
projectRoot: string;
|
|
25
|
+
/** Source directory */
|
|
26
|
+
srcDir: string;
|
|
27
|
+
/** Distribution/output directory */
|
|
28
|
+
distDir: string;
|
|
29
|
+
/** Client entry point path */
|
|
30
|
+
clientEntry: string;
|
|
31
|
+
/**
|
|
32
|
+
* Chunk manifest file path, <distDir>/client/manifest.json. The build
|
|
33
|
+
* writes it last, so it exists only after a build that succeeded.
|
|
34
|
+
*/
|
|
35
|
+
chunkManifestFile: string;
|
|
36
|
+
/** Build cache for incremental builds (watch mode) */
|
|
37
|
+
cache?: BuildCache;
|
|
38
|
+
/**
|
|
39
|
+
* Backend for the server bundle (default and only value: "rolldown").
|
|
40
|
+
*/
|
|
41
|
+
bundlerBackend?: BundlerBackend;
|
|
42
|
+
/** Framework plugin for framework-specific build functionality */
|
|
43
|
+
plugin: FrameworkPlugin;
|
|
44
|
+
/** CSS plugin for CSS processing (Tailwind, UnoCSS, etc.) */
|
|
45
|
+
cssPlugin?: CssPlugin;
|
|
46
|
+
/** Transforms the global stylesheet when the CSS plugin does not compile it */
|
|
47
|
+
cssProcessor: CssProcessor;
|
|
48
|
+
/** Self-hosts the configured fonts */
|
|
49
|
+
fontOptimizer: FontOptimizer;
|
|
50
|
+
/** Optimizes the images under public/images */
|
|
51
|
+
imageOptimizer: ImageOptimizer;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Result of a build operation
|
|
55
|
+
*/
|
|
56
|
+
export type BuildResult = {
|
|
57
|
+
/** Whether the build succeeded */
|
|
58
|
+
success: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Id of the code in dist/. A build that bundles writes a new one into the
|
|
61
|
+
* chunk manifest and the generated routes file; a CSS-only rebuild keeps
|
|
62
|
+
* the code, so it reports the id of the build before it. The server adds
|
|
63
|
+
* it to the URLs it imports dist/ modules by, so each build loads fresh.
|
|
64
|
+
*/
|
|
65
|
+
buildId: string;
|
|
66
|
+
/** Path to the client bundle */
|
|
67
|
+
clientBundle: string;
|
|
68
|
+
/** Module map for client components */
|
|
69
|
+
moduleMap: ModuleMap;
|
|
70
|
+
/** Number of client components found */
|
|
71
|
+
clientComponents: number;
|
|
72
|
+
/** Build duration in milliseconds */
|
|
73
|
+
duration: number;
|
|
74
|
+
/** Build timestamp */
|
|
75
|
+
timestamp: number;
|
|
76
|
+
/** Files that changed (for watch mode HMR) */
|
|
77
|
+
changedFiles?: string[];
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Build plugins configuration
|
|
81
|
+
* Users pass these explicitly when calling bundle functions. Each one left
|
|
82
|
+
* out falls back to a no-op: no framework hooks, no CSS processing, no font
|
|
83
|
+
* self-hosting, no image optimization.
|
|
84
|
+
*/
|
|
85
|
+
export type BuildPlugins = {
|
|
86
|
+
/** Framework plugin for framework-specific build functionality (React, Vue, etc.) */
|
|
87
|
+
framework?: FrameworkPlugin;
|
|
88
|
+
/** CSS plugin for CSS processing (Tailwind, UnoCSS, etc.) */
|
|
89
|
+
css?: CssPlugin;
|
|
90
|
+
/**
|
|
91
|
+
* Transforms the global stylesheet when the CSS plugin does not compile it,
|
|
92
|
+
* such as lightningCssProcessor from adapters/lightningcss. Default: the
|
|
93
|
+
* stylesheet is written as the CSS plugin's input left it.
|
|
94
|
+
*/
|
|
95
|
+
cssProcessor?: CssProcessor;
|
|
96
|
+
/**
|
|
97
|
+
* Self-hosts the configured fonts, such as googleFontOptimizer from
|
|
98
|
+
* adapters/fonts. Default: no font files are downloaded.
|
|
99
|
+
*/
|
|
100
|
+
fontOptimizer?: FontOptimizer;
|
|
101
|
+
/**
|
|
102
|
+
* Optimizes the images under public/images, such as sharpImageOptimizer
|
|
103
|
+
* from adapters/sharp. Default: images are served as they are.
|
|
104
|
+
*/
|
|
105
|
+
imageOptimizer?: ImageOptimizer;
|
|
106
|
+
/**
|
|
107
|
+
* Backend for the server bundle (default and only value: "rolldown").
|
|
108
|
+
*/
|
|
109
|
+
bundlerBackend?: BundlerBackend;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Create build context from configuration
|
|
113
|
+
* @param config - Build configuration
|
|
114
|
+
* @param plugins - Plugins for framework, CSS, and bundler (explicit composition)
|
|
115
|
+
* @returns Build context with all paths and dependencies
|
|
116
|
+
*/
|
|
117
|
+
export declare function createBuildContext(config: types.BuildConfig, plugins?: BuildPlugins): BuildContext;
|
|
118
|
+
/**
|
|
119
|
+
* Main build function
|
|
120
|
+
* Performs complete build: analyze → transform → bundle → generate maps
|
|
121
|
+
* @param context - Build context with configuration and paths
|
|
122
|
+
* @param options - Build options
|
|
123
|
+
* - skipCss: for JS-only changes; keeps styles.css and skips the global
|
|
124
|
+
* stylesheet, but still compiles the CSS modules the bundles import
|
|
125
|
+
* - cssOnly: for CSS-only changes; rewrites styles.css and the CSS derived
|
|
126
|
+
* from it as a full build does, and keeps the JavaScript and its build id
|
|
127
|
+
* - changedFiles: set of changed file paths for incremental builds
|
|
128
|
+
* @returns Build result with success status and metrics
|
|
129
|
+
*/
|
|
130
|
+
export declare function build(context: BuildContext, options?: {
|
|
131
|
+
skipCss?: boolean;
|
|
132
|
+
cssOnly?: boolean;
|
|
133
|
+
changedFiles?: Set<string>;
|
|
134
|
+
}): Promise<BuildResult>;
|
|
135
|
+
/**
|
|
136
|
+
* Ensure build is ready - builds if needed, skips if up-to-date
|
|
137
|
+
*
|
|
138
|
+
* The build is up to date when the chunk manifest of a finished build exists
|
|
139
|
+
* and no build input changed after its timestamp: no file under the source
|
|
140
|
+
* directory or public/ (at any depth, skipping node_modules and hidden
|
|
141
|
+
* entries) and neither laroux.config.ts nor package.json.
|
|
142
|
+
* @param context - Build context with configuration and paths
|
|
143
|
+
* @returns Build result; a skipped build returns the existing build's
|
|
144
|
+
* timestamp, module map and client bundle, with a duration of 0
|
|
145
|
+
*/
|
|
146
|
+
export declare function ensureBuildIsReady(context: BuildContext): Promise<BuildResult>;
|
|
147
|
+
/**
|
|
148
|
+
* Watch mode for Hot Module Replacement (HMR)
|
|
149
|
+
* Monitors source files and rebuilds on changes
|
|
150
|
+
* @param context - Build context
|
|
151
|
+
* @param onChange - Callback invoked after each rebuild, including a failed
|
|
152
|
+
* one; check result.success before serving or announcing the result. The
|
|
153
|
+
* next rebuild waits for the promise it returns, so it can load the
|
|
154
|
+
* rebuilt output before dist/ changes again.
|
|
155
|
+
* @returns File system watcher
|
|
156
|
+
*/
|
|
157
|
+
export declare function watch(context: BuildContext, onChange: (result: BuildResult) => void | Promise<void>): FsWatcher;
|