esbuild 0.16.8
-
Allow plugins to resolve injected files (#2754)
Previously paths passed to the
injectfeature were always interpreted as file system paths. This meant thatonResolveplugins would not be run for them and esbuild's default path resolver would always be used. This meant that theinjectfeature couldn't be used in the browser since the browser doesn't have access to a file system. This release runs paths passed toinjectthrough esbuild's full path resolution pipeline so plugins now have a chance to handle them usingonResolvecallbacks. This makes it possible to write a plugin that makes esbuild'sinjectwork in the browser. -
Add the
emptyloader (#1541, #2753)The new
emptyloader tells esbuild to pretend that a file is empty. So for example--loader:.css=emptyeffectively skips all imports of.cssfiles 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 theemptyloader to remove asset references in CSS files. For example--loader:.png=emptycauses 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=falseor--supported:inline-script=trueaccidentally broke automatic escaping of</script>when an explicittargetsetting is specified. This release restores the correct automatic escaping of</script>(which should not depend on whattargetis set to). -
Enable the
exportsfield 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_PATHSenvironment variable. While esbuild supports this too, previously it only supported the oldmainfield path resolution but did not support the newexportsfield package resolution. This release makes the path resolution rules the same again for bothnode_modulesdirectories andNODE_PATHSdirectories.