3 ms·
I'd recommend using ESBuild directly. The following article helped me recently to figure out how to build a browser-side library to publish to NPM, as well as b
by lioeters 4y ago
I'd recommend using ESBuild directly. The following article helped me recently to figure out how to build a browser-side library to publish to NPM, as well as bundling a Node.js server to deploy.
Build A Library With esbuild - How to bundle ESM, IIFE or CommonJS libraries with esbuild
https://medium.com/geekculture/build-a-library-with-esbuild-23235712f3c https://medium.com/geekculture/build-a-library-with-esbuild-...
---
I had to figure out a trick for Node side to exclude external modules. In my build script:
const esbuild = require('esbuild')
const { dependencies, peerDependencies } = require('./package.json')
const external = [
...Object.keys(dependencies),
...Object.keys(peerDependencies)
]
await esbuild
.build({
entryPoints: ['src/index.ts'],
outfile: 'lib/index.mjs',
bundle: true,
sourcemap: false,
minify: false,
splitting: false,
format: 'esm',
target: ['esnext'],
external
}),