Snyk has created this PR to upgrade esbuild from 0.12.29 to 0.14.14.
:information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
The recommended version is 31 versions ahead of your current version.
The recommended version was released 6 days ago, on 2022-01-25.
Fix bug with filename hashes and the file loader (#1957)
This release fixes a bug where if a file name template has the [hash] placeholder (either --entry-names= or --chunk-names=), the hash that esbuild generates didn't include the content of the string generated by the file loader. Importing a file with the file loader causes the imported file to be copied to the output directory and causes the imported value to be the relative path from the output JS file to that copied file. This bug meant that if the --asset-names= setting also contained [hash] and the file loaded with the file loader was changed, the hash in the copied file name would change but the hash of the JS file would not change, which could potentially result in a stale JS file being loaded. Now the hash of the JS file will be changed too which fixes the reload issue.
Prefer the import condition for entry points (#1956)
The exports field in package.json maps package subpaths to file paths. The mapping can be conditional, which lets it vary in different situations. For example, you can have an import condition that applies when the subpath originated from a JS import statement, and a require condition that applies when the subpath originated from a JS require call. These are supposed to be mutually exclusive according to the specification: https://nodejs.org/api/packages.html#conditional-exports.
However, there's a situation with esbuild where it's not immediately obvious which one should be applied: when a package name is specified as an entry point. For example, this can happen if you do esbuild --bundle some-pkg on the command line. In this situation some-pkg does not originate from either a JS import statement or a JS require call. Previously esbuild just didn't apply the import or require conditions. But that could result in path resolution failure if the package doesn't provide a back-up default condition, as is the case with the is-plain-object package.
Starting with this release, esbuild will now use the import condition in this case. This appears to be how Webpack and Rollup handle this situation so this change makes esbuild consistent with other tools in the ecosystem. Parcel (the other major bundler) just doesn't handle this case at all so esbuild's behavior is not at odds with Parcel's behavior here.
Make parsing of invalid @ keyframes rules more robust (#1959)
This improves esbuild's parsing of certain malformed @ keyframes rules to avoid them affecting the following rule. This fix only affects invalid CSS files, and does not change any behavior for files containing valid CSS. Here's an example of the fix:
/* Original code */@ keyframes x { . }
@ keyframes y { 1% { a: b; } }
/* Old output (with --minify) */@ keyframes x{y{1% {a: b;}}}
/* New output (with --minify) */@ keyframes x{.}@ keyframes y{1%{a:b}}
The rules for marking paths as external using --external: grew over time as more special-cases were added. This release reworks the internal representation to be more straightforward and robust. A side effect is that wildcard patterns can now match post-resolve paths in addition to pre-resolve paths. Specifically you can now do --external:./node_modules/* to mark all files in the ./node_modules/ directory as external.
This is the updated logic:
Before path resolution begins, import paths are checked against everything passed via an --external: flag. In addition, if something looks like a package path (i.e. doesn't start with / or ./ or ../), import paths are checked to see if they have that package path as a path prefix (so --external:@ foo/bar matches the import path @ foo/bar/baz).
After path resolution ends, the absolute paths are checked against everything passed via --external: that doesn't look like a package path (i.e. that starts with / or ./ or ../). But before checking, the pattern is transformed to be relative to the current working directory.
People sometimes try to install esbuild on one OS and then copy the node_modules directory over to another OS without reinstalling. This works with JavaScript code but doesn't work with esbuild because esbuild is a native binary executable. This release attempts to offer a helpful error message when this happens. It looks like this:
$ ./node_modules/.bin/esbuild
./node_modules/esbuild/bin/esbuild:106
throw new Error(`
^
Error:
You installed esbuild on another platform than the one you're currently using.
This won't work because esbuild is written with native code and needs to
install a platform-specific binary executable.
Specifically the "esbuild-linux-arm64" package is present but this platform
needs the "esbuild-darwin-arm64" package instead. People often get into this
situation by installing esbuild on Windows or macOS and copying "node_modules"
into a Docker image that runs Linux, or by copying "node_modules" between
Windows and WSL environments.
If you are installing with npm, you can try not copying the "node_modules"
directory when you copy the files over, and running "npm ci" or "npm install"
on the destination platform after the copy. Or you could consider using yarn
instead which has built-in support for installing a package on multiple
platforms simultaneously.
If you are installing with yarn, you can try listing both this platform and the
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
Keep in mind that this means multiple copies of esbuild will be present.
Another alternative is to use the "esbuild-wasm" package instead, which works
the same way on all platforms. But it comes with a heavy performance cost and
can sometimes be 10x slower than the "esbuild" package, so you may also not
want to do that.
at generateBinPath (./node_modules/esbuild/bin/esbuild:106:17)
at Object.<anonymous> (./node_modules/esbuild/bin/esbuild:161:39)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
In CSS, @ import rules must come first before any other kind of rule (except for @ charset rules). Previously esbuild would warn about incorrectly ordered @ import rules and then hoist them to the top of the file. This broke people who wrote invalid @ import rules in the middle of their files and then relied on them being ignored. With this release, esbuild will now ignore invalid @ import rules and pass them through unmodified. This more accurately follows the CSS specification. Note that this behavior differs from other tools like Parcel, which does hoist CSS @ import rules.
This changes how esbuild prints nested @ import statements that are missing a trailing ;, which is invalid CSS. The result is still partially invalid CSS, but now printed in a better-looking way:
There's a proposed CSS syntax for nesting rules using the & selector, but it's not currently implemented in any browser. Previously esbuild silently passed the syntax through untransformed. With this release, esbuild will now warn when you use nesting syntax with a --target= setting that includes a browser.
Warn about } and > inside JSX elements
The } and > characters are invalid inside JSX elements according to the JSX specification because they commonly result from typos like these that are hard to catch in code reviews:
The TypeScript compiler already treats this as an error, so esbuild now treats this as an error in TypeScript files too. That looks like this:
✘ [ERROR] The character ">" is not valid inside a JSX element
example.tsx:2:14:
2 │ return <div>></div>;
│ ^
╵ {'>'}
Did you mean to escape it as "{'>'}" instead?
✘ [ERROR] The character "}" is not valid inside a JSX element
example.tsx:5:17:
5 │ return <div>{1}}</div>;
│ ^
╵ {'}'}
Did you mean to escape it as "{'}'}" instead?
Babel doesn't yet treat this as an error, so esbuild only warns about these characters in JavaScript files for now. Babel 8 treats this as an error but Babel 8 hasn't been released yet. If you see this warning, I recommend fixing the invalid JSX syntax because it will become an error in the future.
Warn about basic CSS property typos
This release now generates a warning if you use a CSS property that is one character off from a known CSS property:
▲ [WARNING] "marign-left" is not a known CSS property
example.css:2:2:
2 │ marign-left: 12px;
│ ~~~~~~~~~~~
╵ margin-left
Did you mean "margin-left" instead?
The new TypeScript enum inlining behavior had a bug where it worked correctly if you used export enum Foo but not if you used enum Foo and then later export { Foo }. This release fixes the bug so enum inlining now works correctly in this case.
Warn about module.exports.foo = ... in ESM (#1907)
The module variable is treated as a global variable reference instead of as a CommonJS module reference in ESM code, which can cause problems for people that try to use both CommonJS and ESM exports in the same file. There has been a warning about this since version 0.14.9. However, the warning only covered cases like exports.foo = bar and module.exports = bar but not module.exports.foo = bar. This last case is now handled;
▲ [WARNING] The CommonJS "module" variable is treated as a global variable in an ECMAScript module and may not work as expected
example.ts:2:0:
2 │ module.exports.b = 1
╵ ~~~~~~
This file is considered to be an ECMAScript module because of the "export" keyword here:
example.ts:1:0:
1 │ export let a = 1
╵ ~~~~~~
This release allows you to use Deno as an esbuild installer, without also needing to use esbuild's JavaScript API. You can now use esbuild's CLI with Deno:
deno run --allow-all "https://deno.land/x/esbuild@v0.14.11/mod.js" --version
This release fixes a missing dependency issue in the publishing script where it was previously possible for the published binary executable to have an incorrect version number.
Snyk has created this PR to upgrade esbuild from 0.12.29 to 0.14.14.
:information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
Release notes
Package name: esbuild
Fix bug with filename hashes and the
file
loader (#1957)This release fixes a bug where if a file name template has the
[hash]
placeholder (either--entry-names=
or--chunk-names=
), the hash that esbuild generates didn't include the content of the string generated by thefile
loader. Importing a file with thefile
loader causes the imported file to be copied to the output directory and causes the imported value to be the relative path from the output JS file to that copied file. This bug meant that if the--asset-names=
setting also contained[hash]
and the file loaded with thefile
loader was changed, the hash in the copied file name would change but the hash of the JS file would not change, which could potentially result in a stale JS file being loaded. Now the hash of the JS file will be changed too which fixes the reload issue.Prefer the
import
condition for entry points (#1956)The
exports
field inpackage.json
maps package subpaths to file paths. The mapping can be conditional, which lets it vary in different situations. For example, you can have animport
condition that applies when the subpath originated from a JS import statement, and arequire
condition that applies when the subpath originated from a JS require call. These are supposed to be mutually exclusive according to the specification: https://nodejs.org/api/packages.html#conditional-exports.However, there's a situation with esbuild where it's not immediately obvious which one should be applied: when a package name is specified as an entry point. For example, this can happen if you do
esbuild --bundle some-pkg
on the command line. In this situationsome-pkg
does not originate from either a JS import statement or a JS require call. Previously esbuild just didn't apply theimport
orrequire
conditions. But that could result in path resolution failure if the package doesn't provide a back-updefault
condition, as is the case with theis-plain-object
package.Starting with this release, esbuild will now use the
import
condition in this case. This appears to be how Webpack and Rollup handle this situation so this change makes esbuild consistent with other tools in the ecosystem. Parcel (the other major bundler) just doesn't handle this case at all so esbuild's behavior is not at odds with Parcel's behavior here.Make parsing of invalid
@ keyframes
rules more robust (#1959)This improves esbuild's parsing of certain malformed
@ keyframes
rules to avoid them affecting the following rule. This fix only affects invalid CSS files, and does not change any behavior for files containing valid CSS. Here's an example of the fix:Be more consistent about external paths (#619)
The rules for marking paths as external using
--external:
grew over time as more special-cases were added. This release reworks the internal representation to be more straightforward and robust. A side effect is that wildcard patterns can now match post-resolve paths in addition to pre-resolve paths. Specifically you can now do--external:./node_modules/*
to mark all files in the./node_modules/
directory as external.This is the updated logic:
Before path resolution begins, import paths are checked against everything passed via an
--external:
flag. In addition, if something looks like a package path (i.e. doesn't start with/
or./
or../
), import paths are checked to see if they have that package path as a path prefix (so--external:@ foo/bar
matches the import path@ foo/bar/baz
).After path resolution ends, the absolute paths are checked against everything passed via
--external:
that doesn't look like a package path (i.e. that starts with/
or./
or../
). But before checking, the pattern is transformed to be relative to the current working directory.Attempt to explain why esbuild can't run (#1819)
People sometimes try to install esbuild on one OS and then copy the
node_modules
directory over to another OS without reinstalling. This works with JavaScript code but doesn't work with esbuild because esbuild is a native binary executable. This release attempts to offer a helpful error message when this happens. It looks like this:Ignore invalid
@ import
rules in CSS (#1946)In CSS,
@ import
rules must come first before any other kind of rule (except for@ charset
rules). Previously esbuild would warn about incorrectly ordered@ import
rules and then hoist them to the top of the file. This broke people who wrote invalid@ import
rules in the middle of their files and then relied on them being ignored. With this release, esbuild will now ignore invalid@ import
rules and pass them through unmodified. This more accurately follows the CSS specification. Note that this behavior differs from other tools like Parcel, which does hoist CSS@ import
rules.Print invalid CSS differently (#1947)
This changes how esbuild prints nested
@ import
statements that are missing a trailing;
, which is invalid CSS. The result is still partially invalid CSS, but now printed in a better-looking way:Warn about CSS nesting syntax (#1945)
There's a proposed CSS syntax for nesting rules using the
&
selector, but it's not currently implemented in any browser. Previously esbuild silently passed the syntax through untransformed. With this release, esbuild will now warn when you use nesting syntax with a--target=
setting that includes a browser.Warn about
}
and>
inside JSX elementsThe
}
and>
characters are invalid inside JSX elements according to the JSX specification because they commonly result from typos like these that are hard to catch in code reviews:The TypeScript compiler already treats this as an error, so esbuild now treats this as an error in TypeScript files too. That looks like this:
Babel doesn't yet treat this as an error, so esbuild only warns about these characters in JavaScript files for now. Babel 8 treats this as an error but Babel 8 hasn't been released yet. If you see this warning, I recommend fixing the invalid JSX syntax because it will become an error in the future.
Warn about basic CSS property typos
This release now generates a warning if you use a CSS property that is one character off from a known CSS property:
Fix a bug with enum inlining (#1903)
The new TypeScript enum inlining behavior had a bug where it worked correctly if you used
export enum Foo
but not if you usedenum Foo
and then laterexport { Foo }
. This release fixes the bug so enum inlining now works correctly in this case.Warn about
module.exports.foo = ...
in ESM (#1907)The
module
variable is treated as a global variable reference instead of as a CommonJS module reference in ESM code, which can cause problems for people that try to use both CommonJS and ESM exports in the same file. There has been a warning about this since version 0.14.9. However, the warning only covered cases likeexports.foo = bar
andmodule.exports = bar
but notmodule.exports.foo = bar
. This last case is now handled;Enable esbuild's CLI with Deno (#1913)
This release allows you to use Deno as an esbuild installer, without also needing to use esbuild's JavaScript API. You can now use esbuild's CLI with Deno:
Fix an issue with the publishing script
This release fixes a missing dependency issue in the publishing script where it was previously possible for the published binary executable to have an incorrect version number.
Commit messages
Package name: esbuild
Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.
For more information:
🧐 View latest project report
🛠 Adjust upgrade PR settings
🔕 Ignore this dependency or unsubscribe from future upgrade PRs