Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Switch noParse to getter/setter to allow webpack v3 function argument #32

Merged
merged 1 commit into from
Aug 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
dist: trusty
language: node_js
cache: yarn
node_js:
- '6.9'
- '7.7'
cache:
yarn: true
directories:
- node_modules
before_script:
- yarn
- '6.10'
- '7'
- '8'
install:
- yarn install --frozen-lockfile
before_install:
# Required due to: https://github.com/travis-ci/travis-ci/issues/7951
- curl -sSfL https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
script:
- yarn test
- yarn test
28 changes: 12 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# webpack-chain

Use a chaining API to generate and simplify the modification of
Webpack 2 configurations.
Webpack 2 and 3 configurations.

This README corresponds to v3 of webpack-chain.
This documentation corresponds to v4 of webpack-chain.

[v2 docs](https://github.com/mozilla-neutrino/webpack-chain/tree/v2)
* [v3 docs](https://github.com/mozilla-neutrino/webpack-chain/tree/v3)
* [v2 docs](https://github.com/mozilla-neutrino/webpack-chain/tree/v2)
* [v1 docs](https://github.com/mozilla-neutrino/webpack-chain/tree/v1.4.3)

[v1 docs](https://github.com/mozilla-neutrino/webpack-chain/tree/v1.4.3)
_Note: while webpack-chain is utilized extensively in Neutrino, this package is completely
standalone and can be used by any project._

## Introduction

Expand All @@ -24,14 +27,10 @@ standardize how to modify a configuration across projects.

This is easier explained through the examples following.

## Contributing

We welcome any contributor. Just fork and clone, make changes, and send a pull request.

## Installation

`webpack-chain` requires Node.js v6.9 and higher. `webpack-chain` also
only creates configuration objects designed for use in Webpack 2.
only creates configuration objects designed for use in Webpack 2 and 3.

You may install this package using either Yarn or npm (choose one):

Expand Down Expand Up @@ -682,15 +681,13 @@ config.devServer
config.module : ChainedMap
```

#### Config module noParse
#### Config module: shorthand methods

```js
config.module.noParse : ChainedSet
config.module : ChainedMap

config.module.noParse
.add(value)
.prepend(value)
.clear()
config.module
.noParse(noParse)
```

#### Config module rules: shorthand methods
Expand Down Expand Up @@ -859,7 +856,6 @@ config.merge({
module: {
[key]: value,

noParse: [...values],
rule: {
[name]: {
[key]: value,
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
"author": "Eli Perelman <[email protected]>",
"license": "MPL-2.0",
"scripts": {
"test": "ava test"
"test": "ava test",
"changelog": "changelog mozilla-neutrino/webpack-chain all --markdown > CHANGELOG.md"
},
"dependencies": {
"deepmerge": "^1.3.2"
"deepmerge": "^1.5.0"
},
"devDependencies": {
"ava": "^0.19.1",
"webpack": "^2.3.3"
"ava": "^0.21.0",
"changelog": "^1.4.0",
"webpack": "^3.4.1"
}
}
10 changes: 2 additions & 8 deletions src/Module.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
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);
this.extend(['noParse']);
}

rule(name) {
Expand All @@ -19,8 +18,7 @@ module.exports = class extends ChainedMap {

toConfig() {
return this.clean(Object.assign(this.entries() || {}, {
rules: this.rules.values().map(r => r.toConfig()),
noParse: this.noParse.values()
rules: this.rules.values().map(r => r.toConfig())
}));
}

Expand All @@ -37,10 +35,6 @@ module.exports = class extends ChainedMap {
.forEach(name => this.rule(name).merge(value[name]));
}

case 'noParse': {
return this.noParse.merge(value);
}

default: {
this.set(key, value);
}
Expand Down
13 changes: 2 additions & 11 deletions test/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,7 @@ test('toConfig with values', t => {
const module = new Module();

module.rule('compile').test(/\.js$/);
module.noParse.add(/.min.js/);
module.noParse(/.min.js/);

t.deepEqual(module.toConfig(), { rules: [{ test: /\.js$/ }], noParse: [/.min.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/);
});

Loading