From 3b2fe3cd33b74166c3debec9826826f2b5a54fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 3 Nov 2020 09:05:09 +0100 Subject: js: Add avoidTDZ option Fixes #7865 --- resources/resource_transformers/js/options.go | 12 ++++++++++++ resources/resource_transformers/js/options_test.go | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'resources/resource_transformers') diff --git a/resources/resource_transformers/js/options.go b/resources/resource_transformers/js/options.go index 5e74982d3..84a6c1a78 100644 --- a/resources/resource_transformers/js/options.go +++ b/resources/resource_transformers/js/options.go @@ -70,6 +70,16 @@ type Options struct { // What to use instead of React.Fragment. JSXFragment string + // There is/was a bug in WebKit with severe performance issue with the tracking + // of TDZ checks in JavaScriptCore. + // + // Enabling this flag removes the TDZ and `const` assignment checks and + // may improve performance of larger JS codebases until the WebKit fix + // is in widespread use. + // + // See https://bugs.webkit.org/show_bug.cgi?id=199866 + AvoidTDZ bool + mediaType media.Type outDir string contents string @@ -339,6 +349,8 @@ func toBuildOptions(opts Options) (buildOptions api.BuildOptions, err error) { JSXFactory: opts.JSXFactory, JSXFragment: opts.JSXFragment, + AvoidTDZ: opts.AvoidTDZ, + Tsconfig: opts.tsConfig, Stdin: &api.StdinOptions{ diff --git a/resources/resource_transformers/js/options_test.go b/resources/resource_transformers/js/options_test.go index 89d362ab9..abc8091a9 100644 --- a/resources/resource_transformers/js/options_test.go +++ b/resources/resource_transformers/js/options_test.go @@ -54,7 +54,12 @@ func TestToBuildOptions(t *testing.T) { }) opts, err = toBuildOptions(Options{ - Target: "es2018", Format: "cjs", Minify: true, mediaType: media.JavascriptType}) + Target: "es2018", + Format: "cjs", + Minify: true, + mediaType: media.JavascriptType, + AvoidTDZ: true, + }) c.Assert(err, qt.IsNil) c.Assert(opts, qt.DeepEquals, api.BuildOptions{ Bundle: true, @@ -63,6 +68,7 @@ func TestToBuildOptions(t *testing.T) { MinifyIdentifiers: true, MinifySyntax: true, MinifyWhitespace: true, + AvoidTDZ: true, Stdin: &api.StdinOptions{ Loader: api.LoaderJS, }, -- cgit v1.2.3