Skip to content

Commit

Permalink
Merge pull request #58 from canjs/register-deps
Browse files Browse the repository at this point in the history
Register dynamic imports to the slim loader
  • Loading branch information
m-mujica authored Feb 1, 2018
2 parents 2bc88fe + 62c5406 commit 9246e61
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion steal-stache.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"format cjs";
var getIntermediateAndImports = require("can-stache/src/intermediate_and_imports");
var addBundles = require("./add-bundles");
var loader = require("@loader");

function template(imports, intermediate, filename){
imports = JSON.stringify(imports);
Expand Down Expand Up @@ -41,6 +42,16 @@ function translate(load) {
this.normalize("can-stache-bindings", module.id)
]);

// Register dynamic imports for the slim loader config
var localLoader = loader.localLoader || loader;
if (localLoader.slimConfig) {
localLoader.slimConfig.needsDynamicLoader = true;

var push = Array.prototype.push;
var toMap = localLoader.slimConfig.toMap;
push.apply(toMap, intermediateAndImports.imports);
push.apply(toMap, intermediateAndImports.dynamicImports);
}

// Add bundle configuration for these dynamic imports
return Promise.all([
Expand All @@ -58,7 +69,11 @@ function translate(load) {
intermediateAndImports.imports.unshift("can-stache");
intermediateAndImports.imports.unshift("module");

return template(intermediateAndImports.imports, intermediateAndImports.intermediate, filename);
return template(
intermediateAndImports.imports,
intermediateAndImports.intermediate,
filename
);
});
}

Expand Down

0 comments on commit 9246e61

Please sign in to comment.