Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not deep clone the graph and loader objects
Closes #855
- Loading branch information
Showing
6 changed files
with
41 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,42 @@ | ||
var through = require("through2"); | ||
var omit = require("lodash/omit"); | ||
var clone = require("lodash/clone"); | ||
var assign = require("lodash/assign"); | ||
|
||
module.exports = function(options) { | ||
return through.obj(function(data, enc, next) { | ||
try { | ||
next(null, adjustBundlesPath(data, options)); | ||
next(null, options.target ? adjustBundlesPath(data, options) : data); | ||
} catch (err) { | ||
next(err); | ||
} | ||
}); | ||
}; | ||
|
||
/** | ||
* Appends the target name to the bundles path | ||
* | ||
* Each target build should be written in its own subfolder, e.g: | ||
* | ||
* dist/bundles/node | ||
* dist/bundles/web | ||
* dist/bundles/worker | ||
* | ||
* This should only happen when target is explicitly set. | ||
*/ | ||
function adjustBundlesPath(data, options) { | ||
if (options.target) { | ||
var path = require("path"); | ||
var path = require("path"); | ||
var configuration = clone(data.configuration); | ||
|
||
// override the configuration getter for `bundlesPath` so it | ||
// includes the target name | ||
var bundlesPath = data.configuration.bundlesPath; | ||
Object.defineProperty(data.configuration, "bundlesPath", { | ||
configurable: true, | ||
get: function() { | ||
return path.join(bundlesPath, options.target); | ||
} | ||
}); | ||
} | ||
var bundlesPath = configuration.bundlesPath; | ||
Object.defineProperty(configuration, "bundlesPath", { | ||
configurable: true, | ||
get: function() { | ||
return path.join(bundlesPath, options.target); | ||
} | ||
}); | ||
|
||
return data; | ||
return assign({}, omit(data, ["configuration"]), { | ||
configuration: configuration | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters