Skip to content

Commit 640f390

Browse files
committed
ci: add next components to bundle check
1 parent 231307f commit 640f390

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

scripts/bundle-check/compare-bundles.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const path = require("path");
33
const bytes = require("bytes");
44

55
function extractJson(content) {
6-
const jsonMatch = content.match(/\[[\s\S]*?\]/);
6+
const jsonMatch = content.match(/^\[[\s\S]*\]$/m);
77

88
if (!jsonMatch) {
99
throw new Error("No JSON array found in content");
@@ -46,6 +46,12 @@ Array.from(allComponents)
4646
if (componentName.startsWith("packages/components/")) {
4747
const packageName = componentName.split("/")[2];
4848
displayName = `@vibe/${packageName}`;
49+
} else if (
50+
componentName.includes("/next/") ||
51+
(componentName.includes("/Modal/") && !componentName.includes("/LegacyModal/"))
52+
) {
53+
const baseName = path.basename(componentName, path.extname(componentName));
54+
displayName = `${baseName} (Next)`;
4955
} else {
5056
displayName = path.basename(componentName, path.extname(componentName));
5157
}

scripts/bundle-check/generate-size-limit-config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const path = require("path");
33

44
const rootPath = process.cwd();
55
const distIndexPath = path.join(rootPath, "packages/core/dist/src/index.js");
6+
const distNextPath = path.join(rootPath, "packages/core/dist/src/components/next.js");
67
const componentsPath = path.join(rootPath, "packages/components");
78
const sizeLimitConfigPath = path.join(rootPath, ".size-limit.js");
89

@@ -27,6 +28,26 @@ function generateSizeLimitConfig() {
2728
console.log(`Core dist index file not found at ${distIndexPath}.`);
2829
}
2930

31+
// Process @next components
32+
if (fs.existsSync(distNextPath)) {
33+
const nextContent = fs.readFileSync(distNextPath, "utf8");
34+
const exportRegex = /export\{.*?\}from"(\.\/[^"]+\.js)";/g;
35+
36+
let match;
37+
let nextComponentsCount = 0;
38+
while ((match = exportRegex.exec(nextContent)) !== null) {
39+
const relativePath = match[1];
40+
const fullPath = path.join("packages/core/dist/src/components/", relativePath).replace(/\\/g, "/");
41+
allComponents.push({
42+
path: fullPath
43+
});
44+
nextComponentsCount++;
45+
}
46+
console.log(`Found ${nextComponentsCount} @next components.`);
47+
} else {
48+
console.log(`@next dist file not found at ${distNextPath}.`);
49+
}
50+
3051
// Process component packages
3152
if (fs.existsSync(componentsPath)) {
3253
const componentPackages = fs

0 commit comments

Comments
 (0)