From ef829fe3025ec50feeb245eb425ad073f1b28c0b Mon Sep 17 00:00:00 2001 From: Paul Sachs Date: Wed, 17 May 2017 19:26:34 -0400 Subject: [PATCH] Adding noParse on module --- src/Module.js | 8 +++++++- test/Module.js | 12 +++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Module.js b/src/Module.js index 38e0cc4..6442319 100644 --- a/src/Module.js +++ b/src/Module.js @@ -1,10 +1,12 @@ const ChainedMap = require('./ChainedMap'); +const ChainedSet = require('./ChainedSet'); const Rule = require('./Rule'); module.exports = class extends ChainedMap { constructor(parent) { super(parent); this.rules = new ChainedMap(this); + this.noParse = new ChainedSet(this); } rule(name) { @@ -17,7 +19,8 @@ module.exports = class extends ChainedMap { toConfig() { return this.clean(Object.assign(this.entries() || {}, { - rules: this.rules.values().map(r => r.toConfig()) + rules: this.rules.values().map(r => r.toConfig()), + noParse: this.noParse.values() })); } @@ -33,6 +36,9 @@ module.exports = class extends ChainedMap { .keys(value) .forEach(name => this.rule(name).merge(value[name])); } + case 'noParse': { + return this.noParse.merge(value); + } default: { this.set(key, value); diff --git a/test/Module.js b/test/Module.js index 9cbfa0f..daab354 100644 --- a/test/Module.js +++ b/test/Module.js @@ -34,6 +34,16 @@ test('toConfig with values', t => { const module = new Module(); module.rule('compile').test(/\.js$/); + module.noParse.add(/.min.js/); - t.deepEqual(module.toConfig(), { rules: [{ test: /\.js$/ }] }); + t.deepEqual(module.toConfig(), { rules: [{ test: /\.js$/ }], noParse: [/.min.js/]}); }); + +test('noParse', t => { + const module = new Module(); + const instance = module.noParse.add(/.min.js/).end(); + + t.is(instance, module); + t.deepEqual(module.noParse.values()[0], /.min.js/); +}); +