-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
note: esbuild doesn't have a config like most tooling. They suggest instead to use their api. See evanw/esbuild#952 (comment)
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,6 @@ pnpm-lock.yaml | |
|
||
output.json | ||
deno.lock | ||
|
||
bundle.cjs | ||
bundle.cjs.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { build } from 'esbuild' | ||
import fs from 'fs' | ||
|
||
const { dependencies } = JSON.parse(fs.readFileSync('./package.json', 'utf8')) | ||
// we need esbuild to process esm dependencies while leaving cjs compatible ones | ||
// out of the bundle | ||
const esmDependencies = new Set(['bellajs']) | ||
const externalDeps = Object.keys(dependencies) | ||
.filter(dep => !esmDependencies.has(dep)) | ||
|
||
build({ | ||
entryPoints: ['./src/main.js'], | ||
bundle: true, | ||
platform: 'node', | ||
target: 'node16', | ||
outfile: 'bundle.cjs', | ||
minify: true, | ||
sourcemap: true, | ||
external: externalDeps, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters