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

DEV: @babel/plugin-proposal-decorators -> decorator-transforms #25290

Merged
merged 1 commit into from
May 8, 2024

Conversation

davidtaylorhq
Copy link
Member

@davidtaylorhq davidtaylorhq commented Jan 16, 2024

decorator-transforms (https://github.com/ef4/decorator-transforms) is a modern replacement for babel's plugin-proposal-decorators. It provides a decorator implementation using modern browser features, without needing to enable babel's full suite of class feature transformations. This improves the developer experience and performance.

In local testing with Google's 'tachometer' tool, this reduces Discourse's 'init-to-render' time by around 3-4% (230ms -> 222ms).

It reduces our initial gzip'd JS payloads by 3.2% (2.43MB -> 2.35MB), or 7.5% (14.5MB -> 13.4MB) uncompressed.

Copy link

This pull request has been automatically marked as stale because it has been open for 60 days with no activity. To keep it open, remove the stale tag, push code, or add a comment. Otherwise, it will be closed in 14 days.

@github-actions github-actions bot added the Stale label Mar 17, 2024
@davidtaylorhq davidtaylorhq force-pushed the decorator-transforms branch 2 times, most recently from 7eef1e8 to 26ccad4 Compare April 25, 2024 16:13
@davidtaylorhq davidtaylorhq force-pushed the decorator-transforms branch 4 times, most recently from 6fa1e7b to c99b9e9 Compare May 3, 2024 13:29
@davidtaylorhq davidtaylorhq marked this pull request as ready for review May 3, 2024 13:29
@davidtaylorhq davidtaylorhq force-pushed the decorator-transforms branch 3 times, most recently from 13d9654 to 0547e07 Compare May 3, 2024 13:44
@@ -92,7 +92,7 @@ class MyClass {
JS

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

Choose a reason for hiding this comment

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

Is dt7948 name stable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup!

(obviously wouldn't consider it 'public API', but I think it's stable enough for us to use in this test assertion)

decorator-transforms (https://github.com/ef4/decorator-transforms) is a modern replacement for babel's plugin-proposal-decorators. It provides a decorator implementation using modern browser features, without needing to enable babel's full suite of class feature transformations. This improves the developer experience and performance.

In local testing with Google's 'tachometer' tool, this reduces Discourse's 'init-to-render' time by around 3-4% (230ms -> 222ms).

It reduces our initial gzip'd JS payloads by 3.2% (2.43MB -> 2.35MB), or 7.5% (14.5MB -> 13.4MB) uncompressed.
@davidtaylorhq davidtaylorhq merged commit 0f45208 into main May 8, 2024
16 checks passed
@davidtaylorhq davidtaylorhq deleted the decorator-transforms branch May 8, 2024 09:40
@Arkshine
Copy link
Contributor

Arkshine commented May 9, 2024

I just wanted to let you know that In a theme component, I was doing the following:

api.modifyClass("service:chat-state-manager", {
  @tracked isChatSidebarActive: false,
  ...
});

However, after this PR, it no longer works, and isChatSidebarActive returns a function.

ƒ () {
      return propertyDesc;
}

Maybe it was wrong from the start doing that, especially in a native class. (if #24957 is merged, I would assume it would be okay)
Using isChatSidebarActive: tracked({ value: false }), instead seems to work at the moment.

davidtaylorhq added a commit that referenced this pull request May 10, 2024
…orms` (#25290)"

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.
davidtaylorhq added a commit that referenced this pull request May 10, 2024
…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.
brrusselburg pushed a commit to brrusselburg/discourse that referenced this pull request May 10, 2024
…orms` (discourse#25290)" (discourse#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.
@discoursebot
Copy link

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

https://meta.discourse.org/t/this-error-is-a-problem/307647/3

davidtaylorhq added a commit that referenced this pull request May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants