mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 06:13:38 +08:00
565c753dd2
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 was previously reverted in 97847f6
. This version includes a babel transformation which works around the bug in Safari <= 15.
For Cloudflare compatibility issues, check https://meta.discourse.org/t/311390
37 lines
988 B
JavaScript
37 lines
988 B
JavaScript
"use strict";
|
|
|
|
const calculateCacheKeyForTree = require("calculate-cache-key-for-tree");
|
|
const path = require("path");
|
|
const commonBabelConfig = require("../discourse/lib/common-babel-config");
|
|
|
|
module.exports = {
|
|
name: require("./package").name,
|
|
|
|
options: {
|
|
...commonBabelConfig(),
|
|
},
|
|
|
|
// 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
|
|
treeForAddon() {
|
|
return;
|
|
},
|
|
|
|
// custom method to produce the tree for admin.js
|
|
// called by ember-cli-build.js in discourse core
|
|
treeForAddonBundle() {
|
|
let addonTreePath = path.resolve(this.root, this.treePaths.addon);
|
|
let addonTree = this.treeGenerator(addonTreePath);
|
|
return this._super.treeForAddon.call(this, addonTree);
|
|
},
|
|
|
|
cacheKeyForTree(tree) {
|
|
return calculateCacheKeyForTree(tree, this);
|
|
},
|
|
|
|
isDevelopingAddon() {
|
|
return true;
|
|
},
|
|
};
|