Skip to content

Commit 892e2f2

Browse files
committed
refactor: streamline build process and update configuration
- Removed the buildNamespace function from build.ts to simplify the build process for library namespaces. - Updated console log messages for clarity in the build output. - Added a new Vite plugin to drop JavaScript output from the bundle, enhancing the build configuration. - Removed unused property from the RadioGroup component to clean up the code.
1 parent b237d2b commit 892e2f2

File tree

4 files changed

+13
-70
lines changed

4 files changed

+13
-70
lines changed

packages/lib/.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/lib/build.ts

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { $ } from 'bun';
66
const __dirname = fileURLToPath(new URL('.', import.meta.url));
77
const distDir = resolve(__dirname, 'dist');
88

9-
// Define all namespace entry points
109
const namespaces = [
1110
'forms',
1211
'feedback',
@@ -21,76 +20,10 @@ const namespaces = [
2120

2221
console.log('🔨 Building library with Bun...');
2322

24-
// Build function for a single namespace
25-
async function buildNamespace(namespace: string) {
26-
const entryPoint = resolve(__dirname, `${namespace}.ts`);
27-
28-
// Build ES module
29-
const esmResult = await build({
30-
entrypoints: [entryPoint],
31-
external: ['react', 'react-dom', 'react/jsx-runtime'],
32-
format: 'esm',
33-
minify: true,
34-
naming: {
35-
entry: '[name].mjs',
36-
},
37-
outdir: distDir,
38-
sourcemap: 'external',
39-
target: 'browser',
40-
root: __dirname,
41-
});
42-
43-
if (!esmResult.success) {
44-
console.error(`❌ ES module build failed for ${namespace}`);
45-
if (esmResult.logs) {
46-
console.error(esmResult.logs);
47-
}
48-
return false;
49-
}
50-
51-
// Verify output was created
52-
const esmOutputPath = resolve(distDir, `${namespace}.mjs`);
53-
if (!esmResult.outputs || esmResult.outputs.length === 0) {
54-
console.error(`❌ No output files created for ${namespace} ESM`);
55-
return false;
56-
}
57-
58-
// Build CommonJS module
59-
const cjsResult = await build({
60-
entrypoints: [entryPoint],
61-
external: ['react', 'react-dom', 'react/jsx-runtime'],
62-
format: 'cjs',
63-
minify: true,
64-
naming: {
65-
entry: '[name].cjs',
66-
},
67-
outdir: distDir,
68-
sourcemap: 'external',
69-
target: 'browser',
70-
root: __dirname,
71-
});
72-
73-
if (!cjsResult.success) {
74-
console.error(`❌ CommonJS module build failed for ${namespace}`);
75-
if (cjsResult.logs) {
76-
console.error(cjsResult.logs);
77-
}
78-
return false;
79-
}
80-
81-
// Verify output was created
82-
if (!cjsResult.outputs || cjsResult.outputs.length === 0) {
83-
console.error(`❌ No output files created for ${namespace} CJS`);
84-
return false;
85-
}
86-
87-
return true;
88-
}
89-
9023
// Build all namespaces
9124
console.log('📦 Building namespace entry points...');
9225
for (const namespace of namespaces) {
93-
console.log(` Building @react-creme/${namespace}...`);
26+
console.log(` Building react-creme/${namespace}...`);
9427
const entryPoint = resolve(__dirname, `${namespace}.ts`);
9528

9629
// Build ES module

packages/lib/components/radio-group/radio-group.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ const RadioGroup: React.FunctionComponent<RadioGroupProps> = ({
9999
return {
100100
...item,
101101
checked: previous.checked ?? item.checked ?? null,
102-
isChecked: previous.isChecked ?? item.isChecked,
103102
};
104103
}
105104

packages/lib/vite.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ import { fileURLToPath } from 'url';
99
import { visualizer } from 'rollup-plugin-visualizer';
1010

1111
const __dirname = fileURLToPath(new URL('.', import.meta.url));
12+
const dropJsOutput = {
13+
name: 'drop-js-output',
14+
generateBundle(_, bundle) {
15+
for (const key of Object.keys(bundle)) {
16+
if (bundle[key].type === 'chunk') {
17+
delete bundle[key];
18+
}
19+
}
20+
},
21+
};
1222

1323
export default defineConfig({
1424
plugins: [
@@ -19,6 +29,7 @@ export default defineConfig({
1929
brotliSize: true,
2030
template: 'treemap',
2131
}),
32+
dropJsOutput,
2233
],
2334
css: {
2435
preprocessorOptions: {

0 commit comments

Comments
 (0)