pixeleet
pixeleet9mo ago

what’s the current best practice for bundling?

Is it deno esbuild? Wondering what supports npm specifiers and bundling atm
3 Replies
NDH
NDH9mo ago
I've built a small util using the above,. It is deno-installed. It uses a small cfg file that it builds when not found. A cfg-per-project. In any project just enter build on the command line. in /.vscode/dev.json/
{
"simple": {
"TargetFolder": "",
"Port": 80
},
"build": {
"Out": "dist",
"FileName": "kvValueCodec.js",
"Entry": [
"./src/mod.ts"
],
"Minify": false
}
}
{
"simple": {
"TargetFolder": "",
"Port": 80
},
"build": {
"Out": "dist",
"FileName": "kvValueCodec.js",
"Entry": [
"./src/mod.ts"
],
"Minify": false
}
}
I have many installed dev tools that use this cfg. I like to keep this in /.vscode folder. All my tools share this dev.json file. simple above is a small dev server that auto launches the browser. If you enter simple dist 8080 the above dev.json will be auto changed to:
"simple": {
"TargetFolder": "./dist",
"Port": 8080
},
"simple": {
"TargetFolder": "./dist",
"Port": 8080
},
so that any further use you will simply enter simple
Doctor 🤖
Doctor 🤖9mo ago
// @deno-types="https://deno.land/x/esbuild@v0.17.19/mod.d.ts"
import { build, stop } from 'https://deno.land/x/esbuild@v0.17.19/mod.js'
import { denoPlugins } from 'https://deno.land/x/esbuild_deno_loader@0.7.0/mod.ts'

async function esbuild(inPath: string, outPath: string) {
const { errors, warnings } = await build({
plugins: denoPlugins(),
entryPoints: [ inPath ],
outfile: outPath,
format: 'esm',
bundle: true,
minify: true,
jsxFactory: 'x',
jsxFragment: 'y'
})
errors.forEach(error => console.error(error))
warnings.forEach(warning => console.warn(warning))
}
// @deno-types="https://deno.land/x/esbuild@v0.17.19/mod.d.ts"
import { build, stop } from 'https://deno.land/x/esbuild@v0.17.19/mod.js'
import { denoPlugins } from 'https://deno.land/x/esbuild_deno_loader@0.7.0/mod.ts'

async function esbuild(inPath: string, outPath: string) {
const { errors, warnings } = await build({
plugins: denoPlugins(),
entryPoints: [ inPath ],
outfile: outPath,
format: 'esm',
bundle: true,
minify: true,
jsxFactory: 'x',
jsxFragment: 'y'
})
errors.forEach(error => console.error(error))
warnings.forEach(warning => console.warn(warning))
}