Update dependency esbuild-wasm to v0.8.2 - #24
Open
renovate[bot] wants to merge 1 commit into
Open
Conversation
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 3, 2020 07:18
300aa98 to
a69c414
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 6, 2020 07:43
a69c414 to
7ea44d2
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 7, 2020 07:16
7ea44d2 to
60f06ff
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 9, 2020 04:22
60f06ff to
4b01aa8
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 11, 2020 08:51
4b01aa8 to
8d9f87e
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 12, 2020 03:00
8d9f87e to
a985f9f
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 12, 2020 18:27
a985f9f to
8b878fe
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 19, 2020 11:02
8b878fe to
6bc9d1e
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 23, 2020 01:43
6bc9d1e to
9dcc33b
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 23, 2020 18:27
9dcc33b to
7a40a9f
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 24, 2020 17:09
7a40a9f to
01e59c4
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 26, 2020 04:09
01e59c4 to
a35aa8c
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 27, 2020 02:59
a35aa8c to
de1b7bb
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
September 29, 2020 09:38
de1b7bb to
77f506d
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
October 3, 2020 10:26
77f506d to
093ac6a
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
October 8, 2020 00:58
6224139 to
5366150
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
October 8, 2020 09:34
5366150 to
61b6942
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
October 10, 2020 10:46
61b6942 to
790fde4
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
October 13, 2020 08:59
790fde4 to
fc4e25f
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
October 16, 2020 22:54
fc4e25f to
c491699
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
October 18, 2020 11:33
c491699 to
aba7238
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
October 20, 2020 19:55
aba7238 to
f157936
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
October 21, 2020 08:18
f157936 to
9858927
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
October 25, 2020 06:12
9858927 to
a7f8460
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
October 25, 2020 10:27
a7f8460 to
65cf380
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
October 28, 2020 15:26
65cf380 to
cc2ad56
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
October 28, 2020 17:36
cc2ad56 to
fcbc414
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
November 1, 2020 06:38
fcbc414 to
5a8e365
比较
renovate
Bot
force-pushed
the
renovate/esbuild-wasm-0.x
branch
from
November 2, 2020 00:50
5a8e365 to
d4be9a5
比较
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
注册 for free
to join this conversation on GitHub.
Already have an account?
登录 to comment
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.6.28->0.8.2Release Notes
evanw/esbuild
v0.8.2比较 Source
Fix the omission of
outbasein the JavaScript API (#471)The original PR for the
outbasesetting added it to the CLI and Go APIs but not the JavaScript API. This release adds it to the JavaScript API too.Fix the TypeScript type definitions (#499)
The newly-released
pluginsoption in the TypeScript type definitions was incorrectly marked as non-optional. It is now optional. This fix was contributed by @remorses.v0.8.1比较 Source
The initial version of the plugin API (#111)
The plugin API lets you inject custom code inside esbuild's build process. You can write plugins in either JavaScript or Go. Right now you can add an "on resolve" callback to determine where import paths go and an "on load" callback to determine what the imported file contains. These two primitives are very powerful, especially in combination with each other.
Here's a simple example plugin to show off the API in action. Let's say you wanted to enable a workflow where you can import environment variables like this:
This is how you might do that from JavaScript:
This is how you might do that from Go:
0.6.28->0.8.2},
func(args api.OnResolveArgs) (api.OnResolveResult, error) {
return api.OnResolveResult{
Path: args.Path,
Namespace: "env",
}, nil
})
Add the
outbaseoption (#471)Currently, esbuild uses the lowest common ancestor of the entrypoints to determine where to place each entrypoint's output file. This is an excellent default, but is not ideal in some situations. Take for example an app with a folder structure similar to Next.js, with js files at
pages/a/b/c.jsandpages/a/b/d.js. These two files correspond to the paths/a/b/cand/a/b/d. Ideally, esbuild would emitout/a/b/c.jsandout/a/b/d.js. However, esbuild identifiespages/a/bas the lowest common ancestor and emitsout/c.jsandout/d.js. This release introduces an--outbaseargument to the cli that allows the user to choose which path to base entrypoint output paths on. With this change, running esbuild with--outbase=pagesresults in the desired behavior. This change was contributed by @nitsky.v0.8.0比较 Source
This release contains backwards-incompatible changes. Since esbuild is before version 1.0.0, these changes have been released as a new minor version to reflect this (as recommended by npm). You should either be pinning the exact version of
esbuildin yourpackage.jsonfile or be using a version range syntax that only accepts patch upgrades such as^0.7.0. See the documentation about semver for more information.The breaking changes are as follows:
Changed the transform API result object
For the transform API, the return values
jsandjsSourceMaphave been renamed tocodeandmaprespectively. This is because esbuild now supports CSS as a first-class content type, and returning CSS code in a variable calledjsmade no sense.The class field transform is now more accurate
Class fields look like this:
Previously the transform for class fields used a normal assignment for initialization:
However, this doesn't exactly follow the initialization behavior in the JavaScript specification. For example, it can cause a setter to be called if one exists with that property name, which isn't supposed to happen. A more accurate transform that used
Object.defineProperty()instead was available under the--strict:class-fieldsoption.This release removes the
--strict:class-fieldsoption and makes that the default behavior. There is no longer a way to compile class fields to normal assignments instead, since that doesn't follow JavaScript semantics. Note that for legacy reasons, TypeScript code will still compile class fields to normal assignments unlessuseDefineForClassFieldsis enabled intsconfig.jsonjust like the official TypeScript compiler.When bundling stdin using the API,
resolveDiris now required to resolve importsThe
resolveDiroption specifies the directory to resolve relative imports against. Previously it defaulted to the current working directory. Now it no longer does, so you must explicitly specify it if you need it:This was changed because the original behavior was unintentional, and because being explicit seems better in this case. Note that this only affects the JavaScript and Go APIs. The resolution directory for stdin passed using the command-line API still defaults to the current working directory.
In addition, it is now possible for esbuild to discover input source maps linked via
//# sourceMappingURL=comments relative to theresolveDirfor stdin. This previously only worked for files with a real path on the file system.Made names in the Go API consistent
Previously some of the names in the Go API were unnecessarily different than the corresponding names in the CLI and JavaScript APIs. This made it harder to write documentation and examples for these APIs that work consistently across all three API surfaces. These different names in the Go API have been fixed:
Defines→DefineExternals→ExternalLoaders→LoaderPureFunctions→PureThe global name parameter now takes a JavaScript expression (#293)
The global name parameter determines the name of the global variable created for exports with the IIFE output format. For example, a global name of
abcwould generate the following IIFE:Previously this name was injected into the source code verbatim without any validation. This meant a global name of
abc.defwould generate this code, which is a syntax error:With this release, a global name of
abc.defwill now generate the following code instead:The full syntax is an identifier followed by one or more property accesses. If you need to include a
.character in your property name, you can use an index expression instead. For example, the global nameversions['1.0']will generate the following code:Removed the workaround for
document.allwith nullish coalescing and optional chainingThe
--strict:nullish-coalescingand--strict:optional-chainingoptions have been removed. They only existed to address a theoretical problem where modern code that uses the new??and?.operators interacted with the legacydocument.allobject that has been deprecated for a long time. Realistically this case is extremely unlikely to come up in practice, so these obscure options were removed to simplify the API and reduce code complexity. For what it's worth this behavior also matches Terser, a commonly-used JavaScript minifier.v0.7.22比较 Source
Add
tsconfigRawto the transform API (#483)The
buildAPI uses access to the file system and doesn't run in the browser, but thetransformAPI doesn't access the file system and can run in the browser. Previously you could only use the build API for certain scenarios involving TypeScript code andtsconfig.jsonfiles, such as configuring theimportsNotUsedAsValuessetting.You can now use
tsconfig.jsonwith the transform API by passing in the raw contents of that file:Right now four values are supported with the transform API:
jsxFactory,jsxFragmentFactory,useDefineForClassFields, andimportsNotUsedAsValues. The valuesextends,baseUrl, andpathsare not supported because they require access to the file system and the transform API deliberately does not access the file system.You can also pass the
tsconfig.jsonfile as a string instead of a JSON object if you prefer. This can be useful becausetsconfig.jsonfiles actually use a weird pseudo-JSON syntax that allows comments and trailing commas, which means it can't be parsed withJSON.parse().Warn about
process.env.NODE_ENVSome popular browser-oriented libraries such as React use
process.env.NODE_ENVeven though this is not an API provided by the browser. While esbuild makes it easy to replace this at compile time using the--definefeature, you must still do this manually and it's easy to forget. Now esbuild will warn you if you're bundling code containingprocess.env.NODE_ENVfor the browser and you haven't configured it to be replaced by something.Work around a bug in Safari for the run-time code (#489)
The
Object.getOwnPropertyDescriptorfunction in Safari is broken for numeric properties. It incorrectly returnsundefined, which crashes the run-time code esbuild uses to bind modules together. This release contains code to avoid a crash in this case.v0.7.21比较 Source
Use bracketed escape codes for non-BMP characters
The previous release introduced code that escapes non-ASCII characters using ASCII escape sequences. Since JavaScript uses UCS-2/UTF-16 internally, a non-BMP character such as
𐀀ended up being encoded using a surrogate pair:\uD800\uDC00. This is fine when the character is contained in a string, but it causes a syntax error when that character is used as an identifier.This release fixes this issue by using the newer bracketed escape code instead:
\u{10000}. One complication with doing this is that this escape code won't work in older environments without ES6 support. Because of this, using identifiers containing non-BMP characters is now an error if the configured target environment doesn't support bracketed escape codes.Escape non-ASCII characters in properties
The previous release overlooked the need to escape non-ASCII characters in properties in various places in the grammar (e.g. object literals, property accesses, import and export aliases). This resulted in output containing non-ASCII characters even with
--charset=ascii. These characters should now always be escaped, even in properties.v0.7.20比较 Source
Default to ASCII-only output (#70, #485)
While esbuild's output is encoded using UTF-8 encoding, there are many other character encodings in the wild (e.g. Windows-1250). You can explicitly mark the output files as UTF-8 by adding
<meta charset="utf-8">to your HTML page or by includingcharset=utf-8in theContent-Typeheader sent by your server. This is probably a good idea regardless of the contents of esbuild's output since information being displayed to users is probably also encoded using UTF-8.However, sometimes it's not possible to guarantee that your users will be running your code as UTF-8. For example, you may not control the server response or the contents of the HTML page that loads your script. Also, if your code needs to run in IE, there are certain cases where IE may ignore the
<meta charset="utf-8">tag and make up another encoding instead.Also content encoded using UTF-8 may be parsed up to 1.7x slower by the browser than ASCII-only content, at least according to this blog post from the V8 team: https://v8.dev/blog/scanner. The official recommendation is to "avoid non-ASCII identifiers where possible" to improve parsing performance.
For these reasons, esbuild's default output has been changed to ASCII-only. All Unicode code points in identifiers and strings that are outside of the printable ASCII range (
\x20-\x7Einclusive) are escaped using backslash escape sequences. If you would like to use raw UTF-8 encoding instead, you can pass the--charset=utf8flag to esbuild.Further details:
This does not yet escape non-ASCII characters embedded in regular expressions. This is because esbuild does not currently parse the contents of regular expressions at all. The flag was added despite this limitation because it's still useful for code that doesn't contain cases like this.
This flag does not apply to comments. I believe preserving non-ASCII data in comments should be fine because even if the encoding is wrong, the run time environment should completely ignore the contents of all comments. For example, the V8 blog post mentions an optimization that avoids decoding comment contents completely. And all comments other than license-related comments are stripped out by esbuild anyway.
This new
--charsetflag simultaneously applies to all output file types (JavaScript, CSS, and JSON). So if you configure your server to send the correctContent-Typeheader and want to use--charset=utf8, make sure your server is configured to treat both.jsand.cssfiles as UTF-8.Interpret escape sequences in CSS tokens
Escape sequences in CSS tokens are now interpreted. This was already the case for string and URL tokens before, but this is now the case for all identifier-like tokens as well. For example,
c\6flor: #\66 00is now correctly recognized ascolor: #f00.Support
.csswith the--out-extensionoptionThe
--out-extensionoption was added so you could generate.mjsand.cjsfiles for node like this:--out-extension:.js=.mjs. However, now that CSS is a first-class content type in esbuild, this should also be available for.cssfiles. I'm not sure why you would want to do this, but you can now do--out-extension:.css=.somethingtoo.v0.7.19比较 Source
Add the
--avoid-tdzoption for large bundles in Safari (#478)This is a workaround for a performance issue with certain large JavaScript files in Safari.
First, some background. In JavaScript the
varstatement is "hoisted" meaning the variable is declared immediately in the closest surrounding function, module, or global scope. Accessing one of these variables before its declaration has been evaluated results in the valueundefined. In ES6 theconst,let, andclassstatements introduce what's called a "temporal dead zone" or TDZ. This means that, unlikevarstatements, accessing one of these variable before its declaration has been evaluated results in aReferenceErrorbeing thrown. It's called a "temporal dead zone" because it's a zone of time in which the variable is inaccessible.According to this WebKit bug, there's a severe performance issue with the tracking of TDZ checks in JavaScriptCore, the JavaScript JIT compiler used by WebKit. In a large private code base I have access to, the initialization phase of the bundle produced by esbuild runs 10x faster in Safari if top-level
const,let, andclassare replaced withvar. It's a difference between a loading time of about 2sec vs. about 200ms. This transformation is not enabled by default because it changes the semantics of the code (it removes the TDZ andconstassignment checks). However, this change in semantics may be acceptable for you given the performance trade-off. You can enable it with the--avoid-tdzflag.Warn about assignment to
constsymbolsNow that some
constsymbols may be converted tovardue to--avoid-tdz, it seems like a good idea to at least warn when an assignment to aconstsymbol is detected during bundling. Otherwise accidental assignments toconstsymbols could go unnoticed if there isn't other tooling in place such as TypeScript or a linter.v0.7.18比较 Source
Treat paths in CSS without a
./or../prefix as relative (#469)JavaScript paths starting with
./or../are considered relative paths, while other JavaScript paths are considered package paths and are looked up in that package'snode_modulesdirectory. Currentlyurl()paths in CSS files use that same logic, sourl(images/image.png)checks for a file namedimage.pngin theimagepackage.This release changes this behavior. Now
url(images/image.png)first checks for./images/image.png, then checks for a file namedimage.pngin theimagepackage. This behavior should match the behavior of Webpack's standardcss-loaderpackage.Import non-enumerable properties from CommonJS modules (#472)
You can now import non-enumerable properties from CommonJS modules using an ES6
importstatement. Here's an example of a situation where that might matter:Previously that didn't work because the
methodproperty is non-enumerable. This should now work correctly.A minor consequence of this change is that re-exporting from a file using
export * fromwill no longer re-export properties inherited from the prototype of the object assigned tomodule.exports. This is because run-time property copying has been changed from a for-in loop toObject.getOwnPropertyNames. This change should be inconsequential because as far as I can tell this isn't something any other bundler supports either.Remove arrow functions in runtime with
--target=es5The
--target=es5flag is intended to prevent esbuild from introducing any ES6+ syntax into the generated output file. For example, esbuild usually shortens{x: x}into{x}since it's shorter, except that requires ES6 support. This release fixes a bug where=>arrow expressions in esbuild's runtime of helper functions were not converted tofunctionexpressions when--target=es5was present.Merge local variable declarations across files when minifying
Currently files are minified in parallel and then concatenated together for maximum performance. However, that means certain constructs are not optimally minified if they span multiple files. For example, a bundle containing two files
var a = 1andvar b = 2should ideally becomevar a=1,b=2;after minification but it currently becomesvar a=0;var b=2;instead due to parallelism.With this release, esbuild will generate
var a=1,b=2;in this scenario. This is achieved by splicing the two files together to remove the trailing;and the leadingvar, which is more complicated than it sounds when you consider rewriting the source maps.v0.7.17比较 Source
Add
--public-path=for thefileloader (#459)The
fileloader causes importing a file to cause that file to be copied into the output directory. The name of the file is exported as the default export:The new public path setting configures the path prefix. So for example setting it to
https://www.example.com/v1would change the output text for this example tohttps://www.example.com/v1/image.L3XDQOAT.png.Add
--inject:for polyfills (#451)It's now possible to replace global variables with imports from a file with
--inject:file.js. Note thatfile.jsmust export symbols using theexportkeyword for this to work. This can be used to polyfill a global variable in code you don't control. For example:Building this with
esbuild entry.js --inject:process.jsgives this:You can also combine this with the existing
--definefeature to be more selective about what you import. For example:Building this with
esbuild entry.js --inject:process.js --define:process.cwd=dummy_process_cwdgives this:Note that this means you can use
--injectto provide the implementation for JSX expressions (e.g. auto-import thereactpackage):Building this with
esbuild entry.js --inject:shim.js --format=esmgives this:You can also use
--inject:file.jswith files that have no exports. In that case the injected file just comes first before the rest of the output as if every input file containedimport "./file.js". Because of the way ECMAScript modules work, this injection is still "hygienic" in that symbols with the same name in different files are renamed so they don't collide with each other.If you want to conditionally import a file only if the export is actually used, you should mark the injected file as not having side effects by putting it in a package and adding
"sideEffects": falsein that package'spackage.jsonfile. This setting is a convention from Webpack that esbuild respects for any imported file, not just files used with--inject.Add an ECMAScript module build for the browser (#342)
The current browser API lets you use esbuild in the browser via the
esbuild-wasmpackage and a script tag:In addition to this approach, you can now also use esbuild in the browser from a module-type script (note the use of
esm/browser.jsinstead oflib/browser.js):Part of this fix was contributed by @calebeby.
v0.7.16比较 Source
Fix backward slashes in source maps on Windows (#463)
The relative path fix in the previous release caused a regression where paths in source maps contained
\instead of/on Windows. That is incorrect because source map paths are URLs, not file system paths. This release replaces\with/for consistency on Windows.module.require()is now an alias forrequire()(#455)Some packages such as apollo-server use
module.require()instead ofrequire()with the intent of bypassing the bundler'srequireand calling the underlying function fromnodeinstead. Unfortunately that doesn't actually work because CommonJS module semantics meansmoduleis a variable local to that file's CommonJS closure instead of the host'smoduleobject.This wasn't an issue when using
apollo-serverwith Webpack because the literal expressionmodule.require()is automatically rewritten torequire()by Webpack: webpack/webpack#7750. To get this package to work, esbuild now matches Webpack's behavior here. Calls tomodule.require()will become external calls torequire()as long as the required path has been marked as external.v0.7.15比较 Source
Lower
export * assyntax for ES2019 and belowThe
export * from 'path'syntax was added in ES2015 but theexport * as name from 'path'syntax was added more recently in ES2020. This is a shorthand for an import followed by an export:With this release, esbuild will now undo this shorthand syntax when using
--target=es2019or below.Better code generation for TypeScript files with type-only exports (#447)
Previously TypeScript files could have an unnecessary CommonJS wrapper in certain situations. The specific situation is bundling a file that re-exports something from another file without any exports. This happens because esbuild automatically considers a module to be a CommonJS module if there is no ES6
import/exportsyntax.This behavior is undesirable because the CommonJS wrapper is usually unnecessary. It's especially undesirable for cases where the re-export uses
export * frombecause then the re-exporting module is also converted to a CommonJS wrapper (since re-exporting everything from a CommonJS module must be done at run-time). That can also impact the bundle's exports itself if the entry point does this and the format isesm.It is generally equivalent to avoid the CommonJS wrapper and just rewrite the imports to an
undefinedliteral instead:This can be rewritten to this instead (with a warning generated about
namebeing missing):With this release, this is now how cases like these are handled. The only case where this can't be done is when the import uses the
import * assyntax. In that case a CommonJS wrapper is still necessary because the namespace cannot be rewritten toundefined.Add support for
importsNotUsedAsValuesin TypeScript (#448)The
importsNotUsedAsValuesfield intsconfig.jsonis now respected. Setting it to"preserve"means esbuild will no longer remove unused imports in TypeScript files. This field was added in TypeScript 3.8.Fix relative paths in generated source maps (#444)
Currently paths in generated source map files don't necessarily correspond to real file system paths. They are really only meant to be human-readable when debugging in the browser.
However, the Visual Studio Code debugger expects these paths to point back to the original files on the file system. With this release, it should now always be possible to get back to the original source file by joining the directory containing the source map file with the relative path in the source map.
This fix was contributed by @yoyo930021.
v0.7.14比较 Source
Fix a bug with compound import statements (#446)
Import statements can simultaneously contain both a default import and a namespace import like this:
These statements were previously miscompiled when bundling if the import path was marked as external, or when converting to a specific output format, and the namespace variable itself was used for something other than a property access. The generated code contained a syntax error because it generated a
{...}import clause containing the default import.This particular problem was caused by code that converts namespace imports into import clauses for more efficient bundling. This transformation should not be done if the namespace import cannot be completely removed:
v0.7.13比较 Source
Fix
mainFieldsin the JavaScript API (#440 and #441)It turns out the JavaScript bindings for the
mainFieldsAPI option didn't work due to a copy/paste error. The fix for this was contributed by @yoyo930021.The benchmarks have been updated
The benchmarks now include Parcel 2 and Webpack 5 (in addition to Parcel 1 and Webpack 4, which were already included). It looks like Parcel 2 is slightly faster than Parcel 1 and Webpack 5 is significantly slower than Webpack 4.
v0.7.12比较 Source
Fix another subtle ordering issue with
importstatementsWhen importing a file while bundling, the import statement was ordered before the imported code. This could affect import execution order in complex scenarios involving nested hybrid ES6/CommonJS modules. The fix was to move the import statement to after the imported code instead. This issue affected the
@sentry/browserpackage.v0.7.11比较 Source
Fix regression in 0.7.9 when minifying with code splitting (#437)
In certain specific cases, bundling and minifying with code splitting active can cause a crash. This is a regression that was introduced in version 0.7.9 due to the fix for issue #421. The crash has been fixed and this case now has test coverage.
v0.7.10比较 Source
Recover from bad
mainfield inpackage.json(#423)Some packages are published with invalid information in the
mainfield ofpackage.json. In that case, path resolution should fall back to searching for a file namedindex.jsbefore giving up. This matters for thesimple-exiftoolpackage, for example.Ignore TypeScript types on
catchclause bindings (435)This fixes an issue where using a type annotation in a
catchclause like this was a syntax error:v0.7.9比较 Source
Fixed panic when using a
url()import in CSS with the--metafileoptionThis release fixes a crash that happens when
metafileoutput is enabled and theurl()syntax is used in a CSS file to import a successfully-resolved file.Minify some CSS colors
The minifier can now reduce the size of some CSS colors. This is the initial work to start CSS minification in general beyond whitespace removal. There is currently support for minifying hex,
rgb()/rgba(), andhsl()/hsla()into hex or shorthand hex. The minification process respects the configured target browser and doesn't use any syntax that wouldn't be supported.Lower newer CSS syntax for older browsers
新建er color syntax such as
rgba(255 0 0 / 50%)will be converted to older syntax (in this casergba(255, 0, 0, 0.5)) when the target browser doesn't support the newer syntax. For example, this happens when using--target=chrome60.Fix an ordering issue with
importstatements (#421)Previously
importstatements that resolved to a CommonJS module turned into a call torequire()inline. This was subtly incorrect when combined with tree shaking because it could sometimes cause imported modules to be reordered:That code was previously compiled into something like this, which is incorrect because the evaluation of
barmay depend on side effects from importingcjs-file.js:That code is now compiled into something like this:
This now means that a single input file can end up in multiple discontiguous regions in the output file as is the case with
example.jshere, which wasn't the case before this bug fix.v0.7.8比较 Source
Move external
@importrules to the topBundling could cause
@importrules for paths that have been marked as external to be inserted in the middle of the CSS file. This would cause them to become invalid and be ignored by the browser since all@importrules must come first at the top of the file. These@importrules are now always moved to the top of the file so they stay valid.Better support for
@keyframesrulesThe parser now directly understands
@keyframesrules, which means it can now format them more accurately and report more specific syntax errors.Minify whitespace around commas in CSS
Whitespace around commas in CSS will now be pretty-printed when not minifying and removed when minifying. So
a , bbecomesa, bwhen pretty-printed anda,bwhen minified.Warn about unknown at-rules in CSS
Using an
@rulein a CSS file that isn't known by esbuild now generates a warning and these rules will be passed through unmodified. If they aren't known to esbuild, they are probably part of a CSS preprocessor syntax that should have been compiled away before giving the file to esbuild to parse.Recoverable CSS syntax errors are now warnings
The base CSS syntax can preserve nonsensical rules as long as they contain valid tokens and have matching opening and closing brackets. These rule with incorrect syntax now generate a warning instead of an error and esbuild preserves the syntax in the output file. This makes it possible to use esbuild to process CSS that was generated by another tool that contains bugs.
For example, the following code is invalid CSS, and was presumably generated by a bug in an automatic prefix generator:
This code will no longer prevent esbuild from processing the CSS file.
Treat
url(...)in CSS files as an import (#415)When bundling, the
url(...)syntax in CSS now tries to resolve the URL as a path using the bundler's built in path resolution logic. The following loaders can be used with this syntax:text,base64,file,dataurl, andbinary.Automatically treat certain paths as external
The following path forms are now automatically considered external:
http://example.com/image.pnghttps://example.com/image.png//example.com/image.pngdata:image/png;base64,iVBORw0KGgo=In addition, paths starting with
#are considered external in CSS files, which allows the following syntax to continue to work:v0.7.7比较 Source
Fix TypeScript decorators on static members
This release fixes a bug with the TypeScript transform for the
experimentalDecoratorssetting. Previously the target object for all decorators was the class prototype, which was incorrect for static members. Static members now correctly use the class object itself as a target object.Experimental support for CSS syntax (#20)
This release introduces the new
cssloader, enabled by default for.cssfiles. It has the following features:You can now use esbuild to process CSS files by passing a CSS file as an entry point. This means CSS is a new first-class file type and you can use it without involving any JavaScript code at all.
When bundling is enabled, esbuild will bundle multiple CSS files together if they are referenced using the
@import "./file.css";syntax. CSS files can be excluded from the bundle by marking them as external similar to JavaScript files.There is basic support for pretty-printing CSS, and for whitespace removal when the
--minifyflag is present. There isn't any support for CSS syntax compression yet. Note that pretty-printing and whitespace removal both rely on the CSS syntax being recognized. Currently esbuild only recognizes certain CSS syntax and passes through unrecognized syntax unchanged.Some things to keep in mind:
CSS support is a significant undertaking and this is the very first release. There are almost certainly going to be issues. This is an experimental release to land the code and get feedback.
There is no support for CSS modules yet. Right now all class names are in the global namespace. Importing a CSS file into a JavaScript file will not result in any import names.
There is currently no support for code splitting of CSS. I haven't tested multiple entry-point scenarios yet and code splitting will require additional changes to the AST format.
v0.7.6比较 Source
Fix JSON files with multiple entry points (#413)
This release fixes an issue where a single build operation containing multiple entry points and a shared JSON file which is used by more than one of those entry points can generate incorrect code for the JSON file when code splitting is disabled. The problem was not cloning the AST representing the JSON file before mutating it.
Silence warnings about
require.resolve()for external paths (#410)Bundling code containing a call to node's
require.resolve()function causes a warning because it's an unsupported use ofrequirethat does not end up being bundled. For example, the following code will likely have unexpected behavior iffooends up being bundled because therequire()call is evaluated at bundle time but therequire.resolve()call is evaluated at run time:These warnings can already be disabled by surrounding the code with a
try/catchstatement. With this release, these warnings can now also be disabled by marking the path as external.Ensure external relative paths start with
./or../Individual file paths can be marked as external in addition to package paths. In that case, the path to the file is rewritten to be relative to the output directory. However, previously the relative path for files in the output directory itself did not start with
./, meaning they could potentially be interpreted as a package path instead of a relative path. These paths are now prefixed with./to avoid this edge case.v0.7.5比较 Source
Fix an issue with automatic semicolon insertion after
let(#409)The character sequence
letcan be considered either a keyword or an identifier depending on the context. A fix was previously landed in version 0.6.31 to considerletas an identifier in code like this:Handling this edge case is useless but the behavior is required by the specification. However, that fix also unintentionally caused
letto be considered an identifier in code like this:In this case,
letshould be considered a keyword instead. This has been fixed.Fix some additional conformance tests
Some additional syntax edge cases are now forbidden including
let let,import {eval} from 'path', andif (1) x: function f() {}.v0.7.4比较 Source
Undo an earlier change to try to improve yarn compatibility (#91 and #407)
The yarn package manager behaves differently from npm and is not compatible in many ways. While npm is the only officially supported package manager for esbuild, people have contributed fixes for other package managers including yarn. One such fix is PR #91 which makes sure the install script only runs once for a given installation directory.
I suspect this fix is actually incorrect, and is the cause of issue #407. The problem seems to be that if you change the version of a package using
yarn add esbuild@version, yarn doesn't clear out the installation directory before reinstalling the package so the package ends up with a mix of files from both package versions. This is not how npm behaves and seems like a pretty severe bug in yarn. I am reverting PR #91 in an attempt to fix this issue.Disable some warnings for code inside
node_modulesdirectories (#395 and #402)Using esbuild to build code with certain suspicious-looking syntax may generate a warning. These warnings don't fail the build (the build still succeeds) but they point out code that is very likely to not behave as intended. This has caught real bugs in the past:
rollup/rollup#3729: Invalid dead code removal for return statement due to ASI
aws/aws-sdk-js#3325: Array equality bug in the Node.js XML parser
olifolkerd/tabulator#2962: Nonsensical comparisons with typeof and "null"
mrdoob/three.js#11183: Comparison with -0 in Math.js
mrdoob/three.js#11182: Cperator precedence bug in WWOBJLoader2.js
v0.7.3比较 Source
Fix compile error due to missing
unix.SYS_IOCTLin the latestgolang.org/x/sys(#396)The
unix.SYS_IOCTLexport was apparently removed fromgolang.org/x/sysrecently, which affected code in esbuild that gets the width of the terminal. This code now uses another method of getting the terminal width. The fix was contributed by @akayj.Validate that the versions of the host code and the binary executable match (#407)
After the install script runs, the version of the downloaded binary should always match the version of the package being installed. I have added some additional checks to verify this in case this invariant is ever broken. Breaking this invariant is very bad because it means the code being run is a mix of code from different package versions.
v0.7.2比较 Source
Add
tsconfigRawto the transform API (#483)The
buildAPI uses access to the file system and doesn't run in the browser, but thetransformAPI doesn't access the file system and can run in the browser. Previously you could only use the build API for certain scenarios involving TypeScript code andtsconfig.jsonfiles, such as configuring theimportsNotUsedAsValuessetting.You can now use
tsconfig.jsonwith the transform API by passing in the raw contents of that file:Right now four values are supported with the transform API:
jsxFactory,jsxFragmentFactory,useDefineForClassFields, andimportsNotUsedAsValues. The valuesextends,baseUrl, andpathsare not supported because they require access to the file system and the transform API deliberately does not access the file system.You can also pass the
tsconfig.jsonfile as a string instead of a JSON object if you prefer. This can be useful becausetsconfig.jsonfiles actually use a weird pseudo-JSON syntax that allows comments and trailing commas, which means it can't be parsed withJSON.parse().Warn about
process.env.NODE_ENVSome popular browser-oriented libraries such as React use
process.env.NODE_ENVeven though this is not an API provided by the browser. While esbuild makes it easy to replace this at compile time using the--definefeature, you must still do this manually and it's easy to forget. Now esbuild will warn you if you're bundling code containingprocess.env.NODE_ENVfor the browser and you haven't configured it to be replaced by something.Work around a bug in Safari for the run-time code (#489)
The
Object.getOwnPropertyDescriptorfunction in Safari is broken for numeric properties. It incorrectly returnsundefined, which crashes the run-time code esbuild uses to bind modules together. This release contains code to avoid a crash in this case.v0.7.1比较 Source
Add the
--avoid-tdzoption for large bundles in Safari (#478)This is a workaround for a performance issue with certain large JavaScript files in Safari.
First, some background. In JavaScript the
varstatement is "hoisted" meaning the variable is declared immediately in the closest surrounding function, module, or global scope. Accessing one of these variables before its declaration has been evaluated results in the valueundefined. In ES6 theconst,let, andclassstatements introduce what's called a "temporal dead zone" or TDZ. This means that, unlikevarstatements, accessing one of these variable before its declaration has been evaluated results in aReferenceErrorbeing thrown. It's called a "temporal dead zone" because it's a zone of time in which the variable is inaccessible.According to this WebKit bug, there's a severe performance issue with the tracking of TDZ checks in JavaScriptCore, the JavaScript JIT compiler used by WebKit. In a large private code base I have access to, the initialization phase of the bundle produced by esbuild runs 10x faster in Safari if top-level
const,let, andclassare replaced withvar. It's a difference between a loading time of about 2sec vs. about 200ms. This transformation is not enabled by default because it changes the semantics of the code (it removes the TDZ andconstassignment checks). However, this change in semantics may be acceptable for you given the performance trade-off. You can enable it with the--avoid-tdzflag.Warn about assignment to
constsymbolsNow that some
constsymbols may be converted tovardue to--avoid-tdz, it seems like a good idea to at least warn when an assignment to aconstsymbol is detected during bundling. Otherwise accidental assignments toconstsymbols could go unnoticed if there isn't other tooling in place such as TypeScript or a linter.v0.7.0比较 Source
Mark output files with a hashbang as executable (#364)
Output files that start with a hashbang line such as
#!/usr/bin/env nodewill now automatically be marked as executable. This lets you run them directly in a Unix-like shell without using thenodecommand.Use
"main"forrequire()and"module"forimport(#363)The node module resolution algorithm uses the
"main"field inpackage.jsonto determine which file to load when a package is loaded withrequire(). Independent of node, most bundlers have converged on a convention where the"module"field takes precedence over the"main"field when present. Package authors can then use the"module"field to publish the same code in a different format for bundlers than for node.This is commonly used to publish "dual packages" that appear to use ECMAScript modules to bundlers but that appear to use CommonJS modules to node. This is useful because ECMAScript modules improve bundler output by taking advantage of "tree shaking" (basically dead-code elimination) and because ECMAScript modules cause lots of problems in node (for example, node doesn't support importing ECMAScript modules using
require()).The problem is that if code using
require()resolves to the"module"field in esbuild, the resulting value is currently always an object. ECMAScript modules export a namespace containing all exported properties. There is no direct equivalent ofmodule.exports = valuein CommonJS. The closest isexport default valuebut the CommonJS equivalent of that isexports.default = value. This is problematic for code containingmodule.exports = function() {}which is a frequently-used CommonJS library pattern. An example of such an issue is Webpack issue #6584.An often-proposed way to fix this is to map
require()to"main"and mapimportto"module". The problem with this is that it means the same package would be loaded into memory more than once if it is loaded both withrequire()and withimport(perhaps from separate packages). An example of such an issue is GraphQL issueRenovate configuration
📅 Schedule: 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 WhiteSource Renovate. View repository job log here.