-
Allow plugins to resolve injected files (#2754)
Previously paths passed to the
inject
feature were always interpreted as file system paths. This meant thatonResolve
plugins would not be run for them and esbuild's default path resolver would always be used. This meant that theinject
feature couldn't be used in the browser since the browser doesn't have access to a file system. This release runs paths passed toinject
through esbuild's full path resolution pipeline so plugins now have a chance to handle them usingonResolve
callbacks. This makes it possible to write a plugin that makes esbuild'sinject
work in the browser. -
Add the
empty
loader (#1541, #2753)The new
empty
loader tells esbuild to pretend that a file is empty. So for example--loader:.css=empty
effectively skips all imports of.css
files in JavaScript so that they aren't included in the bundle, sinceimport "./some-empty-file"
in JavaScript doesn't bundle anything. You can also use theempty
loader to remove asset references in CSS files. For example--loader:.png=empty
causes esbuild to replace asset references such asurl(image.png)
withurl()
so that they are no longer included in the resulting style sheet. -
Fix
</script>
and</style>
escaping for non-default targets (#2748)The change in version 0.16.0 to give control over
</script>
escaping via--supported:inline-script=false
or--supported:inline-script=true
accidentally broke automatic escaping of</script>
when an explicittarget
setting is specified. This release restores the correct automatic escaping of</script>
(which should not depend on whattarget
is set to). -
Enable the
exports
field withNODE_PATHS
(#2752)Node has a rarely-used feature where you can extend the set of directories that node searches for packages using the
NODE_PATHS
environment variable. While esbuild supports this too, previously it only supported the oldmain
field path resolution but did not support the newexports
field package resolution. This release makes the path resolution rules the same again for bothnode_modules
directories andNODE_PATHS
directories.