Skip to content

Commit 5da2dda

Browse files
committed
fix: Egregious hack to make lazy engines work.
1 parent bf7ba61 commit 5da2dda

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,16 @@ const EMBER_ADDON: AddonImplementation<CSSBlocksApplicationAddon> = {
139139

140140
if (type === "js") {
141141
if (env.isApp) {
142-
this.broccoliAppPluginInstance = new CSSBlocksApplicationPlugin(env.modulePrefix, [env.app.addonTree(), tree], {});
142+
let lazyAddons = this.project.addons.filter((a: any) => a.lazyLoading && a.lazyLoading.enabled === true);
143+
let jsOutputTrees = lazyAddons.map((a) => {
144+
// this isn't tenable *at all*
145+
let publicTree = (<any>a).treeForPublic();
146+
let jsTree = publicTree.inputNodes[publicTree.inputNodes.length - 1];
147+
let blocksOutputTree = jsTree._inputNodes[0]._inputNodes[0]._inputNodes[0]._inputNodes[0]._inputNodes[0]._inputNodes[0];
148+
return blocksOutputTree;
149+
});
150+
let lazyOutput = funnel(mergeTrees(jsOutputTrees), {destDir: "lazy-tree-output"});
151+
this.broccoliAppPluginInstance = new CSSBlocksApplicationPlugin(env.modulePrefix, [env.app.addonTree(), tree, lazyOutput], {});
143152
let debugTree = new BroccoliDebug(this.broccoliAppPluginInstance, `css-blocks:optimized`);
144153
return funnel(debugTree, {srcDir: env.modulePrefix, destDir: env.modulePrefix});
145154
} else {

packages/@css-blocks/ember-support/src/BroccoliTreeImporter.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export function identToPath(input: MergedFileSystem, identifier: string): string
2828
let addonModulesRelativePath = `addon-tree-output/modules/${relativePath}`;
2929
if (input.existsSync(addonModulesRelativePath)) {
3030
relativePath = addonModulesRelativePath;
31+
} else {
32+
let lazyRelativePath = `lazy-tree-output/${relativePath}`;
33+
if (input.existsSync(lazyRelativePath)) {
34+
relativePath = lazyRelativePath;
35+
}
3136
}
3237
}
3338
}
@@ -38,7 +43,9 @@ export function pathToIdent(relativePath: string): string {
3843
if (isBroccoliTreeIdentifier(relativePath)) {
3944
return relativePath;
4045
}
41-
if (relativePath.startsWith("addon-tree-output/modules/")) {
46+
if (relativePath.startsWith("lazy-tree-output/")) {
47+
relativePath = relativePath.substring(17);
48+
} else if (relativePath.startsWith("addon-tree-output/modules/")) {
4249
relativePath = relativePath.substring(26);
4350
} else if (relativePath.startsWith("addon-tree-output/")) {
4451
relativePath = relativePath.substring(18);

0 commit comments

Comments
 (0)