From d141adb872fd4c54f1d7aec0d7e423cebe23eb44 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 26 Jul 2024 17:46:31 +0100 Subject: [PATCH] FIX: Adjust swc minify options for Safari 15 support (#28098) By default, the swc minifier seems to unwrap 'unneeded' IIFE. That means it was undoing the 'bugfix' transformation we have for class fields in Safari 15. Disabling the 'inline' and 'reduce_funcs' options seems to stop this behavior. --- app/assets/javascripts/discourse/ember-cli-build.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/assets/javascripts/discourse/ember-cli-build.js b/app/assets/javascripts/discourse/ember-cli-build.js index 9fa58bd6e2e..762fc84e8ec 100644 --- a/app/assets/javascripts/discourse/ember-cli-build.js +++ b/app/assets/javascripts/discourse/ember-cli-build.js @@ -145,6 +145,14 @@ module.exports = function (defaults) { minimizer: [ new TerserPlugin({ minify: TerserPlugin.swcMinify, + terserOptions: { + compress: { + // Stop swc unwrapping 'unnecessary' IIFE wrappers which are added by Babel + // to workaround a bug in Safari 15 class fields. + inline: false, + reduce_funcs: false, + }, + }, }), ], },