Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snyk] Upgrade esbuild from 0.12.22 to 0.14.10 #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

snyk-bot
Copy link

Snyk has created this PR to upgrade esbuild from 0.12.22 to 0.14.10.

merge advice
ℹ️ 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 34 versions ahead of your current version.
  • The recommended version was released a month ago, on 2021-12-31.
Release notes
Package name: esbuild
  • 0.14.10 - 2021-12-31
    • Enable tree shaking of classes with lowered static fields (#175)

      If the configured target environment doesn't support static class fields, they are converted into a call to esbuild's __publicField function instead. However, esbuild's tree-shaking pass treated this call as a side effect, which meant that all classes with static fields were ineligible for tree shaking. This release fixes the problem by explicitly ignoring calls to the __publicField function during tree shaking side-effect determination. Tree shaking is now enabled for these classes:

      // Original code
      class Foo { static foo = 'foo' }
      class Bar { static bar = 'bar' }
      new Bar()

      // Old output (with --tree-shaking=true --target=es6)
      class Foo {
      }
      __publicField(Foo, "foo", "foo");
      class Bar {
      }
      __publicField(Bar, "bar", "bar");
      new Bar();

      // New output (with --tree-shaking=true --target=es6)
      class Bar {
      }
      __publicField(Bar, "bar", "bar");
      new Bar();

    • Treat --define:foo=undefined as an undefined literal instead of an identifier (#1407)

      References to the global variable undefined are automatically replaced with the literal value for undefined, which appears as void 0 when printed. This allows for additional optimizations such as collapsing undefined ?? bar into just bar. However, this substitution was not done for values specified via --define:. As a result, esbuild could potentially miss out on certain optimizations in these cases. With this release, it's now possible to use --define: to substitute something with an undefined literal:

      // Original code
      let win = typeof window !== 'undefined' ? window : {}

      // Old output (with --define:window=undefined --minify)
      let win=typeof undefined!="undefined"?undefined:{};

      // New output (with --define:window=undefined --minify)
      let win={};

    • Add the --drop:debugger flag (#1809)

      Passing this flag causes all debugger; statements to be removed from the output. This is similar to the drop_debugger: true flag available in the popular UglifyJS and Terser JavaScript minifiers.

    • Add the --drop:console flag (#28)

      Passing this flag causes all console.xyz() API calls to be removed from the output. This is similar to the drop_console: true flag available in the popular UglifyJS and Terser JavaScript minifiers.

      WARNING: Using this flag can introduce bugs into your code! This flag removes the entire call expression including all call arguments. If any of those arguments had important side effects, using this flag will change the behavior of your code. Be very careful when using this flag. If you want to remove console API calls without removing arguments with side effects (which does not introduce bugs), you should mark the relevant API calls as pure instead like this: --pure:console.log --minify.

    • Inline calls to certain no-op functions when minifying (#290, #907)

      This release makes esbuild inline two types of no-op functions: empty functions and identity functions. These most commonly arise when most of the function body is eliminated as dead code. In the examples below, this happens because we use --define:window.DEBUG=false to cause dead code elimination inside the function body of the resulting if (false) statement. This inlining is a small code size and performance win but, more importantly, it allows for people to use these features to add useful abstractions that improve the development experience without needing to worry about the run-time performance impact.

      An identity function is a function that just returns its argument. Here's an example of inlining an identity function:

      // Original code
      function logCalls(fn) {
      if (window.DEBUG) return function(...args) {
      console.log('calling', fn.name, 'with', args)
      return fn.apply(this, args)
      }
      return fn
      }
      export const foo = logCalls(function foo() {})

      // Old output (with --minify --define:window.DEBUG=false --tree-shaking=true)
      function o(n){return n}export const foo=o(function(){});

      // New output (with --minify --define:window.DEBUG=false --tree-shaking=true)
      export const foo=function(){};

      An empty function is a function with an empty body. Here's an example of inlining an empty function:

      // Original code
      function assertNotNull(val: Object | null): asserts val is Object {
      if (window.DEBUG && val === null) throw new Error('null assertion failed');
      }
      export const val = getFoo();
      assertNotNull(val);
      console.log(val.bar);

      // Old output (with --minify --define:window.DEBUG=false --tree-shaking=true)
      function l(o){}export const val=getFoo();l(val);console.log(val.bar);

      // New output (with --minify --define:window.DEBUG=false --tree-shaking=true)
      export const val=getFoo();console.log(val.bar);

      To get this behavior you'll need to use the function keyword to define your function since that causes the definition to be hoisted, which eliminates concerns around initialization order. These features also work across modules, so functions are still inlined even if the definition of the function is in a separate module from the call to the function. To get cross-module function inlining to work, you'll need to have bundling enabled and use the import and export keywords to access the function so that esbuild can see which functions are called. And all of this has been added without an observable impact to compile times.

      I previously wasn't able to add this to esbuild easily because of esbuild's low-pass compilation approach. The compiler only does three full passes over the data for speed. The passes are roughly for parsing, binding, and printing. It's only possible to inline something after binding but it needs to be inlined before printing. Also the way module linking was done made it difficult to roll back uses of symbols that were inlined, so the symbol definitions were not tree shaken even when they became unused due to inlining.

      The linking issue was somewhat resolved when I fixed #128 in the previous release. To implement cross-module inlining of TypeScript enums, I came up with a hack to defer certain symbol uses until the linking phase, which happens after binding but before printing. Another hack is that inlining of TypeScript enums is done directly in the printer to avoid needing another pass.

      The possibility of these two hacks has unblocked these simple function inlining use cases that are now handled. This isn't a fully general approach because optimal inlining is recursive. Inlining something may open up further inlining opportunities, which either requires multiple iterations or a worklist algorithm, both of which don't work when doing late-stage inlining in the printer. But the function inlining that esbuild now implements is still useful even though it's one level deep, and so I believe it's still worth adding.

  • 0.14.9 - 2021-12-29
    Read more
  • 0.14.8 - 2021-12-23
    Read more
  • 0.14.7 - 2021-12-21
    Read more
  • 0.14.6 - 2021-12-20
    Read more
  • 0.14.5 - 2021-12-14
    • 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.

  • 0.14.4 - 2021-12-14
    Read more
  • 0.14.3 - 2021-12-12
    Read more
  • 0.14.2 - 2021-12-04
    Read more
  • 0.14.1 - 2021-11-30
    Read more
  • 0.14.0 - 2021-11-26
  • 0.13.15 - 2021-11-20
  • 0.13.14 - 2021-11-16
  • 0.13.13 - 2021-11-09
  • 0.13.12 - 2021-10-31
  • 0.13.11 - 2021-10-30
  • 0.13.10 - 2021-10-28
  • 0.13.9 - 2021-10-23
  • 0.13.8 - 2021-10-17
  • 0.13.7 - 2021-10-15
  • 0.13.6 - 2021-10-14
  • 0.13.5 - 2021-10-13
  • 0.13.4 - 2021-10-05
  • 0.13.3 - 2021-09-28
  • 0.13.2 - 2021-09-23
  • 0.13.1 - 2021-09-23
  • 0.13.0 - 2021-09-22
  • 0.12.29 - 2021-09-22
  • 0.12.28 - 2021-09-14
  • 0.12.27 - 2021-09-13
  • 0.12.26 - 2021-09-09
  • 0.12.25 - 2021-09-02
  • 0.12.24 - 2021-08-27
  • 0.12.23 - 2021-08-26
  • 0.12.22 - 2021-08-21
from esbuild GitHub release notes

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant