mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 09:15:48 +08:00
3d7cca5911
Currently, the admin/wizard build relies on the addon build getting triggered first, so that its `treeForAddon()` hook will be called, and then it can stash the result on the app's options, which is super fragile. In Embroider the timing works differently so the trees end up being `undefined`. This inverts the logic so that it will be discourse core's build calling these hooks at a specific timing and return the result rather than coordinating through the options bag. ``` $ diff dist/assets/admin.js dist-after/assets/admin.js $ diff dist/assets/wizard.js dist-after/assets/wizard.js ```
32 lines
868 B
JavaScript
32 lines
868 B
JavaScript
"use strict";
|
|
|
|
const calculateCacheKeyForTree = require("calculate-cache-key-for-tree");
|
|
const path = require("path");
|
|
|
|
module.exports = {
|
|
name: require("./package").name,
|
|
|
|
// 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
|
|
// (wizard.js) to be included via a script tag as needed
|
|
treeForAddon() {
|
|
return;
|
|
},
|
|
|
|
// custom method to produce the tree for wizard.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;
|
|
},
|
|
};
|