This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move jobs to separate file w less deps, reduce worker mem consumption.
- Loading branch information
Showing
3 changed files
with
38 additions
and
33 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const smap = require('source-map'); | ||
const SourceMapConsumer = smap.SourceMapConsumer; | ||
const SourceMapGenerator = smap.SourceMapGenerator; | ||
const SourceNode = smap.SourceNode; | ||
|
||
const OptimizeJob = { | ||
path: 'OptimizeJob', | ||
|
||
serialize(hash) { | ||
const optimizer = hash.optimizer.brunchPluginName; | ||
const params = hash.params; | ||
return {optimizer, params: {data: params.data, map: params.map, path: params.path}}; | ||
}, | ||
|
||
deserialize(ctx, hash) { | ||
const optimizer = ctx.plugins.optimizers.find(p => p.brunchPluginName === hash.optimizer); | ||
|
||
const deserializeSourceMap = serializedMap => { | ||
return SourceMapGenerator.fromSourceMap(new SourceMapConsumer(serializedMap)); | ||
}; | ||
|
||
const params = hash.params; | ||
params.map = deserializeSourceMap(params.map); | ||
|
||
return {optimizer, params}; | ||
}, | ||
|
||
work(hash) { | ||
const optimizer = hash.optimizer; | ||
const file = hash.params; | ||
|
||
return optimizer.optimize(file); | ||
}, | ||
}; | ||
|
||
exports.OptimizeJob = OptimizeJob; |