ioredis-mock
ioredis-mock copied to clipboard
chore(deps): update devdependencies (non-major)
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| @babel/cli (source) | 7.17.10 -> 7.18.9 |
||||
| @babel/core (source) | 7.18.2 -> 7.18.9 |
||||
| @babel/preset-env (source) | 7.18.2 -> 7.18.9 |
||||
| @babel/register (source) | 7.17.7 -> 7.18.9 |
||||
| esbuild | 0.14.42 -> 0.14.51 |
||||
| ioredis | 5.0.6 -> 5.2.2 |
||||
| jest (source) | 28.1.0 -> 28.1.3 |
||||
| jest-circus | 28.1.0 -> 28.1.3 |
||||
| jest-environment-jsdom | 28.1.0 -> 28.1.3 |
||||
| prettier (source) | 2.6.2 -> 2.7.1 |
||||
| prettier-package-json | 2.6.3 -> 2.6.4 |
Release Notes
babel/babel
v7.18.9
:bug: Bug Fix
babel-plugin-transform-modules-systemjs,babel-typesbabel-generator- #14758 fix:
returnTypewith comments generates incorrect code (@liuxingbaoyu)
- #14758 fix:
:nail_care: Polish
babel-cli- #14748 Print a message when the watcher of
babel-cliis ready. (@liuxingbaoyu)
- #14748 Print a message when the watcher of
:house: Internal
babel-core,babel-helper-remap-async-to-generator,babel-helpers,babel-parser,babel-plugin-transform-block-scoping,babel-preset-env- #13414 Prepare for compiling Babel to native ESM (@nicolo-ribaudo)
babel-helper-create-class-features-plugin,babel-helper-member-expression-to-functions,babel-helper-remap-async-to-generator,babel-helper-replace-supers,babel-helper-wrap-function,babel-helpers,babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining,babel-plugin-proposal-decorators,babel-plugin-proposal-object-rest-spread,babel-plugin-proposal-optional-chaining,babel-plugin-transform-block-scoping,babel-plugin-transform-classes,babel-traverse,babel-types
:running_woman: Performance
babel-generator- #14701 perf: Improve generator perf (@liuxingbaoyu)
v7.18.6
:eyeglasses: Spec Compliance
babel-parser- #14650 [ts] Disallow property access after instantiation expression (@nicolo-ribaudo)
- #14636 [ts] Allow
...<...>followed by newline or binary operator (@nicolo-ribaudo)
babel-generator,babel-parser,babel-preset-env,babel-template
:bug: Bug Fix
babel-helper-remap-async-to-generator,babel-plugin-proposal-async-generator-functions- #14391 Transform
awaitin computed class keys (@Yokubjon-J)
- #14391 Transform
babel-plugin-transform-parameters- #14694 fix: preserve function params type if possible (@magic-akari)
babel-core- #14583 fix: Memory leak when deep cloning in
babel-core(@liuxingbaoyu)
- #14583 fix: Memory leak when deep cloning in
babel-core,babel-helper-check-duplicate-nodes,babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression,babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining,babel-plugin-proposal-destructuring-private,babel-plugin-proposal-optional-chaining,babel-plugin-transform-runtime- #14663 Fix
import { types } from "@​babel/core"with native ESM (@nicolo-ribaudo)
- #14663 Fix
:house: Internal
babel-standalone- #14697 Add
proposal-unicode-sets-regexto@babel/standalone(@nicolo-ribaudo)
- #14697 Add
- Other
- #14687 chore: Update bench baselines (@liuxingbaoyu)
babel-generator,babel-typesbabel-code-frame,babel-core,babel-generator,babel-helper-annotate-as-pure,babel-helper-builder-binary-assignment-operator-visitor,babel-helper-builder-react-jsx,babel-helper-check-duplicate-nodes,babel-helper-compilation-targets,babel-helper-create-class-features-plugin,babel-helper-create-regexp-features-plugin,babel-helper-define-map,babel-helper-explode-assignable-expression,babel-helper-fixtures,babel-helper-function-name,babel-helper-hoist-variables,babel-helper-member-expression-to-functions,babel-helper-module-imports,babel-helper-module-transforms,babel-helper-optimise-call-expression,babel-helper-plugin-test-runner,babel-helper-plugin-utils,babel-helper-remap-async-to-generator,babel-helper-replace-supers,babel-helper-simple-access,babel-helper-split-export-declaration,babel-helper-transform-fixture-test-runner,babel-helper-validator-option,babel-helper-wrap-function,babel-helpers,babel-highlight,babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining,babel-plugin-external-helpers,babel-plugin-proposal-async-generator-functions,babel-plugin-proposal-class-static-block,babel-plugin-proposal-decorators,babel-plugin-proposal-destructuring-private,babel-plugin-proposal-function-bind,babel-plugin-proposal-function-sent,babel-plugin-proposal-json-strings,babel-plugin-proposal-object-rest-spread,babel-plugin-proposal-optional-chaining,babel-plugin-proposal-partial-application,babel-plugin-proposal-pipeline-operator,babel-plugin-proposal-private-property-in-object,babel-plugin-proposal-record-and-tuple,babel-plugin-syntax-typescript,babel-plugin-transform-block-scoped-functions,babel-plugin-transform-block-scoping,babel-plugin-transform-classes,babel-plugin-transform-computed-properties,babel-plugin-transform-destructuring,babel-plugin-transform-duplicate-keys,babel-plugin-transform-exponentiation-operator,babel-plugin-transform-flow-comments,babel-plugin-transform-flow-strip-types,babel-plugin-transform-for-of,babel-plugin-transform-function-name,babel-plugin-transform-modules-amd,babel-plugin-transform-modules-commonjs,babel-plugin-transform-modules-systemjs,babel-plugin-transform-modules-umd,babel-plugin-transform-object-super,babel-plugin-transform-parameters,babel-plugin-transform-property-mutators,babel-plugin-transform-proto-to-assign,babel-plugin-transform-react-constant-elements,babel-plugin-transform-react-display-name,babel-plugin-transform-react-inline-elements,babel-plugin-transform-react-jsx-compat,babel-plugin-transform-react-jsx-source,babel-plugin-transform-react-jsx,babel-plugin-transform-runtime,babel-plugin-transform-typescript,babel-plugin-transform-unicode-escapes,babel-preset-env,babel-preset-typescript,babel-standalone,babel-template,babel-traverse,babel-typesbabel-core,babel-helper-transform-fixture-test-runner,babel-plugin-transform-destructuring- #14659 Run Babel asynchronously in fixtures (@nicolo-ribaudo)
evanw/esbuild
v0.14.51
-
Add support for React 17's
automaticJSX transform (#334, #718, #1172, #2318, #2349)This adds support for the new "automatic" JSX runtime from React 17+ to esbuild for both the build and transform APIs.
New CLI flags and API options:
--jsx,jsx— Set this to"automatic"to opt in to this new transform--jsx-dev,jsxDev— Toggles development mode for the automatic runtime--jsx-import-source,jsxImportSource— Overrides the root import for runtime functions (default"react")
New JSX pragma comments:
@jsxRuntime— Sets the runtime (automaticorclassic)@jsxImportSource— Sets the import source (only valid with automatic runtime)
The existing
@jsxFragmentand@jsxFactorypragma comments are only valid with "classic" runtime.TSConfig resolving: Along with accepting the new options directly via CLI or API, option inference from
tsconfig.jsoncompiler options was also implemented:"jsx": "preserve"or"jsx": "react-native"→ Same as--jsx=preservein esbuild"jsx": "react"→ Same as--jsx=transformin esbuild (which is the default behavior)"jsx": "react-jsx"→ Same as--jsx=automaticin esbuild"jsx": "react-jsxdev"→ Same as--jsx=automatic --jsx-devin esbuild
It also reads the value of
"jsxImportSource"fromtsconfig.jsonif specified.For
react-jsxit's important to note that it doesn't implicitly disable--jsx-dev. This is to support the case where a user sets"react-jsx"in theirtsconfig.jsonbut then toggles development mode directly in esbuild.esbuild vs Babel vs TS vs...
There are a few differences between the various technologies that implement automatic JSX runtimes. The JSX transform in esbuild follows a mix of Babel's and TypeScript's behavior:
-
When an element has
__sourceor__selfprops:- Babel: Print an error about a deprecated transform plugin
- TypeScript: Allow the props
- swc: Hard crash
- esbuild: Print an error — Following Babel was chosen for this one because this might help people catch configuration issues where JSX files are being parsed by multiple tools
-
Element has an "implicit true" key prop, e.g.
<a key />:- Babel: Print an error indicating that "key" props require an explicit value
- TypeScript: Silently omit the "key" prop
- swc: Hard crash
- esbuild: Print an error like Babel — This might help catch legitimate programming mistakes
-
Element has spread children, e.g.
<a>{...children}</a>- Babel: Print an error stating that React doesn't support spread children
- TypeScript: Use static jsx function and pass children as-is, including spread operator
- swc: same as Babel
- esbuild: Same as TypeScript
Also note that TypeScript has some bugs regarding JSX development mode and the generation of
lineNumberandcolumnNumbervalues. Babel's values are accurate though, so esbuild's line and column numbers match Babel. Both numbers are 1-based and columns are counted in terms of UTF-16 code units.This feature was contributed by @jgoz.
v0.14.50
-
Emit
namesin source maps (#1296)The source map specification includes an optional
namesfield that can associate an identifier with a mapping entry. This can be used to record the original name for an identifier, which is useful if the identifier was renamed to something else in the generated code. When esbuild was originally written, this field wasn't widely used, but now there are some debuggers that make use of it to provide better debugging of minified code. With this release, esbuild now includes anamesfield in the source maps that it generates. To save space, the original name is only recorded when it's different from the final name. -
Update parser for arrow functions with initial default type parameters in
.tsxfiles (#2410)TypeScript 4.6 introduced a change to the parsing of JSX syntax in
.tsxfiles. Now a<token followed by an identifier and then a=token is parsed as an arrow function with a default type parameter instead of as a JSX element. This release updates esbuild's parser to match TypeScript's parser. -
Fix an accidental infinite loop with
--definesubstitution (#2407)This is a fix for a regression that was introduced in esbuild version 0.14.44 where certain
--definesubstitutions could result in esbuild crashing with a stack overflow. The problem was an incorrect fix for #2292. The fix merged the code paths for--defineand--jsx-factoryrewriting since the value substitution is now the same for both. However, doing this accidentally made--definesubstitution recursive since the JSX factory needs to be able to match against--definesubstitutions to integrate with the--injectfeature. The fix is to only do one additional level of matching against define substitutions, and to only do this for JSX factories. Now these cases are able to build successfully without a stack overflow. -
Include the "public path" value in hashes (#2403)
The
--public-path=configuration value affects the paths that esbuild uses to reference files from other files and is used in various situations such as cross-chunk imports in JS and references to asset files from CSS files. However, it wasn't included in the hash calculations used for file names due to an oversight. This meant that changing the public path setting incorrectly didn't result in the hashes in file names changing even though the contents of the files changed. This release fixes the issue by including a hash of the public path in all non-asset output files. -
Fix a cross-platform consistency bug (#2383)
Previously esbuild would minify
0xFFFF_FFFF_FFFF_FFFFas0xffffffffffffffff(18 bytes) on arm64 chips and as18446744073709552e3(19 bytes) on x86_64 chips. The reason was that the number was converted to a 64-bit unsigned integer internally for printing as hexadecimal, the 64-bit floating-point number0xFFFF_FFFF_FFFF_FFFFis actually0x1_0000_0000_0000_0180(i.e. it's rounded up, not down), and convertingfloat64touint64is implementation-dependent in Go when the input is out of bounds. This was fixed by changing the upper limit for which esbuild uses hexadecimal numbers during minification to0xFFFF_FFFF_FFFF_F800, which is the next representable 64-bit floating-point number below0x1_0000_0000_0000_0180, and which fits in auint64. As a result, esbuild will now consistently never minify0xFFFF_FFFF_FFFF_FFFFas0xffffffffffffffffanymore, which means the output should now be consistent across platforms. -
Fix a hang with the synchronous API when the package is corrupted (#2396)
An error message is already thrown when the esbuild package is corrupted and esbuild can't be run. However, if you are using a synchronous call in the JavaScript API in worker mode, esbuild will use a child worker to initialize esbuild once so that the overhead of initializing esbuild can be amortized across multiple synchronous API calls. However, errors thrown during initialization weren't being propagated correctly which resulted in a hang while the main thread waited forever for the child worker to finish initializing. With this release, initialization errors are now propagated correctly so calling a synchronous API call when the package is corrupted should now result in an error instead of a hang.
-
Fix
tsconfig.jsonfiles that collide with directory names (#2411)TypeScript lets you write
tsconfig.jsonfiles withextendsclauses that refer to another config file using an implicit.jsonfile extension. However, if the config file without the.jsonextension existed as a directory name, esbuild and TypeScript had different behavior. TypeScript ignores the directory and continues looking for the config file by adding the.jsonextension while esbuild previously terminated the search and then failed to load the config file (because it's a directory). With this release, esbuild will now ignore exact matches when resolvingextendsfields intsconfig.jsonfiles if the exact match results in a directory. -
Add
platformto the transform API (#2362)The
platformoption is mainly relevant for bundling because it mostly affects path resolution (e.g. activating the"browser"field inpackage.jsonfiles), so it was previously only available for the build API. With this release, it has additionally be made available for the transform API for a single reason: you can now set--platform=nodewhen transforming a string so that esbuild will add export annotations for node, which is only relevant when--format=cjsis also present.This has to do with an implementation detail of node that parses the AST of CommonJS files to discover named exports when importing CommonJS from ESM. However, this new addition to esbuild's API is of questionable usefulness. Node's loader API (the main use case for using esbuild's transform API like this) actually bypasses the content returned from the loader and parses the AST that's present on the file system, so you won't actually be able to use esbuild's API for this. See the linked issue for more information.
v0.14.49
-
Keep inlined constants when direct
evalis present (#2361)Version 0.14.19 of esbuild added inlining of certain
constvariables during minification, which replaces all references to the variable with the initializer and then removes the variable declaration. However, this could generate incorrect code when directevalis present because the directevalcould reference the constant by name. This release fixes the problem by preserving theconstvariable declaration in this case:// Original code console.log((() => { const x = 123; return x + eval('x') })) // Old output (with --minify) console.log(()=>123+eval("x")); // New output (with --minify) console.log(()=>{const x=123;return 123+eval("x")}); -
Fix an incorrect error in TypeScript when targeting ES5 (#2375)
Previously when compiling TypeScript code to ES5, esbuild could incorrectly consider the following syntax forms as a transformation error:
0 ? ([]) : 1 ? ({}) : 2;The error messages looked like this:
✘ [ERROR] Transforming destructuring to the configured target environment ("es5") is not supported yet example.ts:1:5: 1 │ 0 ? ([]) : 1 ? ({}) : 2; ╵ ^ ✘ [ERROR] Transforming destructuring to the configured target environment ("es5") is not supported yet example.ts:1:16: 1 │ 0 ? ([]) : 1 ? ({}) : 2; ╵ ^These parenthesized literals followed by a colon look like the start of an arrow function expression followed by a TypeScript return type (e.g.
([]) : 1could be the start of the TypeScript arrow function([]): 1 => 1). Unlike in JavaScript, parsing arrow functions in TypeScript requires backtracking. In this case esbuild correctly determined that this expression wasn't an arrow function after all but the check for destructuring was incorrectly not covered under the backtracking process. With this release, the error message is now only reported if the parser successfully parses an arrow function without backtracking. -
Fix generated TypeScript
enumcomments containing*/(#2369, #2371)TypeScript
enumvalues that are equal to a number or string literal are inlined (references to the enum are replaced with the literal value) and have a/* ... */comment after them with the original enum name to improve readability. However, this comment is omitted if the enum name contains the character sequence*/because that would end the comment early and cause a syntax error:// Original TypeScript enum Foo { '/*' = 1, '*/' = 2 } console.log(Foo['/*'], Foo['*/']) // Generated JavaScript console.log(1 /* /* */, 2);This was originally handled correctly when TypeScript
enuminlining was initially implemented since it was only supported within a single file. However, when esbuild was later extended to support TypeScriptenuminlining across files, this special case where the enum name contains*/was not handled in that new code. Starting with this release, esbuild will now handle enums with names containing*/correctly when they are inlined across files:// foo.ts export enum Foo { '/*' = 1, '*/' = 2 } // bar.ts import { Foo } from './foo' console.log(Foo['/*'], Foo['*/']) // Old output (with --bundle --format=esm) console.log(1 /* /* */, 2 /* */ */); // New output (with --bundle --format=esm) console.log(1 /* /* */, 2);This fix was contributed by @magic-akari.
-
Allow
declareclass fields to be initialized (#2380)This release fixes an oversight in the TypeScript parser that disallowed initializers for
declareclass fields. TypeScript actually allows the following limited initializer expressions forreadonlyfields:declare const enum a { b = 0 } class Foo { // These are allowed by TypeScript declare readonly a = 0 declare readonly b = -0 declare readonly c = 0n declare readonly d = -0n declare readonly e = 'x' declare readonly f = `x` declare readonly g = a.b declare readonly h = a['b'] // These are not allowed by TypeScript declare readonly x = (0) declare readonly y = null declare readonly z = -a.b }So with this release, esbuild now allows initializers for
declareclass fields too. To future-proof this in case TypeScript allows more expressions as initializers in the future (such asnull), esbuild will allow any expression as an initializer and will leave the specifics of TypeScript's special-casing here to the TypeScript type checker. -
Fix a bug in esbuild's feature compatibility table generator (#2365)
Passing specific JavaScript engines to esbuild's
--targetflag restricts esbuild to only using JavaScript features that are supported on those engines in the output files that esbuild generates. The data for this feature is automatically derived from this compatibility table with a script: https://kangax.github.io/compat-table/.However, the script had a bug that could incorrectly consider a JavaScript syntax feature to be supported in a given engine even when it doesn't actually work in that engine. Specifically this bug happened when a certain aspect of JavaScript syntax has always worked incorrectly in that engine and the bug in that engine has never been fixed. This situation hasn't really come up before because previously esbuild pretty much only targeted JavaScript engines that always fix their bugs, but the two new JavaScript engines that were added in the previous release (Hermes and Rhino) have many aspects of the JavaScript specification that have never been implemented, and may never be implemented. For example, the
letandconstkeywords are not implemented correctly in those engines.With this release, esbuild's compatibility table generator script has been fixed and as a result, esbuild will now correctly consider a JavaScript syntax feature to be unsupported in a given engine if there is some aspect of that syntax that is broken in all known versions of that engine. This means that the following JavaScript syntax features are no longer considered to be supported by these engines (represented using esbuild's internal names for these syntax features):
Hermes:
arrowconst-and-letdefault-argumentgeneratoroptional-catch-bindingoptional-chainrest-argumenttemplate-literal
Rhino:
arrowconst-and-letdestructuringfor-ofgeneratorobject-extensionstemplate-literal
IE:
const-and-let
v0.14.48
-
Enable using esbuild in Deno via WebAssembly (#2323)
The native implementation of esbuild is much faster than the WebAssembly version, but some people don't want to give Deno the
--allow-runpermission necessary to run esbuild and are ok waiting longer for their builds to finish when using the WebAssembly backend. With this release, you can now use esbuild via WebAssembly in Deno. To do this you will need to import fromwasm.jsinstead ofmod.js:import * as esbuild from 'https://deno.land/x/[email protected]/wasm.js' const ts = 'let test: boolean = true' const result = await esbuild.transform(ts, { loader: 'ts' }) console.log('result:', result)Make sure you run Deno with
--allow-netso esbuild can download the WebAssembly module. Using esbuild like this starts up a worker thread that runs esbuild in parallel (unless you callesbuild.initialize({ worker: false })to tell esbuild to run on the main thread). If you want to, you can callesbuild.stop()to terminate the worker if you won't be using esbuild anymore and you want to reclaim the memory.Note that Deno appears to have a bug where background WebAssembly optimization can prevent the process from exiting for many seconds. If you are trying to use Deno and WebAssembly to run esbuild quickly, you may need to manually call
Deno.exit(0)after your code has finished running. -
Add support for font file MIME types (#2337)
This release adds support for font file MIME types to esbuild, which means they are now recognized by the built-in local web server and they are now used when a font file is loaded using the
dataurlloader. The full set of newly-added file extension MIME type mappings is as follows:.eot=>application/vnd.ms-fontobject.otf=>font/otf.sfnt=>font/sfnt.ttf=>font/ttf.woff=>font/woff.woff2=>font/woff2
-
Remove
"use strict";when targeting ESM (#2347)All ES module code is automatically in strict mode, so a
"use strict";directive is unnecessary. With this release, esbuild will now remove the"use strict";directive if the output format is ESM. This change makes the generated output file a few bytes smaller:// Original code 'use strict' export let foo = 123 // Old output (with --format=esm --minify) "use strict";let t=123;export{t as foo}; // New output (with --format=esm --minify) let t=123;export{t as foo}; -
Attempt to have esbuild work with Deno on FreeBSD (#2356)
Deno doesn't support FreeBSD, but it's possible to build Deno for FreeBSD with some additional patches on top. This release of esbuild changes esbuild's Deno installer to download esbuild's FreeBSD binary in this situation. This configuration is unsupported although in theory everything should work.
-
Add some more target JavaScript engines (#2357)
This release adds the Rhino and Hermes JavaScript engines to the set of engine identifiers that can be passed to the
--targetflag. You can use this to restrict esbuild to only using JavaScript features that are supported on those engines in the output files that esbuild generates.
v0.14.47
-
Make global names more compact when
||=is available (#2331)With this release, the code esbuild generates for the
--global-name=setting is now slightly shorter when you don't configure esbuild such that the||=operator is unsupported (e.g. with--target=chrome80or--supported:logical-assignment=false):// Original code exports.foo = 123 // Old output (with --format=iife --global-name=foo.bar.baz --minify) var foo=foo||{};foo.bar=foo.bar||{};foo.bar.baz=(()=>{var b=(a,o)=>()=>(o||a((o={exports:{}}).exports,o),o.exports);var c=b(f=>{f.foo=123});return c();})(); // New output (with --format=iife --global-name=foo.bar.baz --minify) var foo;((foo||={}).bar||={}).baz=(()=>{var b=(a,o)=>()=>(o||a((o={exports:{}}).exports,o),o.exports);var c=b(f=>{f.foo=123});return c();})(); -
Fix
--mangle-quoted=falsewith--minify-syntax=trueIf property mangling is active and
--mangle-quotedis disabled, quoted properties are supposed to be preserved. However, there was a case when this didn't happen if--minify-syntaxwas enabled, since that internally transformsx['y']intox.yto reduce code size. This issue has been fixed:// Original code x.foo = x['bar'] = { foo: y, 'bar': z } // Old output (with --mangle-props=. --mangle-quoted=false --minify-syntax=true) x.a = x.b = { a: y, bar: z }; // New output (with --mangle-props=. --mangle-quoted=false --minify-syntax=true) x.a = x.bar = { a: y, bar: z };Notice how the property
foois always used unquoted but the propertybaris always used quoted, sofooshould be consistently mangled whilebarshould be consistently not mangled. -
Fix a minification bug regarding
thisand property initializersWhen minification is enabled, esbuild attempts to inline the initializers of variables that have only been used once into the start of the following expression to reduce code size. However, there was a bug where this transformation could change the value of
thiswhen the initializer is a property access and the start of the following expression is a call expression. This release fixes the bug:// Original code function foo(obj) { let fn = obj.prop; fn(); } // Old output (with --minify) function foo(f){f.prop()} // New output (with --minify) function foo(o){let f=o.prop;f()}
v0.14.46
-
Add the ability to override support for individual syntax features (#2060, #2290, #2308)
The
targetsetting already lets you configure esbuild to restrict its output by only making use of syntax features that are known to be supported in the configured target environment. For example, settingtargettochrome50causes esbuild to automatically transform optional chain expressions into the equivalent older JavaScript and prevents you from using BigInts, among many other things. However, sometimes you may want to customize this set of unsupported syntax features at the individual feature level.Some examples of why you might want to do this:
-
JavaScript runtimes often do a quick implementation of newer syntax features that is slower than the equivalent older JavaScript, and you can get a speedup by telling esbuild to pretend this syntax feature isn't supported. For example, V8 has a long-standing performance bug regarding object spread that can be avoided by manually copying properties instead of using object spread syntax. Right now esbuild hard-codes this optimization if you set
targetto a V8-based runtime. -
There are many less-used JavaScript runtimes in addition to the ones present in browsers, and these runtimes sometimes just decide not to implement parts of the specification, which might make sense for runtimes intended for embedded environments. For example, the developers behind Facebook's JavaScript runtime Hermes have decided to not implement classes despite it being a major JavaScript feature that was added seven years ago and that is used in virtually every large JavaScript project.
-
You may be processing esbuild's output with another tool, and you may want esbuild to transform certain features and the other tool to transform certain other features. For example, if you are using esbuild to transform files individually to ES5 but you are then feeding the output into Webpack for bundling, you may want to preserve
import()expressions even though they are a syntax error in ES5.
With this release, you can now use
--supported:feature=falseto forcefeatureto be unsupported. This will cause esbuild to either rewrite code that uses the feature into older code that doesn't use the feature (if esbuild is able to), or to emit a build error (if esbuild is unable to). For example, you can use--supported:arrow=falseto turn arrow functions into function expressions and--supported:bigint=falseto make it an error to use a BigInt literal. You can also use--supported:feature=trueto force it to be supported, which means esbuild will pass it through without transforming it. Keep in mind that this is an advanced feature. For most use cases you will probably want to just usetargetinstead of using this.The full set of currently-allowed features are as follows:
JavaScript:
arbitrary-module-namespace-namesarray-spreadarrowasync-awaitasync-generatorbigintclassclass-fieldclass-private-accessorclass-private-brand-checkclass-private-fieldclass-private-methodclass-private-static-accessorclass-private-static-fieldclass-private-static-methodclass-static-blocksclass-static-fieldconst-and-letdefault-argumentdestructuringdynamic-importexponent-operatorexport-star-asfor-awaitfor-ofgeneratorhashbangimport-assertionsimport-metalogical-assignmentnested-rest-bindingnew-targetnode-colon-prefix-importnode-colon-prefix-requirenullish-coalescingobject-accessorsobject-extensionsobject-rest-spreadoptional-catch-bindingoptional-chainregexp-dot-all-flagregexp-lookbehind-assertionsregexp-match-indicesregexp-named-capture-groupsregexp-sticky-and-unicode-flagsregexp-unicode-property-escapesrest-argumenttemplate-literaltop-level-awaittypeof-exotic-object-is-objectunicode-escapes
CSS:
hex-rgbarebecca-purplemodern-rgb-hslinset-propertynesting
Since you can now specify
--supported:object-rest-spread=falseyourself to work around the V8 performance issue mentioned above, esbuild will no longer automatically transform all instances of object spread when targeting a V8-based JavaScript runtime going forward.Note that JavaScript feature transformation is very complex and allowing full customization of the set of supported syntax features could cause bugs in esbuild due to new interactions between multiple features that were never possible before. Consider this to be an experimental feature.
-
-
Implement
extendsconstraints oninfertype variables (#2330)TypeScript 4.7 introduced the ability to write an
extendsconstraint after aninfertype variable, which looks like this:type FirstIfString<T> = T extends [infer S extends string, ...unknown[]] ? S : never;You can read the blog post for more details: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#extends-constraints-on-infer-type-variables. Previously this was a syntax error in esbuild but with this release, esbuild can now parse this syntax correctly.
-
Allow
defineto match optional chain expressions (#2324)Previously esbuild's
definefeature only matched member expressions that did not use optional chaining. With this release, esbuild will now also match those that use optional chaining:// Original code console.log(a.b, a?.b) // Old output (with --define:a.b=c) console.log(c, a?.b); // New output (with --define:a.b=c) console.log(c, c);This is for compatibility with Webpack's
DefinePlugin, which behaves the same way.
v0.14.45
-
Add a log message for ambiguous re-exports (#2322)
In JavaScript, you can re-export symbols from another file using
export * from './another-file'. When you do this from multiple files that export different symbols with the same name, this creates an ambiguous export which is causes that name to not be exported. This is harmless if you don't plan on using the ambiguous export name, so esbuild doesn't have a warning for this. But if you do want a warning for this (or if you want to make it an error), you can now opt-in to seeing this log message with--log-override:ambiguous-reexport=warningor--log-override:ambiguous-reexport=error. The log message looks like this:▲ [WARNING] Re-export of "common" in "example.js" is ambiguous and has been removed [ambiguous-reexport] One definition of "common" comes from "a.js" here: a.js:2:11: 2 │ export let common = 2 ╵ ~~~~~~ Another definition of "common" comes from "b.js" here: b.js:3:14: 3 │ export { b as common } ╵ ~~~~~~ -
Optimize the output of the JSON loader (#2161)
The
jsonloader (which is enabled by default for.jsonfiles) parses the file as JSON and generates a JavaScript file with the parsed expression as thedefaultexport. This behavior is standard and works in both node and the browser (well, as long as you use an import assertion). As an extension, esbuild also allows you to import additional top-level properties of the JSON object directly as a named export. This is beneficial for tree shaking. For example:import { version } from 'esbuild/package.json' console.log(version)If you bundle the above code with esbuild, you'll get something like the following:
// node_modules/esbuild/package.json var version = "0.14.44"; // example.js console.log(version);Most of the
package.jsonfile is irrelevant and has been omitted from the output due to tree shaking. The way esbuild implements this is to have the JavaScript file that's generated from the JSON look something like this with a separate exported variable for each property on the top-level object:// node_modules/esbuild/package.json export var name = "esbuild"; export var version = "0.14.44"; export var repository = "https://github.com/evanw/esbuild"; export var bin = { esbuild: "bin/esbuild" }; ... export default { name, version, repository, bin, ... };However, this means that if you import the
defaultexport instead of a named export, you will get non-optimal output. Thedefaultexport references all top-level properties, leading to many unnecessary variables in the output. With this release esbuild will now optimize this case to only generate additional variables for top-level object properties that are actually imported:// Original code import all, { bar } from 'data:application/json,{"foo":[1,2,3],"bar":[4,5,6]}' console.log(all, bar) // Old output (with --bundle --minify --format=esm) var a=[1,2,3],l=[4,5,6],r={foo:a,bar:l};console.log(r,l); // New output (with --bundle --minify --format=esm) var l=[4,5,6],r={foo:[1,2,3],bar:l};console.log(r,l);Notice how there is no longer an unnecessary generated variable for
foosince it's never imported. And if you only import thedefaultexport, esbuild will now reproduce the original JSON object in the output with all top-level properties compactly inline. -
Add
idto warnings returned from the APIWith this release, warnings returned from esbuild's API now have an
idproperty. This identifies which kind of log message it is, which can be used to more easily filter out certain warnings. For example, reassigning aconstvariable will generate a message with anidof"assign-to-constant". This also gives you the identifier you need to apply a log override for that kind of message: https://esbuild.github.io/api/#log-override.
v0.14.44
-
Add a
copyloader (#2255)You can configure the "loader" for a specific file extension in esbuild, which is a way of telling esbuild how it should treat that file. For example, the
textloader means the file is imported as a string while thebinaryloader means the file is imported as aUint8Array. If you want the imported file to stay a separate file, the only option was previously thefileloader (which is intended to be similar to Webpack'sfile-loaderpackage). This loader copies the file to the output directory and imports the path to that output file as a string. This is useful for a web application because you can refer to resources such as.pngimages by importing them for their URL. However, it's not helpful if you need the imported file to stay a separate file but to still behave the way it normally would when the code is run without bundling.With this release, there is now a new loader called
copythat copies the loaded file to the output directory and then rewrites the path of the import statement orrequire()call to point to the copied file instead of the original file. This will automatically add a content hash to the output name by default (which can be configured with the--asset-names=setting). You can use this by specifyingcopyfor a specific file extension, such as with--loader:.png=copy. -
Fix a regression in arrow function lowering (#2302)
This release fixes a regression with lowering arrow functions to function expressions in ES5. This feature was introduced in version 0.7.2 and regressed in version 0.14.30.
In JavaScript, regular
functionexpressions treatthisas an implicit argument that is determined by how the function is called, but arrow functions treatthisas a variable that is captured in the closure from the surrounding lexical scope. This is emulated in esbuild by storing the value ofthisin a variable before changing the arrow function into a function expression.However, the code that did this didn't treat
thisexpressions as a usage of that generated variable. Version 0.14.30 began omitting unused generated variables, which caused the transformation ofthisto break. This regression happened due to missing test coverage. With this release, the problem has been fixed:// Original code function foo() { return () => this } // Old output (with --target=es5) function foo() { return function() { return _this; }; } // New output (with --target=es5) function foo() { var _this = this; return function() { return _this; }; }This fix was contributed by @nkeynes.
-
Allow entity names as define values (#2292)
The "define" feature allows you to replace certain expressions with certain other expressions at compile time. For example, you might want to replace the global identifier
IS_PRODUCTIONwith the boolean valuetruewhen building for production. Previously the only expressions you could substitute in were either identifier expressions or anything that is valid JSON syntax. This limitation exists because supporting more complex expressions is more complex (for example, substituting in arequire()call could potentially pull in additional files, which would need to be handled). With this release, you can now also now define something as a member expression chain of the formfoo.abc.xyz. -
Implement package self-references (#2312)
This release implements a rarely-used feature in node where a package can import itself by name instead of using relative imports. You can read more about this feature here: https://nodejs.org/api/packages.html#self-referencing-a-package-using-its-name. For example, assuming the
package.jsonin a given package looks like this:// package.json { "name": "a-package", "exports": { ".": "./main.mjs", "./foo": "./foo.js" } }Then any module in that package can reference an export in the package itself:
// ./a-module.mjs import { something } from 'a-package'; // Imports "something" from ./main.mjs.Self-referencing is also available when using
require, both in an ES module, and in a CommonJS one. For example, this code will also work:// ./a-module.js const { something } = require('a-package/foo'); // Loads from ./foo.js. -
Add a warning for assigning to an import (#2319)
Import bindings are immutable in JavaScript, and assigning to them will throw an error. So instead of doing this:
import { foo } from 'foo' foo++You need to do something like this instead:
import { foo, setFoo } from 'foo' setFoo(foo + 1)This is already an error if you try to bundle this code with esbuild. However, this was previously allowed silently when bundling is disabled, which can lead to confusion for people who don't know about this aspect of how JavaScript works. So with this release, there is now a warning when you do this:
▲ [WARNING] This assignment will throw because "foo" is an import [assign-to-import] example.js:2:0: 2 │ foo++ ╵ ~~~ Imports are immutable in JavaScript. To modify the value of this import, you must export a setter function in the imported file (e.g. "setFoo") and then import and call that function here instead.This new warning can be turned off with
--log-override:assign-to-import=silentif you don't want to see it. -
Implement
alwaysStrictintsconfig.json([#2264](https://togithub.com/evanw/e
Configuration
📅 Schedule: Branch creation - "before 4am on sunday" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled due to failing status checks.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.
- [ ] If you want to rebase/retry this PR, click this checkbox.
This PR has been generated by Mend Renovate. View repository job log here.
Code Climate has analyzed commit a4146591 and detected 0 issues on this pull request.
The test coverage on the diff in this pull request is 100.0% (80% is the threshold).
This pull request will bring the total coverage in the repository to 95.8% (0.0% change).
View more on Code Climate.
Socket Security Pull Request Report
Dependency issues detected. If you merge this pull request, you will not be alerted to the instances of these issues again.
📜 Install scripts
Install scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.
| Package | Script field | Source |
|---|---|---|
| [email protected] (upgraded) | postinstall |
package-lock.json, package.json |
😵💫 Bin script confusion
This package has multiple bin scripts with the same name. This can cause non-deterministic behavior when installing or could be a sign of a supply chain attack
Consider removing one of the conflicting packages. Packages should only export bin scripts with their name
| Package | Bin script | Source |
|---|---|---|
| [email protected] (upgraded) | semver |
package-lock.json via [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected] |
| [email protected] (upgraded) | semver |
package-lock.json via @sanity/[email protected], [email protected], [email protected], [email protected] |
| [email protected] (upgraded) | jest |
package-lock.json, package.json |
| [email protected] (upgraded) | jest |
package-lock.json via [email protected] |
Pull request report summary
| Issue | Status |
|---|---|
| Install scripts | ⚠️ 1 issue |
| Native code | ✅ 0 issues |
| Bin script confusion | ⚠️ 4 issues |
| Bin script shell injection | ✅ 0 issues |
| Unresolved require | ✅ 0 issues |
| Invalid package.json | ✅ 0 issues |
| HTTP dependency | ✅ 0 issues |
| Git dependency | ✅ 0 issues |
| Potential typo squat | ✅ 0 issues |
| Known Malware | ✅ 0 issues |
| Telemetry | ✅ 0 issues |
| Protestware/Troll package | ✅ 0 issues |
Bot Commands
To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore [email protected] [email protected]
@SocketSecurity ignore [email protected]@SocketSecurity ignore [email protected]@SocketSecurity ignore [email protected]@SocketSecurity ignore [email protected]@SocketSecurity ignore [email protected]
Powered by socket.dev