Iβm Marco a Frontend DevEx Engineer @ Immobiliare.it.
microbundle.Iβm Marco a Frontend DevEx Engineer @ Immobiliare.it.
microbundle.tsup src/index.ts --format esm,cjs,iife --minify --dtstsup src/index.ts --format esm,cjs,iife --minify --dts
For the bundling process tsup uses:
tsup is a zero config bundler, but itβs possible to configure it with a tsup.config.ts file.
import { defineConfig } from 'tsup' export default defineConfig({ entry: ["src/index.ts"], format: ["cjs", "esm", "iife"], sourcemap: true, platform: "node", target: "node20", dts: true, });import { defineConfig } from 'tsup' export default defineConfig({ entry: ["src/index.ts"], format: ["cjs", "esm", "iife"], sourcemap: true, platform: "node", target: "node20", dts: true, });
dist βββ index.d.ts # types βββ index.mjs # esm βββ index.mjs.map # sourcemap βββ index.global.js # iife |ββ index.js # cjs βββ index.js.map # sourcemapdist βββ index.d.ts # types βββ index.mjs # esm βββ index.mjs.map # sourcemap βββ index.global.js # iife |ββ index.js # cjs βββ index.js.map # sourcemap
#!/bin/env node in your entry file, tsup will automatically make the output file executable.dependencies and devDependencies, but you can selective bundle them with noExternal option.metadata to defineConfig export metadata about the build process for visualize modules size in the bundle. You can pass it to Bundle Size Analyzer{ "json.schemas": [ { "url": "https://cdn.jsdelivr.net/npm/tsup/schema.json", "fileMatch": ["package.json", "tsup.config.json"] } ] }{ "json.schemas": [ { "url": "https://cdn.jsdelivr.net/npm/tsup/schema.json", "fileMatch": ["package.json", "tsup.config.json"] } ] }