Skip to content

Commit

Permalink
Merge pull request #235 from Secreto31126/build
Browse files Browse the repository at this point in the history
Build improvements
  • Loading branch information
Secreto31126 authored Sep 24, 2023
2 parents 42ef841 + 7a22a50 commit ee7552e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
29 changes: 15 additions & 14 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,28 @@ const production = process.env.NODE_ENV !== "development";
* @type {import("esbuild").BuildOptions}
*/
const sharedConfig = {
entryPoints: await glob("src/**/*.ts", { ignore: ["src/**/*.d.ts"] }),
bundle: production,
entryPoints: await glob("src/**/*.ts", { ignore: ["src/standalone.ts"] }),
minifySyntax: production,
minifyWhitespace: production,
minifyIdentifiers: false,
sourcemap: true,
platform: "node"
};

// ESM
await build({
...sharedConfig,
format: "esm",
outdir: "lib/esm"
});
await Promise.all([
// ESM
build({
...sharedConfig,
format: "esm",
outdir: "lib/esm"
}),

// CJS
await build({
...sharedConfig,
format: "cjs",
outdir: "lib/cjs"
});
// CJS
build({
...sharedConfig,
format: "cjs",
outdir: "lib/cjs"
})
]);

await writeFile("./lib/cjs/package.json", '{"type":"commonjs"}');
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"build:code:dev": "npm run build:code",
"build:types": "tsc",
"build:types:dev": "tsc --outDir ./lib/esm && tsc --outDir ./lib/cjs",
"build:standalone": "esbuild src/standalone.ts --outfile=lib/standalone.js --bundle --platform=neutral --target=node10 --minify-syntax",
"test": "mocha",
"test:build": "npm run build && npm run test",
"test:watch": "mocha --reporter min --watch",
Expand Down
5 changes: 5 additions & 0 deletions src/standalone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from "./utils.js";
export * from "./types.js";
export * from "./emitters.js";
export * from "./messages/index.js";
export { default as WhatsAppAPI } from "./index.js";
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"include": ["src/**/*"],
"exclude": ["src/standalone.ts"],
"compilerOptions": {
"lib": ["ESNext"],
"outDir": "lib/types",
Expand Down

0 comments on commit ee7552e

Please sign in to comment.