diff --git a/lib/build/slim.js b/lib/build/slim.js index 5a508940..af1da127 100644 --- a/lib/build/slim.js +++ b/lib/build/slim.js @@ -64,7 +64,10 @@ module.exports = function(cfg, opts) { addModuleIds(), convertSlimConfig(), loadNodeBuilder(), - transpile({ outputFormat: "slim" }), + transpile({ + outputFormat: "slim", + keepInGraph: ["@steal", "@loader"] + }), bundle(), addPluginNames(), addBundleIds(), diff --git a/lib/graph/pluck.js b/lib/graph/pluck.js index 493c86d7..6fbb3773 100644 --- a/lib/graph/pluck.js +++ b/lib/graph/pluck.js @@ -1,19 +1,20 @@ +var includes = require("lodash/includes"); // removes a module and all of its dependencies from the graph. -module.exports = function(graph, name) { +module.exports = function(graph, name, _except) { var modules = []; var visited = {}; + var except = _except == null ? [] : _except; function visit(name) { - if (!visited[name]) { + if (!visited[name] && !includes(except, name)) { visited[name] = true; var node = graph[name]; delete graph[name]; + if (node) { - node.dependencies.forEach(function(moduleName) { - visit(moduleName); - }); + node.dependencies.forEach(visit); modules.push(node); } } diff --git a/lib/stream/transpile.js b/lib/stream/transpile.js index fe5d537a..e33c60a3 100644 --- a/lib/stream/transpile.js +++ b/lib/stream/transpile.js @@ -23,11 +23,14 @@ function transpileGraph(data, transpileOptions) { // Remove @config so it is not transpiled. It is a global, // but we will want it to run ASAP. - var configGraph = pluck(dependencyGraph, - data.loader.configMain || "@config"); + var configGraph = pluck( + dependencyGraph, + data.loader.configMain || "@config", + transpileOptions.keepInGraph || [] + ); // Remove steal dev from production builds. - pluck(dependencyGraph,"@dev"); + pluck(dependencyGraph, "@dev", transpileOptions.keepInGraph || []); // Clean development code if the option was passed if(options.removeDevelopmentCode) { diff --git a/test/slim/at_loader/npm.html b/test/slim/at_loader/npm.html new file mode 100644 index 00000000..40e6dcce --- /dev/null +++ b/test/slim/at_loader/npm.html @@ -0,0 +1,10 @@ + + +
+ +