robuild 0.1.0 → 0.1.2
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 +31 -5
- package/dist/_chunks/build-DsVOIGdc.mjs +3 -0
- package/dist/_chunks/{build-DbAuaVYJ.mjs → build-ZPgEqYgE.mjs} +562 -510
- package/dist/_chunks/manager-CnmjrU85.mjs +3 -0
- package/dist/_chunks/{plugin-manager-CwMXjVtp.mjs → manager-DyYf90Z5.mjs} +1 -1
- package/dist/_chunks/{package-05zYHSH0.mjs → package-Cq3r5Qfx.mjs} +26 -26
- package/dist/cli.mjs +2 -2
- package/dist/config.d.mts +1 -2
- package/dist/index.d.mts +173 -14
- package/dist/index.mjs +387 -86
- package/package.json +26 -26
- package/dist/_chunks/build-tpynh1ZI.mjs +0 -3
- package/dist/_chunks/plugin-manager-pCQvlo7q.mjs +0 -3
package/dist/index.mjs
CHANGED
|
@@ -1,99 +1,246 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as createBrowserShimsPlugin, c as SHEBANG_RE, d as shebangPlugin, f as nodeProtocolPlugin, g as logger, i as DEFAULT_SHIMS_CONFIG, l as hasShebang, m as hasGlobImports, o as createNodeShimsPlugin, p as createGlobImportPlugin, r as createSkipNodeModulesPlugin, s as createShimsPlugin, t as build, u as makeExecutable } from "./_chunks/build-ZPgEqYgE.mjs";
|
|
2
|
+
import { t as RobuildPluginManager } from "./_chunks/manager-DyYf90Z5.mjs";
|
|
2
3
|
import { defineConfig } from "./config.mjs";
|
|
4
|
+
import { extname } from "node:path";
|
|
5
|
+
import { readFile } from "node:fs/promises";
|
|
3
6
|
|
|
4
|
-
//#region src/
|
|
7
|
+
//#region src/plugins/builtin/cjs-default.ts
|
|
5
8
|
/**
|
|
6
|
-
*
|
|
9
|
+
* Detect if a file uses CommonJS exports
|
|
7
10
|
*/
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
function detectCommonJSExports(code) {
|
|
12
|
+
const cleanCode = removeCommentsAndStrings(code);
|
|
13
|
+
return {
|
|
14
|
+
hasModuleExports: /\bmodule\.exports\s*=/.test(cleanCode),
|
|
15
|
+
hasExportsAssignment: /\bexports\.\w+\s*=/.test(cleanCode),
|
|
16
|
+
hasDefaultExport: /\bexport\s+default\b/.test(cleanCode),
|
|
17
|
+
hasNamedExports: /\bexport\s+(?:const|let|var|function|class|\{)/.test(cleanCode)
|
|
18
|
+
};
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
|
-
*
|
|
21
|
+
* Remove comments and string literals from code
|
|
15
22
|
*/
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
function removeCommentsAndStrings(code) {
|
|
24
|
+
return code.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/"(?:[^"\\]|\\.)*"/g, "\"\"").replace(/'(?:[^'\\]|\\.)*'/g, "''").replace(/`(?:[^`\\]|\\.)*`/g, "``");
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Transform CommonJS exports to ES modules
|
|
28
|
+
*/
|
|
29
|
+
function transformCommonJSExports(code, mode) {
|
|
30
|
+
if (mode === false) return code;
|
|
31
|
+
const detection = detectCommonJSExports(code);
|
|
32
|
+
if (mode === "auto") {
|
|
33
|
+
if (!detection.hasModuleExports && !detection.hasExportsAssignment) return code;
|
|
34
|
+
if (detection.hasDefaultExport || detection.hasNamedExports) return code;
|
|
35
|
+
}
|
|
36
|
+
let transformedCode = code;
|
|
37
|
+
transformedCode = transformedCode.replace(/\bmodule\.exports\s*=\s*([^;]+);?/g, (match, value) => {
|
|
38
|
+
return `export default ${value.trim()};`;
|
|
39
|
+
});
|
|
40
|
+
transformedCode = transformedCode.replace(/\bexports\.(\w+)\s*=\s*([^;]+);?/g, "export const $1 = $2;");
|
|
41
|
+
return transformedCode;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create CJS default export handling plugin
|
|
45
|
+
*/
|
|
46
|
+
function createCjsDefaultPlugin(mode = "auto") {
|
|
47
|
+
return {
|
|
48
|
+
name: "cjs-default",
|
|
49
|
+
transform: async (code, id) => {
|
|
50
|
+
if (!/\.(?:js|mjs|cjs|ts|mts|cts|jsx|tsx)$/.test(id)) return null;
|
|
51
|
+
const detection = detectCommonJSExports(code);
|
|
52
|
+
if (mode === "auto" && !detection.hasModuleExports && !detection.hasExportsAssignment) return null;
|
|
53
|
+
if (mode === "auto" && (detection.hasDefaultExport || detection.hasNamedExports)) return null;
|
|
54
|
+
const transformedCode = transformCommonJSExports(code, mode);
|
|
55
|
+
return transformedCode !== code ? transformedCode : null;
|
|
22
56
|
}
|
|
23
57
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/plugins/builtin/loaders.ts
|
|
62
|
+
/**
|
|
63
|
+
* Default loader mappings for common file extensions.
|
|
64
|
+
*
|
|
65
|
+
* Uses Rolldown's native moduleTypes:
|
|
66
|
+
* - 'asset': Auto-detect (base64 for small files, file path for large)
|
|
67
|
+
* - 'file': Always emit as separate file
|
|
68
|
+
* - 'base64': Always inline as base64 data URL
|
|
69
|
+
* - 'text': Import as string
|
|
70
|
+
*/
|
|
71
|
+
const DEFAULT_LOADERS = {
|
|
72
|
+
".js": "js",
|
|
73
|
+
".mjs": "js",
|
|
74
|
+
".cjs": "js",
|
|
75
|
+
".jsx": "jsx",
|
|
76
|
+
".ts": "ts",
|
|
77
|
+
".mts": "ts",
|
|
78
|
+
".cts": "ts",
|
|
79
|
+
".tsx": "tsx",
|
|
80
|
+
".json": "json",
|
|
81
|
+
".css": "css",
|
|
82
|
+
".scss": "css",
|
|
83
|
+
".sass": "css",
|
|
84
|
+
".less": "css",
|
|
85
|
+
".styl": "css",
|
|
86
|
+
".txt": "text",
|
|
87
|
+
".md": "text",
|
|
88
|
+
".html": "text",
|
|
89
|
+
".xml": "text",
|
|
90
|
+
".svg": "text",
|
|
91
|
+
".png": "asset",
|
|
92
|
+
".jpg": "asset",
|
|
93
|
+
".jpeg": "asset",
|
|
94
|
+
".gif": "asset",
|
|
95
|
+
".webp": "asset",
|
|
96
|
+
".ico": "asset",
|
|
97
|
+
".avif": "asset",
|
|
98
|
+
".woff": "asset",
|
|
99
|
+
".woff2": "asset",
|
|
100
|
+
".ttf": "asset",
|
|
101
|
+
".eot": "asset",
|
|
102
|
+
".otf": "asset",
|
|
103
|
+
".mp4": "file",
|
|
104
|
+
".webm": "file",
|
|
105
|
+
".ogg": "file",
|
|
106
|
+
".wav": "file",
|
|
107
|
+
".mp3": "file",
|
|
108
|
+
".flac": "file",
|
|
109
|
+
".aac": "file",
|
|
110
|
+
".zip": "binary",
|
|
111
|
+
".tar": "binary",
|
|
112
|
+
".gz": "binary",
|
|
113
|
+
".br": "binary",
|
|
114
|
+
".wasm": "binary"
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Get loader type for a file based on its extension
|
|
118
|
+
*/
|
|
119
|
+
function getLoaderForFile(filePath, loaders) {
|
|
120
|
+
const ext = extname(filePath).toLowerCase();
|
|
121
|
+
if (loaders?.[ext]) return loaders[ext].loader;
|
|
122
|
+
return DEFAULT_LOADERS[ext] || "file";
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Transform file content based on loader type
|
|
126
|
+
*/
|
|
127
|
+
async function transformWithLoader(filePath, content, loader, options) {
|
|
128
|
+
switch (loader) {
|
|
129
|
+
case "js":
|
|
130
|
+
case "jsx":
|
|
131
|
+
case "ts":
|
|
132
|
+
case "tsx": return content;
|
|
133
|
+
case "json": try {
|
|
134
|
+
const parsed = JSON.parse(content);
|
|
135
|
+
return `export default ${JSON.stringify(parsed)}`;
|
|
136
|
+
} catch {
|
|
137
|
+
return `export default ${JSON.stringify(content)}`;
|
|
90
138
|
}
|
|
139
|
+
case "css": return transformCssContent(content, options);
|
|
140
|
+
case "text": return `export default ${JSON.stringify(content)}`;
|
|
141
|
+
case "file": return transformFileContent(filePath, options);
|
|
142
|
+
case "dataurl": return transformDataUrlContent(filePath, content, options);
|
|
143
|
+
case "binary": return transformBinaryContent(filePath, options);
|
|
144
|
+
case "empty": return "export default {}";
|
|
145
|
+
default: throw new Error(`Unknown loader type: ${loader}`);
|
|
91
146
|
}
|
|
92
|
-
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Transform CSS content
|
|
150
|
+
*/
|
|
151
|
+
function transformCssContent(content, options) {
|
|
152
|
+
if (options?.modules) {
|
|
153
|
+
const moduleExports = extractCssClassNames(content).reduce((acc, className) => {
|
|
154
|
+
acc[className] = className;
|
|
155
|
+
return acc;
|
|
156
|
+
}, {});
|
|
157
|
+
return `export default ${JSON.stringify(moduleExports)}`;
|
|
158
|
+
}
|
|
159
|
+
return `export default ${JSON.stringify(content)}`;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Transform file content to URL
|
|
163
|
+
*/
|
|
164
|
+
function transformFileContent(filePath, options) {
|
|
165
|
+
const url = `${options?.publicPath || "/"}${filePath.split("/").pop() || "file"}`;
|
|
166
|
+
return `export default ${JSON.stringify(url)}`;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Transform file content to data URL
|
|
170
|
+
*/
|
|
171
|
+
function transformDataUrlContent(filePath, content, _options) {
|
|
172
|
+
const dataUrl = `data:${getMimeType(extname(filePath).toLowerCase())};base64,${Buffer.from(content).toString("base64")}`;
|
|
173
|
+
return `export default ${JSON.stringify(dataUrl)}`;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Transform binary file content
|
|
177
|
+
*/
|
|
178
|
+
function transformBinaryContent(filePath, _options) {
|
|
179
|
+
const fileName = filePath.split("/").pop() || "binary";
|
|
180
|
+
return `export default ${JSON.stringify(fileName)}`;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Extract CSS class names (simplified implementation)
|
|
184
|
+
*/
|
|
185
|
+
function extractCssClassNames(content) {
|
|
186
|
+
const matches = content.match(/\.([a-z_-][\w-]*)/gi) || [];
|
|
187
|
+
return Array.from(new Set(matches.map((match) => match.slice(1))));
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Get MIME type for file extension
|
|
191
|
+
*/
|
|
192
|
+
function getMimeType(ext) {
|
|
193
|
+
return {
|
|
194
|
+
".png": "image/png",
|
|
195
|
+
".jpg": "image/jpeg",
|
|
196
|
+
".jpeg": "image/jpeg",
|
|
197
|
+
".gif": "image/gif",
|
|
198
|
+
".webp": "image/webp",
|
|
199
|
+
".svg": "image/svg+xml",
|
|
200
|
+
".ico": "image/x-icon",
|
|
201
|
+
".woff": "font/woff",
|
|
202
|
+
".woff2": "font/woff2",
|
|
203
|
+
".ttf": "font/ttf",
|
|
204
|
+
".eot": "application/vnd.ms-fontobject",
|
|
205
|
+
".mp4": "video/mp4",
|
|
206
|
+
".webm": "video/webm",
|
|
207
|
+
".wav": "audio/wav",
|
|
208
|
+
".mp3": "audio/mpeg",
|
|
209
|
+
".flac": "audio/flac",
|
|
210
|
+
".aac": "audio/aac",
|
|
211
|
+
".txt": "text/plain",
|
|
212
|
+
".md": "text/markdown",
|
|
213
|
+
".html": "text/html",
|
|
214
|
+
".xml": "application/xml",
|
|
215
|
+
".css": "text/css",
|
|
216
|
+
".js": "application/javascript",
|
|
217
|
+
".json": "application/json"
|
|
218
|
+
}[ext] || "application/octet-stream";
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Create a loader plugin for robuild
|
|
222
|
+
*/
|
|
223
|
+
function createLoaderPlugin(loaders) {
|
|
224
|
+
return {
|
|
225
|
+
name: "loaders",
|
|
226
|
+
load: async (id) => {
|
|
227
|
+
const ext = extname(id);
|
|
228
|
+
const loader = getLoaderForFile(id, loaders);
|
|
229
|
+
if (loader === "js" || loader === "jsx" || loader === "ts" || loader === "tsx") return null;
|
|
230
|
+
if (loader === "json" && !loaders?.[ext]) return null;
|
|
231
|
+
try {
|
|
232
|
+
const content = await readFile(id, "utf-8");
|
|
233
|
+
const options = loaders?.[ext]?.options;
|
|
234
|
+
return await transformWithLoader(id, content, loader, options);
|
|
235
|
+
} catch {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
};
|
|
93
240
|
}
|
|
94
241
|
|
|
95
242
|
//#endregion
|
|
96
|
-
//#region src/plugins/node-polyfills.ts
|
|
243
|
+
//#region src/plugins/extras/node-polyfills.ts
|
|
97
244
|
/**
|
|
98
245
|
* Built-in plugin for Node.js polyfills
|
|
99
246
|
*/
|
|
@@ -119,7 +266,7 @@ function nodePolyfillsPlugin() {
|
|
|
119
266
|
}
|
|
120
267
|
|
|
121
268
|
//#endregion
|
|
122
|
-
//#region src/plugins/text.ts
|
|
269
|
+
//#region src/plugins/extras/text.ts
|
|
123
270
|
/**
|
|
124
271
|
* Built-in plugin for text file imports
|
|
125
272
|
*/
|
|
@@ -141,7 +288,7 @@ function textPlugin(extensions = [".txt", ".md"]) {
|
|
|
141
288
|
}
|
|
142
289
|
|
|
143
290
|
//#endregion
|
|
144
|
-
//#region src/plugins/url.ts
|
|
291
|
+
//#region src/plugins/extras/url.ts
|
|
145
292
|
/**
|
|
146
293
|
* Built-in plugin for URL imports (assets)
|
|
147
294
|
*/
|
|
@@ -166,7 +313,7 @@ function urlPlugin(extensions = [
|
|
|
166
313
|
}
|
|
167
314
|
|
|
168
315
|
//#endregion
|
|
169
|
-
//#region src/plugins/virtual.ts
|
|
316
|
+
//#region src/plugins/extras/virtual.ts
|
|
170
317
|
/**
|
|
171
318
|
* Built-in plugin for virtual modules
|
|
172
319
|
*/
|
|
@@ -185,4 +332,158 @@ function virtualPlugin(modules) {
|
|
|
185
332
|
}
|
|
186
333
|
|
|
187
334
|
//#endregion
|
|
188
|
-
|
|
335
|
+
//#region src/plugins/factory.ts
|
|
336
|
+
/**
|
|
337
|
+
* Helper function to call a rolldown plugin hook safely
|
|
338
|
+
*/
|
|
339
|
+
function callHook(hook, ...args) {
|
|
340
|
+
if (typeof hook === "function") return hook(...args);
|
|
341
|
+
if (hook && typeof hook.handler === "function") return hook.handler(...args);
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Create a robuild plugin with enhanced hooks
|
|
346
|
+
*/
|
|
347
|
+
function createRobuildPlugin(name, hooks) {
|
|
348
|
+
return {
|
|
349
|
+
name,
|
|
350
|
+
meta: {
|
|
351
|
+
framework: "robuild",
|
|
352
|
+
robuild: true
|
|
353
|
+
},
|
|
354
|
+
...hooks
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Create a plugin factory function
|
|
359
|
+
*/
|
|
360
|
+
function createPluginFactory(name, factory) {
|
|
361
|
+
return (options) => createRobuildPlugin(name, factory(options));
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Extend a rolldown plugin with robuild-specific hooks
|
|
365
|
+
*/
|
|
366
|
+
function extendRolldownPlugin(plugin, robuildHooks) {
|
|
367
|
+
return {
|
|
368
|
+
...plugin,
|
|
369
|
+
...robuildHooks,
|
|
370
|
+
meta: {
|
|
371
|
+
...plugin.meta,
|
|
372
|
+
framework: "robuild",
|
|
373
|
+
robuild: true,
|
|
374
|
+
rollup: true
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Create a simple transform plugin
|
|
380
|
+
*/
|
|
381
|
+
function createTransformPlugin(name, transform, filter) {
|
|
382
|
+
return createRobuildPlugin(name, { transform: async (code, id) => {
|
|
383
|
+
if (filter && !filter.test(id)) return null;
|
|
384
|
+
const result = await transform(code, id, {});
|
|
385
|
+
return result ? { code: result } : null;
|
|
386
|
+
} });
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Create a simple load plugin
|
|
390
|
+
*/
|
|
391
|
+
function createLoadPlugin(name, load, filter) {
|
|
392
|
+
return createRobuildPlugin(name, { load: async (id) => {
|
|
393
|
+
if (filter && !filter.test(id)) return null;
|
|
394
|
+
return await load(id, {});
|
|
395
|
+
} });
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Create a simple resolve plugin
|
|
399
|
+
*/
|
|
400
|
+
function createResolvePlugin(name, resolveId, filter) {
|
|
401
|
+
return createRobuildPlugin(name, { resolveId: async (id, importer) => {
|
|
402
|
+
if (filter && !filter.test(id)) return null;
|
|
403
|
+
return await resolveId(id, importer, {});
|
|
404
|
+
} });
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Combine multiple plugins into one
|
|
408
|
+
*/
|
|
409
|
+
function combinePlugins(name, plugins) {
|
|
410
|
+
const combinedPlugin = {
|
|
411
|
+
name,
|
|
412
|
+
meta: {
|
|
413
|
+
framework: "robuild",
|
|
414
|
+
robuild: true
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
for (const plugin of plugins) {
|
|
418
|
+
if (plugin.buildStart) {
|
|
419
|
+
const prevHook = combinedPlugin.buildStart;
|
|
420
|
+
combinedPlugin.buildStart = async (opts) => {
|
|
421
|
+
if (prevHook) await callHook(prevHook, opts);
|
|
422
|
+
await callHook(plugin.buildStart, opts);
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
if (plugin.buildEnd) {
|
|
426
|
+
const prevHook = combinedPlugin.buildEnd;
|
|
427
|
+
combinedPlugin.buildEnd = async (error) => {
|
|
428
|
+
if (prevHook) await callHook(prevHook, error);
|
|
429
|
+
await callHook(plugin.buildEnd, error);
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
if (plugin.resolveId) {
|
|
433
|
+
const prevHook = combinedPlugin.resolveId;
|
|
434
|
+
combinedPlugin.resolveId = async (id, importer) => {
|
|
435
|
+
if (prevHook) {
|
|
436
|
+
const result = await callHook(prevHook, id, importer);
|
|
437
|
+
if (result) return result;
|
|
438
|
+
}
|
|
439
|
+
return await callHook(plugin.resolveId, id, importer);
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
if (plugin.load) {
|
|
443
|
+
const prevHook = combinedPlugin.load;
|
|
444
|
+
combinedPlugin.load = async (id) => {
|
|
445
|
+
if (prevHook) {
|
|
446
|
+
const result = await callHook(prevHook, id);
|
|
447
|
+
if (result) return result;
|
|
448
|
+
}
|
|
449
|
+
return await callHook(plugin.load, id);
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
if (plugin.transform) {
|
|
453
|
+
const prevHook = combinedPlugin.transform;
|
|
454
|
+
combinedPlugin.transform = async (code, id) => {
|
|
455
|
+
let currentCode = code;
|
|
456
|
+
if (prevHook) {
|
|
457
|
+
const result = await callHook(prevHook, currentCode, id);
|
|
458
|
+
if (result) currentCode = typeof result === "string" ? result : result.code;
|
|
459
|
+
}
|
|
460
|
+
return await callHook(plugin.transform, currentCode, id);
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
if (plugin.robuildSetup) {
|
|
464
|
+
const prevHook = combinedPlugin.robuildSetup;
|
|
465
|
+
combinedPlugin.robuildSetup = async (context) => {
|
|
466
|
+
if (prevHook) await prevHook(context);
|
|
467
|
+
await plugin.robuildSetup(context);
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
if (plugin.robuildBuildStart) {
|
|
471
|
+
const prevHook = combinedPlugin.robuildBuildStart;
|
|
472
|
+
combinedPlugin.robuildBuildStart = async (context) => {
|
|
473
|
+
if (prevHook) await prevHook(context);
|
|
474
|
+
await plugin.robuildBuildStart(context);
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
if (plugin.robuildBuildEnd) {
|
|
478
|
+
const prevHook = combinedPlugin.robuildBuildEnd;
|
|
479
|
+
combinedPlugin.robuildBuildEnd = async (context, result) => {
|
|
480
|
+
if (prevHook) await prevHook(context, result);
|
|
481
|
+
await plugin.robuildBuildEnd(context, result);
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return combinedPlugin;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
//#endregion
|
|
489
|
+
export { DEFAULT_LOADERS, DEFAULT_SHIMS_CONFIG, RobuildPluginManager, SHEBANG_RE, build, combinePlugins, createBrowserShimsPlugin, createCjsDefaultPlugin, createGlobImportPlugin, createLoadPlugin, createLoaderPlugin, createNodeShimsPlugin, createPluginFactory, createResolvePlugin, createRobuildPlugin, createShimsPlugin, createSkipNodeModulesPlugin, createTransformPlugin, defineConfig, extendRolldownPlugin, getLoaderForFile, hasGlobImports, hasShebang, makeExecutable, nodePolyfillsPlugin, nodeProtocolPlugin, shebangPlugin, textPlugin, urlPlugin, virtualPlugin };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "robuild",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"packageManager": "pnpm@10.11.1",
|
|
6
6
|
"description": "Zero-config ESM/TS package builder. Powered by Rolldown and Oxc",
|
|
7
7
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"test:raw": "vitest run",
|
|
31
31
|
"test:watch": "vitest",
|
|
32
32
|
"test:coverage": "turbo test:coverage:raw --filter=robuild",
|
|
33
|
-
"test:coverage:raw": "vitest run --coverage",
|
|
33
|
+
"test:coverage:raw": "vitest run --coverage && node scripts/update-coverage.mjs",
|
|
34
34
|
"test:coverage:watch": "vitest --coverage",
|
|
35
35
|
"test:ui": "vitest --ui",
|
|
36
36
|
"test:types": "tsc --noEmit --skipLibCheck src/**/*.ts",
|
|
@@ -42,37 +42,37 @@
|
|
|
42
42
|
"clean": "rm -rf .turbo dist coverage"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"c12": "
|
|
45
|
+
"c12": "4.0.0-beta.2",
|
|
46
46
|
"cac": "^6.7.14",
|
|
47
|
-
"chokidar": "^
|
|
47
|
+
"chokidar": "^5.0.0",
|
|
48
48
|
"consola": "^3.4.2",
|
|
49
|
-
"exsolve": "^1.0.
|
|
50
|
-
"glob": "^
|
|
51
|
-
"js-yaml": "^4.1.
|
|
52
|
-
"magic-string": "^0.30.
|
|
53
|
-
"minimatch": "^10.0
|
|
54
|
-
"oxc-minify": "^0.
|
|
55
|
-
"oxc-parser": "^0.
|
|
56
|
-
"oxc-transform": "^0.
|
|
57
|
-
"pretty-bytes": "^7.0
|
|
58
|
-
"rolldown": "1.0.0-rc.
|
|
59
|
-
"rolldown-plugin-dts": "^0.
|
|
60
|
-
"tinyglobby": "^0.2.
|
|
61
|
-
"typescript": "^5.
|
|
49
|
+
"exsolve": "^1.0.8",
|
|
50
|
+
"glob": "^13.0.3",
|
|
51
|
+
"js-yaml": "^4.1.1",
|
|
52
|
+
"magic-string": "^0.30.21",
|
|
53
|
+
"minimatch": "^10.2.0",
|
|
54
|
+
"oxc-minify": "^0.112.0",
|
|
55
|
+
"oxc-parser": "^0.112.0",
|
|
56
|
+
"oxc-transform": "^0.112.0",
|
|
57
|
+
"pretty-bytes": "^7.1.0",
|
|
58
|
+
"rolldown": "1.0.0-rc.4",
|
|
59
|
+
"rolldown-plugin-dts": "^0.22.1",
|
|
60
|
+
"tinyglobby": "^0.2.15",
|
|
61
|
+
"typescript": "^5.9.3"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@antfu/eslint-config": "^
|
|
64
|
+
"@antfu/eslint-config": "^7.4.3",
|
|
65
65
|
"@types/js-yaml": "^4.0.9",
|
|
66
|
-
"@types/node": "^
|
|
67
|
-
"@vitest/coverage-v8": "^
|
|
68
|
-
"automd": "^0.4.
|
|
69
|
-
"changelogen": "^0.6.
|
|
70
|
-
"eslint": "^
|
|
66
|
+
"@types/node": "^25.2.3",
|
|
67
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
68
|
+
"automd": "^0.4.3",
|
|
69
|
+
"changelogen": "^0.6.2",
|
|
70
|
+
"eslint": "^10.0.0",
|
|
71
71
|
"esno": "^4.8.0",
|
|
72
72
|
"git-cz": "^4.9.0",
|
|
73
|
-
"prettier": "^3.
|
|
73
|
+
"prettier": "^3.8.1",
|
|
74
74
|
"turbo": "^2.8.7",
|
|
75
|
-
"vitepress": "^1.6.
|
|
76
|
-
"vitest": "^
|
|
75
|
+
"vitepress": "^1.6.4",
|
|
76
|
+
"vitest": "^4.0.18"
|
|
77
77
|
}
|
|
78
78
|
}
|