mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +08:00
DEV: @babel/plugin-proposal-decorators
-> decorator-transforms
(#25290)
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.
This commit is contained in:
21
patches/decorator-transforms+2.0.0.patch
Normal file
21
patches/decorator-transforms+2.0.0.patch
Normal file
@ -0,0 +1,21 @@
|
||||
diff --git a/node_modules/decorator-transforms/dist/index.js b/node_modules/decorator-transforms/dist/index.js
|
||||
index fce3aeb..c23d8e4 100644
|
||||
--- a/node_modules/decorator-transforms/dist/index.js
|
||||
+++ b/node_modules/decorator-transforms/dist/index.js
|
||||
@@ -4,10 +4,13 @@ import {
|
||||
import "./chunk-CSAU5B4Q.js";
|
||||
|
||||
// src/index.ts
|
||||
-import { createRequire } from "module";
|
||||
+
|
||||
import { ImportUtil } from "babel-import-util";
|
||||
-var req = createRequire(import.meta.url);
|
||||
-var { default: decoratorSyntax } = req("@babel/plugin-syntax-decorators");
|
||||
+
|
||||
+// https://github.com/ef4/decorator-transforms/pull/27
|
||||
+import PluginSyntaxDecorators from "@babel/plugin-syntax-decorators";
|
||||
+const decoratorSyntax = PluginSyntaxDecorators.default || PluginSyntaxDecorators;
|
||||
+
|
||||
function makeVisitor(babel) {
|
||||
const t = babel.types;
|
||||
return {
|
Reference in New Issue
Block a user