chore(deps): update dependency esbuild to ^0.18.0 #341
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^0.17.19->^0.18.0Release Notes
evanw/esbuild
v0.18.0Compare Source
This release deliberately contains backwards-incompatible changes. To avoid automatically picking up releases like this, you should either be pinning the exact version of
esbuildin yourpackage.jsonfile (recommended) or be using a version range syntax that only accepts patch upgrades such as^0.17.0or~0.17.0. See npm's documentation about semver for more information.The breaking changes in this release mainly focus on fixing some long-standing issues with esbuild's handling of
tsconfig.jsonfiles. Here are all the changes in this release, in detail:Add a way to try esbuild online (#797)
There is now a way to try esbuild live on esbuild's website without installing it: https://esbuild.github.io/try/. In addition to being able to more easily evaluate esbuild, this should also make it more efficient to generate esbuild bug reports. For example, you can use it to compare the behavior of different versions of esbuild on the same input. The state of the page is stored in the URL for easy sharing. Many thanks to @hyrious for creating https://hyrious.me/esbuild-repl/, which was the main inspiration for this addition to esbuild's website.
Two forms of build options are supported: either CLI-style (example) or JS-style (example). Both are converted into a JS object that's passed to esbuild's WebAssembly API. The CLI-style argument parser is a custom one that simulates shell quoting rules, and the JS-style argument parser is also custom and parses a superset of JSON (basically JSON5 + regular expressions). So argument parsing is an approximate simulation of what happens for real but hopefully it should be close enough.
Changes to esbuild's
tsconfig.jsonsupport (#3019):This release makes the following changes to esbuild's
tsconfig.jsonsupport:Using experimental decorators now requires
"experimentalDecorators": true(#104)Previously esbuild would always compile decorators in TypeScript code using TypeScript's experimental decorator transform. Now that standard JavaScript decorators are close to being finalized, esbuild will now require you to use
"experimentalDecorators": trueto do this. This new requirement makes it possible for esbuild to introduce a transform for standard JavaScript decorators in TypeScript code in the future. Such a transform has not been implemented yet, however.TypeScript's
targetno longer affects esbuild'starget(#2628)Some people requested that esbuild support TypeScript's
targetsetting, so support for it was added (in version 0.12.4). However, esbuild supports reading from multipletsconfig.jsonfiles within a single build, which opens up the possibility that different files in the build have different language targets configured. There isn't really any reason to do this and it can lead to unexpected results. So with this release, thetargetsetting intsconfig.jsonwill no longer affect esbuild's owntargetsetting. You will have to use esbuild's own target setting instead (which is a single, global value).TypeScript's
jsxsetting no longer causes esbuild to preserve JSX syntax (#2634)TypeScript has a setting called
jsxthat controls how to transform JSX into JS. The tool-agnostic transform is calledreact, and the React-specific transform is calledreact-jsx(orreact-jsxdev). There is also a setting calledpreservewhich indicates JSX should be passed through untransformed. Previously people would run esbuild with"jsx": "preserve"in theirtsconfig.jsonfiles and then be surprised when esbuild preserved their JSX. So with this release, esbuild will now ignore"jsx": "preserve"intsconfig.jsonfiles. If you want to preserve JSX syntax with esbuild, you now have to use--jsx=preserve.Note: Some people have suggested that esbuild's equivalent
jsxsetting override the one intsconfig.json. However, some projects need to legitimately have different files within the same build use different transforms (i.e.reactvs.react-jsx) and having esbuild's globaljsxsetting overridetsconfig.jsonwould prevent this from working. This release ignores"jsx": "preserve"but still allows otherjsxvalues intsconfig.jsonfiles to override esbuild's globaljsxsetting to keep the ability for multiple files within the same build to use different transforms.useDefineForClassFieldsbehavior has changed (#2584, #2993)Class fields in TypeScript look like this (
xis a class field):TypeScript has legacy behavior that uses assignment semantics instead of define semantics for class fields when
useDefineForClassFieldsis enabled (in which case class fields in TypeScript behave differently than they do in JavaScript, which is arguably "wrong").This legacy behavior exists because TypeScript added class fields to TypeScript before they were added to JavaScript. The TypeScript team decided to go with assignment semantics and shipped their implementation. Much later on TC39 decided to go with define semantics for class fields in JavaScript instead. This behaves differently if the base class has a setter with the same name:
When you run
tsc, the value ofuseDefineForClassFieldsdefaults tofalsewhen it's not specified and thetargetintsconfig.jsonis present but earlier thanES2022. This sort of makes sense because the class field language feature was added in ES2022, so before ES2022 class fields didn't exist (and thus TypeScript's legacy behavior is active). However, TypeScript'stargetsetting currently defaults toES3which unfortunately means that theuseDefineForClassFieldssetting currently defaults to false (i.e. to "wrong"). In other words if you runtscwith all default settings, class fields will behave incorrectly.Previously esbuild tried to do what
tscdid. That meant esbuild's version ofuseDefineForClassFieldswasfalseby default, and was alsofalseif esbuild's--target=was present but earlier thanes2022. However, TypeScript's legacy class field behavior is becoming increasingly irrelevant and people who expect class fields in TypeScript to work like they do in JavaScript are confused when they use esbuild with default settings. It's also confusing that the behavior of class fields would change if you changed the language target (even though that's exactly how TypeScript works).So with this release, esbuild will now only use the information in
tsconfig.jsonto determine whetheruseDefineForClassFieldsis true or not. SpecificallyuseDefineForClassFieldswill be respected if present, otherwise it will befalseiftargetis present intsconfig.jsonand isES2021or earlier, otherwise it will betrue. Targets passed to esbuild's--target=setting will no longer affectuseDefineForClassFields.Note that this means different directories in your build can have different values for this setting since esbuild allows different directories to have different
tsconfig.jsonfiles within the same build. This should let you migrate your code one directory at a time without esbuild's--target=setting affecting the semantics of your code.Add support for
verbatimModuleSyntaxfrom TypeScript 5.0TypeScript 5.0 added a new option called
verbatimModuleSyntaxthat deprecates and replaces two older options,preserveValueImportsandimportsNotUsedAsValues. SettingverbatimModuleSyntaxto true intsconfig.jsontells esbuild to not drop unused import statements. Specifically esbuild now treats"verbatimModuleSyntax": trueas if you had specified both"preserveValueImports": trueand"importsNotUsedAsValues": "preserve".Add multiple inheritance for
tsconfig.jsonfrom TypeScript 5.0TypeScript 5.0 now allows multiple inheritance for
tsconfig.jsonfiles. You can now pass an array of filenames via theextendsparameter and yourtsconfig.jsonwill start off containing properties from all of those configuration files, in order. This release of esbuild adds support for this new TypeScript feature.Remove support for
moduleSuffixes(#2395)The community has requested that esbuild remove support for TypeScript's
moduleSuffixesfeature, so it has been removed in this release. Instead you can use esbuild's--resolve-extensions=feature to select which module suffix you want to build with.Apply
--tsconfig=overrides tostdinand virtual files (#385, #2543)When you override esbuild's automatic
tsconfig.jsonfile detection with--tsconfig=to pass a specifictsconfig.jsonfile, esbuild previously didn't apply these settings to source code passed via thestdinAPI option or to TypeScript files from plugins that weren't in thefilenamespace. This release changes esbuild's behavior so that settings fromtsconfig.jsonalso apply to these source code files as well.Support
--tsconfig-raw=in build API calls (#943, #2440)Previously if you wanted to override esbuild's automatic
tsconfig.jsonfile detection, you had to create a newtsconfig.jsonfile and pass the file name to esbuild via the--tsconfig=flag. With this release, you can now optionally use--tsconfig-raw=instead to pass the contents oftsconfig.jsonto esbuild directly instead of passing the file name. For example, you can now use--tsconfig-raw={"compilerOptions":{"experimentalDecorators":true}}to enable TypeScript experimental decorators directly using a command-line flag (assuming you escape the quotes correctly using your current shell's quoting rules). The--tsconfig-raw=flag previously only worked with transform API calls but with this release, it now works with build API calls too.Ignore all
tsconfig.jsonfiles innode_modules(#276, #2386)This changes esbuild's behavior that applies
tsconfig.jsonto all files in the subtree of the directory containingtsconfig.json. In version 0.12.7, esbuild started ignoringtsconfig.jsonfiles insidenode_modulesfolders. The rationale is that people typically do this by mistake and that doing this intentionally is a rare use case that doesn't need to be supported. However, this change only applied to certain syntax-specific settings (e.g.jsxFactory) but did not apply to path resolution settings (e.g.paths). With this release, esbuild will now ignore alltsconfig.jsonfiles innode_modulesinstead of only ignoring certain settings.Ignore
tsconfig.jsonwhen resolving paths withinnode_modules(#2481)Previously fields in
tsconfig.jsonrelated to path resolution (e.g.paths) were respected for all files in the subtree containing thattsconfig.jsonfile, even within a nestednode_modulessubdirectory. This meant that a project'spathssettings could potentially affect any bundled packages. With this release, esbuild will no longer usetsconfig.jsonsettings during path resolution inside nestednode_modulessubdirectories.Prefer
.jsover.tswithinnode_modules(#3019)The default list of implicit extensions that esbuild will try appending to import paths contains
.tsbefore.js. This makes it possible to bundle TypeScript projects that reference other files in the project using extension-less imports (e.g../some-fileto load./some-file.tsinstead of./some-file.js). However, this behavior is undesirable withinnode_modulesdirectories. Some package authors publish both their original TypeScript code and their compiled JavaScript code side-by-side. In these cases, esbuild should arguably be using the compiled JavaScript files instead of the original TypeScript files because the TypeScript compilation settings for files within the package should be determined by the package author, not the user of esbuild. So with this release, esbuild will now prefer implicit.jsextensions over.tswhen searching for import paths withinnode_modules.These changes are intended to improve esbuild's compatibility with
tscand reduce the number of unfortunate behaviors regardingtsconfig.jsonand esbuild.Add a workaround for bugs in Safari 16.2 and earlier (#3072)
Safari's JavaScript parser had a bug (which has now been fixed) where at least something about unary/binary operators nested inside default arguments nested inside either a function or class expression was incorrectly considered a syntax error if that expression was the target of a property assignment. Here are some examples that trigger this Safari bug:
It's not clear what the exact conditions are that trigger this bug. However, a workaround for this bug appears to be to post-process your JavaScript to wrap any in function and class declarations that are the direct target of a property access expression in parentheses. That's the workaround that UglifyJS applies for this issue: mishoo/UglifyJS#2056. So that's what esbuild now does starting with this release:
This fix is not enabled by default. It's only enabled when
--target=contains Safari 16.2 or earlier, such as with--target=safari16.2. You can also explicitly enable or disable this specific transform (calledfunction-or-class-property-access) with--supported:function-or-class-property-access=false.Fix esbuild's TypeScript type declarations to forbid unknown properties (#3089)
Version 0.17.0 of esbuild introduced a specific form of function overloads in the TypeScript type definitions for esbuild's API calls that looks like this:
This more accurately reflects how esbuild's JavaScript API behaves. The result object returned by
transformSynconly has thelegalCommentsproperty if you passlegalComments: 'external':However, this form of function overloads unfortunately allows typos (e.g.
egalComments) to pass the type checker without generating an error as TypeScript allows all objects with unknown properties to extendTransformOptions. These typos result in esbuild's API throwing an error at run-time.To prevent typos during type checking, esbuild's TypeScript type definitions will now use a different form that looks like this:
This change should hopefully not affect correct code. It should hopefully introduce type errors only for incorrect code.
Fix CSS nesting transform for pseudo-elements (#3119)
This release fixes esbuild's CSS nesting transform for pseudo-elements (e.g.
::beforeand::after). The CSS nesting specification says that the nesting selector does not work with pseudo-elements. This can be seen in the example below: esbuild does not carry the parent pseudo-element::beforethrough the nesting selector&. However, that doesn't apply to pseudo-elements that are within the same selector. Previously esbuild had a bug where it considered pseudo-elements in both locations as invalid. This release changes esbuild to only consider those from the parent selector invalid, which should align with the specification:Forbid
&before a type selector in nested CSSThe people behind the work-in-progress CSS nesting specification have very recently decided to forbid nested CSS that looks like
&div. You will have to use eitherdiv&or&:is(div)instead. This release of esbuild has been updated to take this new change into consideration. Doing this now generates a warning. The suggested fix is slightly different depending on where in the overall selector it happened:Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.