Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/upstream/master'
Browse files Browse the repository at this point in the history
Conflicts:
	.gitignore
	package.json
  • Loading branch information
e-cloud committed Nov 9, 2016
2 parents 485775c + 1b24bcf commit bd397af
Show file tree
Hide file tree
Showing 58 changed files with 442 additions and 4,915 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ lib/**/*.map
.DS_Store
.idea
.vscode

yarn.lock
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@ cache:

os:
- linux
# - osx
- osx
node_js:
- "7"
- "6"
- "4"
- "v0.12.17"

matrix:
allow_failures:
- node_js: "4"
- node_js: "v0.12.17"
- os: osx

script: npm run travis
env:
- NO_WATCH_TESTS=1

before_install: if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi
install:
- npm install yarn -g
- yarn install
- if [ ! -h "$HOME/.yarn-cache/.link/webpack" ]; then yarn link; fi
- yarn link webpack

- bash ./ci/travis-install.sh
after_success:
- cat ./coverage/lcov.info | node_modules/.bin/coveralls --verbose
- cat ./coverage/coverage.json | node_modules/codecov.io/bin/codecov.io.js
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ environment:
install:
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
- npm install yarn -g
- yarn install --msvs_version=2013
- yarn install
- yarn link
- yarn link webpack

Expand Down
8 changes: 2 additions & 6 deletions bin/config-yargs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module.exports = function(yargs) {
yargs
.help("help")
.alias("help", "h", "?")
.version()
.alias("version", "v")
.options({
"config": {
type: "string",
Expand All @@ -22,12 +24,6 @@ module.exports = function(yargs) {
describe: "Enviroment passed to the config, when it is a function",
group: CONFIG_GROUP
},
"version": {
type: "string",
describe: "Webpack version",
alias: "v",
group: BASIC_GROUP,
},
"context": {
type: "string",
describe: "The root directory for resolving entry point and stats",
Expand Down
25 changes: 6 additions & 19 deletions bin/convert-argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,11 @@ fs.existsSync = fs.existsSync || path.existsSync;
var resolve = require("enhanced-resolve");
var interpret = require("interpret");
var WebpackOptionsDefaulter = require("../lib/WebpackOptionsDefaulter");
var validateWebpackOptions = require("../lib/validateWebpackOptions");

module.exports = function(optimist, argv, convertOptions) {
module.exports = function(yargs, argv, convertOptions) {

var options = [];

// Help
if(argv.help) {
optimist.showHelp();
process.exit(0); // eslint-disable-line
}

// Version
if(argv.v || argv.version) {
console.log(require("../package.json").version);
process.exit(0); // eslint-disable-line
}

// Shortcuts
if(argv.d) {
argv.debug = true;
Expand Down Expand Up @@ -53,7 +40,7 @@ module.exports = function(optimist, argv, convertOptions) {

var i;
if(argv.config) {
function getConfigExtension(configPath) {
var getConfigExtension = function getConfigExtension(configPath) {
for(i = extensions.length - 1; i >= 0; i--) {
var tmpExt = extensions[i];
if(configPath.indexOf(tmpExt, configPath.length - tmpExt.length) > -1) {
Expand All @@ -63,7 +50,7 @@ module.exports = function(optimist, argv, convertOptions) {
return path.extname(configPath);
}

function mapConfigArg(configArg) {
var mapConfigArg = function mapConfigArg(configArg) {
var resolvedPath = path.resolve(configArg);
var extension = getConfigExtension(resolvedPath);
return {
Expand All @@ -88,7 +75,7 @@ module.exports = function(optimist, argv, convertOptions) {
}

if(configFiles.length > 0) {
function registerCompiler(moduleDescriptor) {
var registerCompiler = function registerCompiler(moduleDescriptor) {
if(moduleDescriptor) {
if(typeof moduleDescriptor === "string") {
require(moduleDescriptor);
Expand All @@ -107,7 +94,7 @@ module.exports = function(optimist, argv, convertOptions) {
}
}

function requireConfig(configPath) {
var requireConfig = function requireConfig(configPath) {
var options = require(configPath);
var isES6DefaultExportedFunc = (
typeof options === "object" && options !== null && typeof options.default === "function"
Expand Down Expand Up @@ -538,7 +525,7 @@ module.exports = function(optimist, argv, convertOptions) {
}
ensureObject(options, "entry");

function addTo(name, entry) {
var addTo = function addTo(name, entry) {
if(options.entry[name]) {
if(!Array.isArray(options.entry[name])) {
options.entry[name] = [options.entry[name]];
Expand Down
8 changes: 8 additions & 0 deletions ci/travis-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -ev

if [ "$TRAVIS_NODE_VERSION" == "v0.12.17" ]; then
npm install --force && npm link && npm link webpack;
else
npm install yarn -g && yarn install && yarn link || true && yarn link webpack;
fi
5 changes: 4 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@ If you think an example is missing, please report it as issue. :)
# Building an Example

1. Run `npm install` in the root of the project.
2. Run `node build.js` in the specific example directory. (Ex: `cd examples/commonjs && node build.js`)
2. Run `npm link webpack` in the root of the project.
3. Run `node build.js` in the specific example directory. (Ex: `cd examples/commonjs && node build.js`)

Note: To build all examples run `npm run build:examples`
4 changes: 2 additions & 2 deletions examples/code-splitting-bundle-loader/example.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require("bundle!./file.js")(function(fileJsExports) {
require("bundle-loader!./file.js")(function(fileJsExports) {
console.log(fileJsExports);
});
});
4 changes: 2 additions & 2 deletions examples/coffee-script/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module.exports = {
module: {
loaders: [
{ test: /\.coffee$/, loader: "coffee" }
{ test: /\.coffee$/, loader: "coffee-loader" }
]
},
resolve: {
extensions: [".web.coffee", ".web.js", ".coffee", ".js"]
}
}
}
4 changes: 2 additions & 2 deletions examples/hybrid-routing/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b"
// -> Pages are only loaded on demand

// This line may throw a exception on runtime if the page wasn't found.
var pageBundle = require("bundle!./" + name + "Page");
var pageBundle = require("bundle-loader!./" + name + "Page");

// Wait until the chunk is loaded
pageBundle(function(page) {
render(page);
});
}
}
2 changes: 1 addition & 1 deletion examples/loader/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ console.dir(require("./loader!./file"));

// use buildin json loader
console.dir(require("./test.json")); // default by extension
console.dir(require("!json!./test.json")); // manual
console.dir(require("!json-loader!./test.json")); // manual
4 changes: 2 additions & 2 deletions examples/loader/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
module: {
loaders: [
{ test: /\.json$/, loader: "json" }
{ test: /\.json$/, loader: "json-loader" }
]
}
}
}
4 changes: 2 additions & 2 deletions examples/multi-part-library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This example demonstrates how to build a complex library with webpack. The libra

When using this library with script tags it exports itself to the namespace `MyLibrary` and each part to a property in this namespace (`MyLibrary.alpha` and `MyLibrary.beta`). When consuming the library with CommonsJs or AMD it just export each part.

We are using mutliple entry points (`entry` option) to build every part of the library as separate output file. The `output.filename` option contains `[name]` to give each output file a different name.
We are using multiple entry points (`entry` option) to build every part of the library as separate output file. The `output.filename` option contains `[name]` to give each output file a different name.

We are using the `libraryTarget` option to generate a UMD ([Universal Module Definition](https://github.com/umdjs/umd)) module that is consumable in CommonsJs, AMD and with script tags. The `library` option defines the namespace. We are using `[name]` in the `library` option to give every entry a different namespace.

Expand Down Expand Up @@ -261,4 +261,4 @@ chunk {0} MyLibrary.beta.js (beta) 24 bytes [entry] [rendered]
chunk {1} MyLibrary.alpha.js (alpha) 25 bytes [entry] [rendered]
> alpha [0] ./alpha.js
[0] ./alpha.js 25 bytes {1} [built]
```
```
4 changes: 2 additions & 2 deletions examples/multi-part-library/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This example demonstrates how to build a complex library with webpack. The libra

When using this library with script tags it exports itself to the namespace `MyLibrary` and each part to a property in this namespace (`MyLibrary.alpha` and `MyLibrary.beta`). When consuming the library with CommonsJs or AMD it just export each part.

We are using mutliple entry points (`entry` option) to build every part of the library as separate output file. The `output.filename` option contains `[name]` to give each output file a different name.
We are using multiple entry points (`entry` option) to build every part of the library as separate output file. The `output.filename` option contains `[name]` to give each output file a different name.

We are using the `libraryTarget` option to generate a UMD ([Universal Module Definition](https://github.com/umdjs/umd)) module that is consumable in CommonsJs, AMD and with script tags. The `library` option defines the namespace. We are using `[name]` in the `library` option to give every entry a different namespace.

Expand Down Expand Up @@ -42,4 +42,4 @@ Note: When your library has dependencies that should not be included in the comp

```
{{min:stdout}}
```
```
26 changes: 13 additions & 13 deletions examples/web-worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# example.js

``` javascript
var Worker = require("worker!./worker");
var Worker = require("worker-loader!./worker");
var worker = new Worker;
worker.postMessage("b");
worker.onmessage = function(event) {
Expand Down Expand Up @@ -335,9 +335,9 @@ Time: 191ms
hash.worker.js 3.83 kB [emitted]
output.js 3.18 kB 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 297 bytes [entry] [rendered]
> main [1] ./example.js
[0] (webpack)/~/worker-loader!./worker.js 96 bytes {0} [not cacheable] [built]
chunk {0} output.js (main) 302 bytes [entry] [rendered]
> main [1] ./example.js
[0] (webpack)/~/worker-loader!./worker.js 96 bytes {0} [built]
cjs require worker!./worker [1] ./example.js 1:13-39
[1] ./example.js 201 bytes {0} [built]
Child worker:
Expand All @@ -358,9 +358,9 @@ Child worker:
[4] ../require.context/templates/c.js 80 bytes {0} [optional] [built]
context element ./c [0] ../require.context/templates ^\.\/.*$
context element ./c.js [0] ../require.context/templates ^\.\/.*$
chunk {1} hash.worker.js (main) 162 bytes [entry] [rendered]
> main [1] ./worker.js
[1] ./worker.js 162 bytes {1} [built]
chunk {1} hash.worker.js (main) 168 bytes [entry] [rendered]
> main [1] ./worker.js
[1] ./worker.js 168 bytes {1} [built]
```

## Minimized (uglify-js, no zip)
Expand All @@ -374,9 +374,9 @@ Time: 329ms
hash.worker.js 842 bytes [emitted]
output.js 655 bytes 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 297 bytes [entry] [rendered]
> main [1] ./example.js
[0] (webpack)/~/worker-loader!./worker.js 96 bytes {0} [not cacheable] [built]
chunk {0} output.js (main) 302 bytes [entry] [rendered]
> main [1] ./example.js
[0] (webpack)/~/worker-loader!./worker.js 96 bytes {0} [built]
cjs require worker!./worker [1] ./example.js 1:13-39
[1] ./example.js 201 bytes {0} [built]
Child worker:
Expand All @@ -397,7 +397,7 @@ Child worker:
[4] ../require.context/templates/c.js 80 bytes {0} [optional] [built]
context element ./c [0] ../require.context/templates ^\.\/.*$
context element ./c.js [0] ../require.context/templates ^\.\/.*$
chunk {1} hash.worker.js (main) 162 bytes [entry] [rendered]
> main [1] ./worker.js
[1] ./worker.js 162 bytes {1} [built]
chunk {1} hash.worker.js (main) 168 bytes [entry] [rendered]
> main [1] ./worker.js
[1] ./worker.js 168 bytes {1} [built]
```
4 changes: 2 additions & 2 deletions examples/web-worker/example.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var Worker = require("worker!./worker");
var Worker = require("worker-loader!./worker");
var worker = new Worker;
worker.postMessage("b");
worker.onmessage = function(event) {
var templateB = event.data; // "This text was generated by template B"
}
}
24 changes: 12 additions & 12 deletions examples/web-worker/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
var webpack = require("../../");
module.exports = {
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
worker: {
output: {
filename: "hash.worker.js",
chunkFilename: "[id].hash.worker.js"
}
}
}
})
]
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
worker: {
output: {
filename: "hash.worker.js",
chunkFilename: "[id].hash.worker.js"
}
}
}
})
]
}
2 changes: 1 addition & 1 deletion hot/poll.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
if(module.hot) {
var hotPollInterval = +(__resourceQuery.substr(1)) || (10 * 60 * 1000);

function checkForUpdate(fromUpdate) {
var checkForUpdate = function checkForUpdate(fromUpdate) {
if(module.hot.status() === "idle") {
module.hot.check(true).then(function(updatedModules) {
if(!updatedModules) {
Expand Down
2 changes: 1 addition & 1 deletion hot/signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
/*globals __resourceQuery */
if(module.hot) {
function checkForUpdate(fromUpdate) {
var checkForUpdate = function checkForUpdate(fromUpdate) {
module.hot.check().then(function(updatedModules) {
if(!updatedModules) {
if(fromUpdate)
Expand Down
12 changes: 7 additions & 5 deletions lib/Compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -944,14 +944,16 @@ Compilation.prototype.modifyHash = function modifyHash(update) {
};

Compilation.prototype.createModuleAssets = function createModuleAssets() {
var cacheAssetsAndApplyPlugins = function cacheAssetsAndApplyPlugins(name) {
var file = this.getPath(name);
this.assets[file] = module.assets[name];
this.applyPlugins("module-asset", module, file);
}

for(var i = 0; i < this.modules.length; i++) {
var module = this.modules[i];
if(module.assets) {
Object.keys(module.assets).forEach(function(name) {
var file = this.getPath(name);
this.assets[file] = module.assets[name];
this.applyPlugins("module-asset", module, file);
}, this);
Object.keys(module.assets).forEach(cacheAssetsAndApplyPlugins, this);
}
}
};
Expand Down
Loading

0 comments on commit bd397af

Please sign in to comment.