robuild 0.2.0 → 0.2.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/dist/_chunks/build-D0MXJmgE.mjs +2 -0
- package/dist/_chunks/{build-CKpqg1bY.mjs → build-DeROCGLc.mjs} +45 -30
- package/dist/_chunks/{package-DhV5-Z9t.mjs → package-CPHhLlk6.mjs} +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/_chunks/build-DlIVMHjs.mjs +0 -2
|
@@ -611,17 +611,26 @@ function normalizeChunkFileName(chunkFileName) {
|
|
|
611
611
|
*
|
|
612
612
|
* Since rolldown 1.0.0-rc.9 removed experimental CSS bundling support,
|
|
613
613
|
* this plugin handles CSS files by:
|
|
614
|
-
* 1.
|
|
615
|
-
* 2.
|
|
616
|
-
* 3. Emitting
|
|
614
|
+
* 1. Intercepting CSS file resolution and loading them as empty JS modules
|
|
615
|
+
* 2. Tracking the importer chain to assign CSS to the correct output chunk
|
|
616
|
+
* 3. Emitting CSS asset files in generateBundle
|
|
617
617
|
*
|
|
618
618
|
* This allows CSS imports in JS/TS files to work without rolldown errors.
|
|
619
619
|
*/
|
|
620
620
|
function createBuiltinCssPlugin(options = {}) {
|
|
621
621
|
const { fileName = "style.css", splitting = true } = options;
|
|
622
622
|
const cssMap = /* @__PURE__ */ new Map();
|
|
623
|
+
const cssImporters = /* @__PURE__ */ new Map();
|
|
623
624
|
return {
|
|
624
625
|
name: "robuild:css",
|
|
626
|
+
resolveId(id, importer) {
|
|
627
|
+
if (importer && id.endsWith(".css")) {
|
|
628
|
+
const resolved = resolve(dirname(importer), id);
|
|
629
|
+
if (!cssImporters.has(resolved)) cssImporters.set(resolved, /* @__PURE__ */ new Set());
|
|
630
|
+
cssImporters.get(resolved).add(importer);
|
|
631
|
+
}
|
|
632
|
+
return null;
|
|
633
|
+
},
|
|
625
634
|
async load(id) {
|
|
626
635
|
if (!id.endsWith(".css")) return null;
|
|
627
636
|
try {
|
|
@@ -637,37 +646,43 @@ function createBuiltinCssPlugin(options = {}) {
|
|
|
637
646
|
},
|
|
638
647
|
generateBundle(_outputOptions, bundle) {
|
|
639
648
|
if (cssMap.size === 0) return;
|
|
640
|
-
if (splitting) {
|
|
641
|
-
const chunks = Object.values(bundle);
|
|
642
|
-
for (const chunk of chunks) {
|
|
643
|
-
if (chunk.type !== "chunk" || !chunk.isEntry) continue;
|
|
644
|
-
const chunkCss = [];
|
|
645
|
-
const visited = /* @__PURE__ */ new Set();
|
|
646
|
-
function collectCss(moduleIds) {
|
|
647
|
-
for (const id of moduleIds) {
|
|
648
|
-
if (visited.has(id)) continue;
|
|
649
|
-
visited.add(id);
|
|
650
|
-
if (cssMap.has(id)) chunkCss.push(cssMap.get(id));
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
collectCss(chunk.moduleIds);
|
|
654
|
-
if (chunkCss.length > 0) {
|
|
655
|
-
const cssContent = chunkCss.join("\n");
|
|
656
|
-
const cssFileName = chunk.fileName.replace(/\.(m?js|cjs)$/, ".css");
|
|
657
|
-
this.emitFile({
|
|
658
|
-
type: "asset",
|
|
659
|
-
fileName: cssFileName,
|
|
660
|
-
source: cssContent
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
} else {
|
|
649
|
+
if (!splitting) {
|
|
665
650
|
const allCss = [...cssMap.values()].join("\n");
|
|
666
651
|
if (allCss.trim()) this.emitFile({
|
|
667
652
|
type: "asset",
|
|
668
653
|
fileName,
|
|
669
654
|
source: allCss
|
|
670
655
|
});
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
const chunks = Object.values(bundle).filter((c) => c.type === "chunk");
|
|
659
|
+
const chunkModuleIds = /* @__PURE__ */ new Map();
|
|
660
|
+
for (const chunk of chunks) chunkModuleIds.set(chunk.fileName, new Set(chunk.moduleIds));
|
|
661
|
+
function findOwnerChunks(cssId) {
|
|
662
|
+
const importers = cssImporters.get(cssId);
|
|
663
|
+
if (!importers || importers.size === 0) return chunks.filter((c) => c.isEntry).map((c) => c.fileName);
|
|
664
|
+
const ownerChunks = /* @__PURE__ */ new Set();
|
|
665
|
+
for (const [chunkFileName, moduleIds] of chunkModuleIds) for (const importerId of importers) if (moduleIds.has(importerId)) ownerChunks.add(chunkFileName);
|
|
666
|
+
if (ownerChunks.size === 0) return chunks.filter((c) => c.isEntry).map((c) => c.fileName);
|
|
667
|
+
return [...ownerChunks];
|
|
668
|
+
}
|
|
669
|
+
const chunkCssMap = /* @__PURE__ */ new Map();
|
|
670
|
+
for (const [cssId, cssContent] of cssMap) {
|
|
671
|
+
const ownerChunks = findOwnerChunks(cssId);
|
|
672
|
+
for (const chunkFileName of ownerChunks) {
|
|
673
|
+
if (!chunkCssMap.has(chunkFileName)) chunkCssMap.set(chunkFileName, []);
|
|
674
|
+
chunkCssMap.get(chunkFileName).push(cssContent);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
for (const [chunkFileName, cssList] of chunkCssMap) {
|
|
678
|
+
const cssContent = cssList.join("\n");
|
|
679
|
+
if (!cssContent.trim()) continue;
|
|
680
|
+
const cssFileName = chunkFileName.replace(/\.(m?js|cjs)$/, ".css");
|
|
681
|
+
this.emitFile({
|
|
682
|
+
type: "asset",
|
|
683
|
+
fileName: cssFileName,
|
|
684
|
+
source: cssContent
|
|
685
|
+
});
|
|
671
686
|
}
|
|
672
687
|
}
|
|
673
688
|
};
|
|
@@ -2315,7 +2330,7 @@ function createBuildResult(entries, startTime) {
|
|
|
2315
2330
|
* Perform watch build using rolldown's built-in watch mode
|
|
2316
2331
|
*/
|
|
2317
2332
|
async function performWatchBuild(config, ctx, startTime) {
|
|
2318
|
-
const { performBuild } = await import("./build-
|
|
2333
|
+
const { performBuild } = await import("./build-D0MXJmgE.mjs");
|
|
2319
2334
|
await performBuild(config, ctx, startTime);
|
|
2320
2335
|
const bundleEntries = (config.entries || []).filter((entry) => {
|
|
2321
2336
|
if (typeof entry === "string") return !entry.endsWith("/");
|
|
@@ -2335,7 +2350,7 @@ async function performWatchBuild(config, ctx, startTime) {
|
|
|
2335
2350
|
*/
|
|
2336
2351
|
async function startRolldownWatch(config, ctx, bundleEntries) {
|
|
2337
2352
|
logger.info("Watching for changes...");
|
|
2338
|
-
const { inheritConfig } = await import("./build-
|
|
2353
|
+
const { inheritConfig } = await import("./build-D0MXJmgE.mjs");
|
|
2339
2354
|
const watchConfigs = [];
|
|
2340
2355
|
for (const rawEntry of bundleEntries) {
|
|
2341
2356
|
let entry = typeof rawEntry === "string" ? parseEntryString(rawEntry) : rawEntry;
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { _ as configureLogger, t as build, v as logger } from "./_chunks/build-
|
|
2
|
+
import { _ as configureLogger, t as build, v as logger } from "./_chunks/build-DeROCGLc.mjs";
|
|
3
3
|
import module from "node:module";
|
|
4
4
|
import { colors } from "consola/utils";
|
|
5
5
|
import process from "node:process";
|
package/dist/index.d.mts
CHANGED
|
@@ -248,9 +248,9 @@ declare function createCssCodeSplitPlugin(config: Pick<Required<CssOptions>, 'sp
|
|
|
248
248
|
*
|
|
249
249
|
* Since rolldown 1.0.0-rc.9 removed experimental CSS bundling support,
|
|
250
250
|
* this plugin handles CSS files by:
|
|
251
|
-
* 1.
|
|
252
|
-
* 2.
|
|
253
|
-
* 3. Emitting
|
|
251
|
+
* 1. Intercepting CSS file resolution and loading them as empty JS modules
|
|
252
|
+
* 2. Tracking the importer chain to assign CSS to the correct output chunk
|
|
253
|
+
* 3. Emitting CSS asset files in generateBundle
|
|
254
254
|
*
|
|
255
255
|
* This allows CSS imports in JS/TS files to work without rolldown errors.
|
|
256
256
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as resolveCssOptions, S as esbuildTargetToLightningCSS, a as createSkipNodeModulesPlugin, b as createCssCodeSplitPlugin, c as createNodeShimsPlugin, d as hasShebang, f as makeExecutable, g as hasGlobImports, h as createGlobImportPlugin, i as RobuildPluginManager, l as createShimsPlugin, m as nodeProtocolPlugin, o as DEFAULT_SHIMS_CONFIG, p as shebangPlugin, s as createBrowserShimsPlugin, t as build, u as SHEBANG_RE, v as logger, x as createLightningCSSPlugin, y as createBuiltinCssPlugin } from "./_chunks/build-
|
|
1
|
+
import { C as resolveCssOptions, S as esbuildTargetToLightningCSS, a as createSkipNodeModulesPlugin, b as createCssCodeSplitPlugin, c as createNodeShimsPlugin, d as hasShebang, f as makeExecutable, g as hasGlobImports, h as createGlobImportPlugin, i as RobuildPluginManager, l as createShimsPlugin, m as nodeProtocolPlugin, o as DEFAULT_SHIMS_CONFIG, p as shebangPlugin, s as createBrowserShimsPlugin, t as build, u as SHEBANG_RE, v as logger, x as createLightningCSSPlugin, y as createBuiltinCssPlugin } from "./_chunks/build-DeROCGLc.mjs";
|
|
2
2
|
import { t as defineConfig } from "./_chunks/config-DnVMMWOP.mjs";
|
|
3
3
|
import { extname } from "node:path";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
package/package.json
CHANGED