- feat: Export glob util
createMatchfrom/glob.
-
feat!: Add
--exclude:patternto exclude paths. When enabled without--include, it assumes all paths will be included, i.e.--include:**. It does not inherit from--externalwhich are directly passed to esbuild options.The implementation (include and exclude) is changed to matching esbuild's glob algorithm for smaller footprint. So the pattern only supports
*and**now.
- feat: Support glob patterns in
--include. - chore: Type definitions enable code splitting.
- refactor: Test
.esbuild-dev/package.jsoninstead of its parent dir.
- refactor: Disable
--cacheby default, it might be too aggressive.
- feat: Add
--cwdto change the working directory, it also affects the cache file logic.
- chore: Generate type definitions.
- feat: Add
--cacheand enable it by default. - refactor: Alias
temptotmp.
- fix: Path after
--importshould be an import specifier.
- feat: Shim
import.meta.{dirname,filename}. - refactor: Use
"type": "module"and change main file extension to.js. - refactor: Use
--importinstead of--loaderwhen possible.
- feat: Add
tempcommand to print the output directory. - feat: Add
--nodeto append node options instead of relying onNODE_OPTIONSenv.
- feat: Add
--drop-labelstoEsbuildFlags.
-
feat:
importFile()andrequireFile()can accept path with search params.
This is useful when you are running them on the same file but the file has changed since last import. For example you can make an esbuild svelte ssr plugin that even works in watch mode:onResolve({ filter: /index\.html$/ }, args => { return { path: args.path, namespace: "svelte-ssr" }; }); onLoad({ filter: /()/, namespace: "svelte-ssr" }, async args => { const svelteFile = findSvelteFile(args.path); const { default: App } = await importFile(svelteFile + "?t=" + Date.now(), { plugins: [svelte({ compilerOptions: { css: "none", generate: "ssr", hydratable: true } })], }); const { html, head } = App.render(); return { contents: renderHTML(args.path, { html, head }), loader: "copy" }; });
-
feat: Add
--line-limittoEsbuildFlags.
- fix: Wait for first build in watch mode.
- fix: Don't run output when there's error in build result.
- refactor: Await
context.watch(). - fix: Keep shebang when prepending shims.
- refactor!: Integrate esbuild 0.17's
contextapi.
- refactor: Lock
esbuildto<=0.16to avoid breaking changes.
- feat: Add
--packagestoEsbuildFlags. - feat!: Use
--packages=externalif possible and no--includeis provided.
- feat: Add
--aliastoEsbuildFlags.
- refatcor: Hack around
--shimsto make it work with--plugin.
- refactor: Improve
--shims(enabled by default) behavior.
Again, it has a caveat that--plugincannot be used with--shims.
- feat: Add
--jsx-side-effectstoEsbuildFlags.
- feat: Add
--include:nameto force include a package in the bundle.
- feat: Add
--jsx-import-sourceand--jsx-devtoEsbuildFlags.
- fix: Add
shortCircuitto loader api.
-
refactor: Correctly transform
--supportedto record of booleans. -
refactor!: Enable
--shimsby default. You can disable it by--shims=false.
Caveats:--shimscannot be used with--plugin, because oneonLoadcallback can only be called once per file. -
refactor: Temporary built file paths now have replaced
/to+for better debug purpose.
- feat: Add
--supportedand--log-overridetoEsbuildFlags.
-
feat: Add
--shimsto polyfillimport.meta.urland__dirname,__filename.
Below is the difference with/without this option:without
--shims:$ cat test/index.ts // WARN: do not use these words as key console.log({ import_meta_url: import.meta.url } as any); console.log({ filename: __filename } as any); $ esbuild-dev test/index.ts { import_meta_url: 'file:///Users/hyrious/esbuild-dev/node_modules/.esbuild-dev/test/index.ts.js' } /Users/hyrious/esbuild-dev/test/index.ts:3 console.log({ filename: __filename } as any); ^ ReferenceError: __filename is not defined in ES module scope $ esbuild-dev --cjs test/index.ts { import_meta_url: undefined } { filename: '/Users/hyrious/esbuild-dev/node_modules/.esbuild-dev/test/index.ts.cjs' }
with
--shims:$ esbuild-dev --shims test/index.ts { import_meta_url: 'file:///Users/hyrious/esbuild-dev/test/index.ts' } { filename: '/Users/hyrious/esbuild-dev/test/index.ts' } $ esbuild-dev --cjs --shims test/index.ts { import_meta_url: 'file:///Users/hyrious/esbuild-dev/test/index.ts' } { filename: '/Users/hyrious/esbuild-dev/test/index.ts' }
- feat: Forward child process exit code. (#19)
This feature was contributed by @tmueller.
- fix: Transform
manglerelated flags to RegExp.
This is still hand-written because there's no obvious way to generate it.
- feat: Add
manglerelated flags toEsbuildFlags.
Now this list is generated.
- feat: Add
--drop:toEsbuildFlags. - feat: Add
rsin watch mode to force rebuild and run.
- fix: (loader) Ignore url that are not file url in
load().
- feat: Add
--loaderto run file with--experimental-loader.
Note that it does not support esbuild plugins.
- fix: Fix using plugin from local file.
- package: Peer dependency
esbuild→*.
-
dep: Move esbuild to peer dependencies.
If you can not use this package at global environment, trynpm i -g esbuild. -
refactor: You can pass esbuild options through command line.
usage: esbuild-dev [esbuild options | esbuild-dev options] entry [...args] esbuild-dev --cjs --unknown-flag1 --jsx-factory=h main.ts --unknown-flag2 # same as `node main.js --unknown-flag1 --unknown-flag2`
Internally, it shares the same processing logic as esbuild's.
-
package: Target
node14.8→node16.13.
- dep: Upgrade esbuild to 0.14.x.
This is not a minor version upgrade. I guess there won't be any issue. Finally I will find a way to make esbuild a peer dependency, so that their versions can be decoupled.
- refactor: It will log warnings about not able to load plugins.
- dep: Upgrade esbuild to 0.13.x.
- fix: Missing args.d.ts in release.
- fix: Make it work in workspace by looking up 2 parent's package.json.
- types: Include args.d.ts in root path.
- fix: Fix a conversion bug in
buildOptionsToArgs(). - refactor: Now errors throw-ed by esbuild will not be printed twice.
-
fix: All flags after the entry are passed to script.
Previously, all flags are processed despite the side of them. This leads to a bad behavior:esbuild-dev --cjs --unknown-flag main.ts --help # prints esbuild-dev's help instead of calling `node main.js --help` # same as `esbuild-dev --help`
Now it was fixed. Flags after the entry are always passed to script. Note that unknown flags are also passed to the script for loose rule.
esbuild-dev --cjs --unknown-flag main.ts --help # same as `node main.js --unknown-flag --help` -
refactor:
argsToBuildOptionsandbuildOptionsToArgsnow accept & return bothBuildOptionsandTransformOptions.
-
refactor: Split esm dist files, so that
args()can be used without importing esbuild.
Note: you may have to add such shim.d.ts for correct types:declare module "@hyrious/esbuild-dev/args" { export { argsToBuildOptions, buildOptionsToArgs } from "@hyrious/esbuild-dev"; }
- feat: Add
--bareoption to cli commandexternal.
This option makes the output in the format of "one name per line". - refactor:
--target=esnextby default inexternal(). - refactor: Use
{}instead ofSetinexternal().
This minor change makes the result keep order on some platforms, which may be useful.
- feat:
external()to search external libraries. - cli: Sub command
externalto callexternal(). - feat:
buildOptionsToArgs()to reverseargsToBuildOptions().
- [BREAKING]: There's no
--buildany more. - Removed
chokidardependency, now it uses the builtin watch mode in esbuild.
This makes re-build/run slower, but will eat less CPU.
- feat: Support multiple build entries when use
--build.
For example:esbuild-dev --build src/index.ts src/bin.ts --outdir=lib. - feat: Support
--buildwithout entry file name.
In that case, it will infer your entries through package.json.
- fix:
importFile()use correct path url. - fix: Camelize keys when parsing args from command line.
- fix: Support
pkg.module. - feat:
requireFile()to dynamically require a file, remember to add--cjsto use it. - feat:
importFile()to dynamically import a file.
- fix: Incorrect watch files on first run.
- fix:
lookupFiletypo error. - feat: Support
--cjsforrequire.resolveusage. - fix: Remove
--enable-source-mapsin its bin file to prevent GitHub Action error.
- [BREAKING]: The outfile format is changed to
esm.__filenamereplacement is preserved for compatibility.require()will throw error, useimportinstead.
- Deps are discovered through esbuild metafile instead of scanning
importby hand. - Export names are changed:
esbuildRun→runFile,esbuildDev→watchFile.
- Bundle entry point to
node_modules/.esbuild-dev/file.jsand run it. - Watch and rebuild incrementally and rerun.
- Shortcut to call
esbuild --bundle. - Plugins support.