Skip to content

Commit f31c4ee

Browse files
committed
Initial commit
0 parents  commit f31c4ee

15 files changed

+7650
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

build.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const esbuild = require("esbuild");
2+
const { nodeExternalsPlugin } = require("esbuild-node-externals");
3+
const { exec } = require("child_process");
4+
5+
// Function to run esbuild with given options
6+
const build = async (options) => {
7+
try {
8+
await esbuild.build({
9+
...options,
10+
bundle: true,
11+
minify: true,
12+
platform: "neutral",
13+
plugins: [nodeExternalsPlugin()],
14+
});
15+
console.log(`Build successful: ${options.outfile}`);
16+
} catch {
17+
process.exit(1);
18+
}
19+
};
20+
21+
// Build configurations for CJS and ESM
22+
const buildOptions = [
23+
{
24+
entryPoints: ["src/index.ts"],
25+
outfile: "dist/bundle.cjs.js",
26+
format: "cjs",
27+
},
28+
{
29+
entryPoints: ["src/index.ts"],
30+
outfile: "dist/bundle.esm.js",
31+
format: "esm",
32+
},
33+
];
34+
35+
// Execute builds
36+
buildOptions.forEach(build);
37+
38+
// Generate type declarations
39+
exec("tsc --emitDeclarationOnly --outDir dist", (error, stdout, stderr) => {
40+
if (error) {
41+
console.error(`exec error: ${error}`);
42+
return;
43+
}
44+
console.log(`TypeScript declarations generated: ${stdout}`);
45+
if (stderr) {
46+
console.error(`stderr: ${stderr}`);
47+
}
48+
});
49+
50+
// const esbuild = require("esbuild");
51+
// const { nodeExternalsPlugin } = require("esbuild-node-externals");
52+
53+
// // Bundle CommonJS
54+
// esbuild
55+
// .build({
56+
// entryPoints: ["src/index.js"],
57+
// bundle: true,
58+
// minify: true,
59+
// platform: "neutral",
60+
// outfile: "dist/bundle.cjs.js",
61+
// format: "cjs",
62+
// plugins: [nodeExternalsPlugin()],
63+
// })
64+
// .catch(() => process.exit(1));
65+
66+
// // Bundle ES Module
67+
// esbuild
68+
// .build({
69+
// entryPoints: ["src/index.js"],
70+
// bundle: true,
71+
// minify: true,
72+
// platform: "neutral",
73+
// outfile: "dist/bundle.esm.js",
74+
// format: "esm",
75+
// plugins: [nodeExternalsPlugin()],
76+
// })
77+
// .catch(() => process.exit(1));

dist/bundle.cjs.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/bundle.esm.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types/Button.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
interface Props {
2+
title: string;
3+
onPress: () => void;
4+
}
5+
export declare function Button({ title, onPress }: Props): any;
6+
export {};

dist/types/Test.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface Props {
2+
title: string;
3+
}
4+
export declare function Test({ title }: Props): import("react/jsx-runtime").JSX.Element;
5+
export {};

dist/types/Trash.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare function Trash(): import("react/jsx-runtime").JSX.Element;

dist/types/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { Test } from "./Test";
2+
export { Trash } from "./Trash";

0 commit comments

Comments
 (0)