Skip to content

Commit 318e79a

Browse files
committed
fix: A cleaner approach to getting access to css-blocks build output.
1 parent fec1b7c commit 318e79a

File tree

1 file changed

+6
-23
lines changed
  • packages/@css-blocks/ember-app/src

1 file changed

+6
-23
lines changed

Diff for: packages/@css-blocks/ember-app/src/index.ts

+6-23
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,13 @@ const EMBER_ADDON: AddonImplementation<CSSBlocksApplicationAddon> = {
156156
// tslint:disable-next-line:prefer-unknown-to-any
157157
let lazyAddons = this.project.addons.filter((a: any) => a.lazyLoading && a.lazyLoading.enabled === true);
158158
let jsOutputTrees = lazyAddons.map((a) => {
159-
// XXX I have no idea how engines will work with embroider.
160-
// XXX This code assumes that lazy engines are always compiled
161-
// XXX at the same time as the application (not precompiled).
159+
// This won't work with embroider in (at least) the case of
160+
// precompiled ember engines. We need the intermediate build structure
161+
// of the addon to include the files I output from template
162+
// compilation.
163+
let addon = a.addons.find((child) => child.name === "@css-blocks/ember");
162164
// tslint:disable-next-line:prefer-unknown-to-any
163-
let publicTree = (<any>a).treeForPublic();
164-
return findCssBlocksTemplateOutputTree(publicTree.inputNodes);
165+
return addon && (<any>addon).templateCompiler;
165166
}).filter(Boolean);
166167
let lazyOutput = funnel(mergeTrees(jsOutputTrees), {destDir: "lazy-tree-output"});
167168
this.broccoliAppPluginInstance = new CSSBlocksApplicationPlugin(env.modulePrefix, [env.app.addonTree(), tree, lazyOutput], env.config);
@@ -195,22 +196,4 @@ interface MaybeCSSBlocksTreePlugin {
195196
isCssBlocksTemplateCompiler: boolean | undefined;
196197
}
197198

198-
function findCssBlocksTemplateOutputTree(trees: Array<MaybeCSSBlocksTree>): MaybeCSSBlocksTree | null {
199-
for (let tree of trees) {
200-
if (typeof tree === "object" && tree.isCssBlocksTemplateCompiler === true) {
201-
return tree;
202-
}
203-
}
204-
for (let tree of trees) {
205-
if (typeof tree === "object" && tree._inputNodes) {
206-
let found = findCssBlocksTemplateOutputTree(tree._inputNodes);
207-
if (found !== null) {
208-
return found;
209-
}
210-
}
211-
}
212-
return null;
213-
}
214-
215-
// Aaaaand export the addon implementation!
216199
module.exports = EMBER_ADDON;

0 commit comments

Comments
 (0)