Skip to content

Commit

Permalink
build: esnext esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaishankar committed Feb 28, 2024
1 parent 2e0d66e commit b986ed8
Show file tree
Hide file tree
Showing 9 changed files with 5,339 additions and 2,466 deletions.
3 changes: 1 addition & 2 deletions .vscode/settings.json
@@ -1,7 +1,7 @@
{
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"typescript.tsdk": "node_modules/typescript/lib",
"files.exclude": {
Expand All @@ -13,7 +13,6 @@
"**/lib": true,
"**/node_modules": true,
"**/coverage": true,
"**/dist": true,
"**/tsconfig.tsbuildinfo": true,
"**/yarn-error.log": true
}
Expand Down
29 changes: 29 additions & 0 deletions build.js
@@ -0,0 +1,29 @@
// https://janessagarrow.com/blog/typescript-and-esbuild/

const { build } = require("esbuild");
const { dependencies, peerDependencies } = require('./package.json');
const { Generator } = require('npm-dts');

new Generator({
entry: 'index.ts',
output: 'dist/index.d.ts',
}).generate();

const sharedConfig = {
entryPoints: ["src/index.ts"],
bundle: true,
external: Object.keys(dependencies ?? {}).concat(Object.keys(peerDependencies ?? {})),
};

build({
...sharedConfig,
platform: 'node', // for CJS
outfile: "dist/index.cjs",
});

build({
...sharedConfig,
outfile: "dist/index.js",
platform: 'neutral', // for ESM
format: "esm",
});

0 comments on commit b986ed8

Please sign in to comment.