Skip to content

Commit

Permalink
Revert "DEV: @babel/plugin-proposal-decorators -> `decorator-transf…
Browse files Browse the repository at this point in the history
…orms` (#25290)" (#26971)

This reverts commit 0f45208.

This has led to two problems:

1. An incompatibility with Cloudflare's "auto minify" feature. They've deprecated this feature because of incompatibility with modern JS syntax. But unfortunately it will remain enabled on existing properties until 2024-08-05.

2. Discourse fails to boot in Safari 15. This is strange, because Safari does support all the required features in our production JS bundles. Even more strangely, things start working as soon as you open the developer tools. That suggests the cause could be a Safari bug rather than a simple incompatibility.

Reverting while we work out a path forward on both those issues.
  • Loading branch information
davidtaylorhq committed May 10, 2024
1 parent 47cabdc commit 97847f6
Show file tree
Hide file tree
Showing 17 changed files with 12 additions and 151 deletions.
17 changes: 0 additions & 17 deletions app/assets/javascripts/admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@ const path = require("path");
module.exports = {
name: require("./package").name,

options: {
babel: {
plugins: [
[
require.resolve("decorator-transforms"),
{
runEarly: true,
},
],
],
},

"ember-cli-babel": {
disableDecoratorTransforms: true,
},
},

// return an empty tree here as we do not want the addon modules to be
// included into vendor.js; instead, we will produce a separate bundle
// (admin.js) to be included via a script tag as needed
Expand Down
17 changes: 0 additions & 17 deletions app/assets/javascripts/dialog-holder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,6 @@
module.exports = {
name: require("./package").name,

options: {
babel: {
plugins: [
[
require.resolve("decorator-transforms"),
{
runEarly: true,
},
],
],
},

"ember-cli-babel": {
disableDecoratorTransforms: true,
},
},

isDevelopingAddon() {
return true;
},
Expand Down
15 changes: 0 additions & 15 deletions app/assets/javascripts/discourse-common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@ module.exports = {
handlebars: "handlebars/dist/cjs/handlebars.js",
},
},

babel: {
plugins: [
[
require.resolve("decorator-transforms"),
{
runEarly: true,
},
],
],
},

"ember-cli-babel": {
disableDecoratorTransforms: true,
},
},

isDevelopingAddon() {
Expand Down
11 changes: 1 addition & 10 deletions app/assets/javascripts/discourse-plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,11 @@ module.exports = {

options: {
babel: {
plugins: [
require.resolve("deprecation-silencer"),
[
require.resolve("decorator-transforms"),
{
runEarly: true,
},
],
],
plugins: [require.resolve("deprecation-silencer")],
},

"ember-cli-babel": {
throwUnlessParallelizable: true,
disableDecoratorTransforms: true,
},

"ember-this-fallback": {
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/discourse/app/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable simple-import-sort/imports */
import "decorator-transforms/globals";
import "./loader-shims";
import "./global-compat";
/* eslint-enable simple-import-sort/imports */
Expand Down
12 changes: 1 addition & 11 deletions app/assets/javascripts/discourse/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,10 @@ module.exports = function (defaults) {

"ember-cli-babel": {
throwUnlessParallelizable: true,
disableDecoratorTransforms: true,
},

babel: {
sourceMaps: false,
plugins: [
require.resolve("deprecation-silencer"),
[
require.resolve("decorator-transforms"),
{
runEarly: true,
},
],
],
plugins: [require.resolve("deprecation-silencer")],
},

vendorFiles: {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/discourse/tests/setup-tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable simple-import-sort/imports */
import Application from "../app";
import "./loader-shims";
/* eslint-enable simple-import-sort/imports */

Expand Down Expand Up @@ -47,6 +46,7 @@ import deprecated from "discourse-common/lib/deprecated";
import { setDefaultOwner } from "discourse-common/lib/get-owner";
import { setupS3CDN, setupURL } from "discourse-common/lib/get-url";
import { buildResolver } from "discourse-common/resolver";
import Application from "../app";
import { loadSprites } from "../lib/svg-sprite-loader";
import * as FakerModule from "@faker-js/faker";
import { setLoadedFaker } from "discourse/lib/load-faker";
Expand Down
17 changes: 1 addition & 16 deletions app/assets/javascripts/float-kit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,7 @@

module.exports = {
name: require("./package").name,
options: {
babel: {
plugins: [
[
require.resolve("decorator-transforms"),
{
runEarly: true,
},
],
],
},

"ember-cli-babel": {
disableDecoratorTransforms: true,
},
},
options: {},
isDevelopingAddon() {
return true;
},
Expand Down
17 changes: 0 additions & 17 deletions app/assets/javascripts/pretty-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,6 @@
module.exports = {
name: require("./package").name,

options: {
babel: {
plugins: [
[
require.resolve("decorator-transforms"),
{
runEarly: true,
},
],
],
},

"ember-cli-babel": {
disableDecoratorTransforms: true,
},
},

isDevelopingAddon() {
return true;
},
Expand Down
17 changes: 1 addition & 16 deletions app/assets/javascripts/select-kit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,7 @@

module.exports = {
name: require("./package").name,
options: {
babel: {
plugins: [
[
require.resolve("decorator-transforms"),
{
runEarly: true,
},
],
],
},

"ember-cli-babel": {
disableDecoratorTransforms: true,
},
},
options: {},
isDevelopingAddon() {
return true;
},
Expand Down
3 changes: 1 addition & 2 deletions app/assets/javascripts/theme-transpiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"handlebars": "^4.7.8",
"path-browserify": "^1.0.1",
"polyfill-crypto.getrandomvalues": "^1.0.0",
"terser": "^5.31.0",
"decorator-transforms": "^2.0.0"
"terser": "^5.31.0"
},
"engines": {
"node": ">= 18",
Expand Down
3 changes: 0 additions & 3 deletions app/assets/javascripts/theme-transpiler/transpiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ globalThis.console = {
import { transform as babelTransform } from "@babel/standalone";
import HTMLBarsInlinePrecompile from "babel-plugin-ember-template-compilation";
import { Preprocessor } from "content-tag";
import DecoratorTransforms from "decorator-transforms";
import colocatedBabelPlugin from "ember-cli-htmlbars/lib/colocated-babel-plugin";
import { precompile } from "ember-source/dist/ember-template-compiler";
import EmberThisFallback from "ember-this-fallback";
Expand Down Expand Up @@ -139,8 +138,6 @@ globalThis.transpile = function (source, options = {}) {
if (moduleId && !skipModule) {
plugins.push(["transform-modules-amd", { noInterop: true }]);
}
commonPlugins.find((p) => p[0] === "decorator-transforms")[0] =
DecoratorTransforms;
plugins.push(...commonPlugins);

try {
Expand Down
2 changes: 1 addition & 1 deletion app/models/theme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Theme < ActiveRecord::Base
include GlobalPath

BASE_COMPILER_VERSION = 82
BASE_COMPILER_VERSION = 81

class SettingsMigrationError < StandardError
end
Expand Down
4 changes: 3 additions & 1 deletion lib/discourse_js_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class TranspileError < StandardError
# To generate a list of babel plugins used by ember-cli, set
# babel: { debug: true } in ember-cli-build.js, then run `yarn ember build -prod`
DISCOURSE_COMMON_BABEL_PLUGINS = [
["decorator-transforms", { runEarly: true }],
["proposal-decorators", { legacy: true }],
"proposal-class-properties",
"proposal-private-methods",
"proposal-class-static-block",
"transform-parameters",
"proposal-export-namespace-from",
Expand Down
21 changes: 0 additions & 21 deletions patches/decorator-transforms+2.0.0.patch

This file was deleted.

2 changes: 1 addition & 1 deletion spec/lib/discourse_js_processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class MyClass {
JS

result = DiscourseJsProcessor.transpile(script, "blah", "blah/mymodule")
expect(result).to include("static #_ = dt7948.n")
expect(result).to include("_applyDecoratedDescriptor")
end

it "correctly transpiles widget hbs" do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/theme_javascript_compiler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class MyComponent extends Component {}
expect(compiler.raw_content).to include(
"define(\"discourse/theme-1/discourse/components/my-component\", [\"exports\",",
)
expect(compiler.raw_content).to include('value = "foo";')
expect(compiler.raw_content).to include("_defineProperty(this, \"value\", \"foo\");")
expect(compiler.raw_content).to include("setComponentTemplate")
expect(compiler.raw_content).to include("createTemplateFactory")
end
Expand Down

2 comments on commit 97847f6

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/discourse-site-cannot-be-opened-on-safari-ios-15-8-2/307523/7

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/discourse-broken-after-moving-servers/307476/14

Please sign in to comment.