esbuild 0.19.1
-
Fix a regression with
baseURLintsconfig.json(#3307)The previous release moved
tsconfig.jsonpath resolution before--packages=externalchecks to allow thepathsfield intsconfig.jsonto avoid a package being marked as external. However, that reordering accidentally broke the behavior of thebaseURLfield fromtsconfig.json. This release moves these path resolution rules around again in an attempt to allow both of these cases to work. -
Parse TypeScript type arguments for JavaScript decorators (#3308)
When parsing JavaScript decorators in TypeScript (i.e. with
experimentalDecoratorsdisabled), esbuild previously didn't parse type arguments. Type arguments will now be parsed starting with this release. For example:@foo<number> @bar<number, string>() class Foo {} -
Fix glob patterns matching extra stuff at the end (#3306)
Previously glob patterns such as
./*.jswould incorrectly behave like./*.js*during path matching (also matching.js.mapfiles, for example). This was never intentional behavior, and has now been fixed. -
Change the permissions of esbuild's generated output files (#3285)
This release changes the permissions of the output files that esbuild generates to align with the default behavior of node's
fs.writeFileSyncfunction. Since most tools written in JavaScript usefs.writeFileSync, this should make esbuild more consistent with how other JavaScript build tools behave.The full Unix-y details: Unix permissions use three-digit octal notation where the three digits mean "user, group, other" in that order. Within a digit, 4 means "read" and 2 means "write" and 1 means "execute". So 6 == 4 + 2 == read + write. Previously esbuild uses 0644 permissions (the leading 0 means octal notation) but the permissions for
fs.writeFileSyncdefaults to 0666, so esbuild will now use 0666 permissions. This does not necessarily mean that the files esbuild generates will end up having 0666 permissions, however, as there is another Unix feature called "umask" where the operating system masks out some of these bits. If your umask is set to 0022 then the generated files will have 0644 permissions, and if your umask is set to 0002 then the generated files will have 0664 permissions. -
Fix a subtle CSS ordering issue with
@importand@layerWith this release, esbuild may now introduce additional
@layerrules when bundling CSS to better preserve the layer ordering of the input code. Here's an example of an edge case where this matters:/* entry.css */ @import "a.css"; @import "b.css"; @import "a.css";/* a.css */ @layer a { body { background: red; } }/* b.css */ @layer b { body { background: green; } }This CSS should set the body background to
green, which is what happens in the browser. Previously esbuild generated the following output which incorrectly sets the body background tored:/* b.css */ @layer b { body { background: green; } } /* a.css */ @layer a { body { background: red; } }This difference in behavior is because the browser evaluates
a.css+b.css+a.css(in CSS, each@importis replaced with a copy of the imported file) while esbuild was only writing outb.css+a.css. The first copy ofa.csswasn't being written out by esbuild for two reasons: 1) bundlers care about code size and try to avoid emitting duplicate CSS and 2) when there are multiple copies of a CSS file, normally only the last copy matters since the last declaration with equal specificity wins in CSS.However,
@layerwas recently added to CSS and for@layerthe first copy matters because layers are ordered using their first location in source code order. This introduction of@layermeans esbuild needs to change its bundling algorithm. An easy solution would be for esbuild to write outa.csstwice, but that would be inefficient. So what I'm going to try to have esbuild do with this release is to write out an abbreviated form of the first copy of a CSS file that only includes the@layerinformation, and then still only write out the full CSS file once for the last copy. So esbuild's output for this edge case now looks like this:/* a.css */ @layer a; /* b.css */ @layer b { body { background: green; } } /* a.css */ @layer a { body { background: red; } }The behavior of the bundled CSS now matches the behavior of the unbundled CSS. You may be wondering why esbuild doesn't just write out
a.cssfirst followed byb.css. That would work in this case but it doesn't work in general because for any rules outside of a@layerrule, the last copy should still win instead of the first copy. -
Fix a bug with esbuild's TypeScript type definitions (#3299)
This release fixes a copy/paste error with the TypeScript type definitions for esbuild's JS API:
export interface TsconfigRaw { compilerOptions?: { - baseUrl?: boolean + baseUrl?: string ... } }This fix was contributed by @privatenumber.