From 9b272cfb2bccee98bbe8438c817c4207a0a3cb71 Mon Sep 17 00:00:00 2001
From: Thomas Sileghem
Date: Wed, 10 May 2017 12:44:44 +0100
Subject: [PATCH] make test passes for webpack@1 and webapck@2 (#642)
* test(ci): start testing using webpack@2
* test(examples): update examples output files
* chore(travis): remove deprecaded node versions
---
.travis.yml | 8 +-
examples/appcache/dist/webpack-1/bundle.js | 8 +-
.../appcache/dist/webpack-1/manifest.appcache | 2 +-
examples/appcache/dist/webpack-2/bundle.js | 63 +-
.../appcache/dist/webpack-2/manifest.appcache | 2 +-
examples/appcache/webpack.config.js | 1 +
examples/build-examples.js | 35 +-
.../custom-template/dist/webpack-1/bundle.js | 8 +-
.../custom-template/dist/webpack-1/index.html | 2 +-
.../custom-template/dist/webpack-2/bundle.js | 63 +-
.../custom-template/dist/webpack-2/index.html | 2 +-
examples/custom-template/template.html | 4 +-
examples/custom-template/webpack.config.js | 1 +
examples/default/dist/webpack-1/bundle.js | 616 ++++++++--------
examples/default/dist/webpack-2/bundle.js | 671 +++++++++---------
examples/default/webpack.config.js | 1 +
examples/favicon/dist/webpack-1/bundle.js | 8 +-
examples/favicon/dist/webpack-2/bundle.js | 63 +-
examples/favicon/webpack.config.js | 1 +
examples/html-loader/dist/webpack-1/bundle.js | 8 +-
examples/html-loader/dist/webpack-2/bundle.js | 63 +-
examples/html-loader/webpack.config.js | 1 +
examples/inline/dist/webpack-1/bundle.js | 8 +-
examples/inline/dist/webpack-1/index.html | 8 +-
examples/inline/dist/webpack-2/bundle.js | 65 +-
examples/inline/dist/webpack-2/index.html | 65 +-
examples/inline/webpack.config.js | 3 +-
examples/jade-loader/dist/webpack-1/bundle.js | 24 +-
examples/jade-loader/dist/webpack-2/bundle.js | 83 ++-
examples/jade-loader/webpack.config.js | 1 +
.../dist/webpack-1/bundle.js | 12 +-
.../dist/webpack-2/bundle.js | 69 +-
.../javascript-advanced/webpack.config.js | 1 +
examples/javascript/dist/webpack-1/bundle.js | 12 +-
examples/javascript/dist/webpack-1/index.html | 2 +-
examples/javascript/dist/webpack-2/bundle.js | 69 +-
examples/javascript/dist/webpack-2/index.html | 2 +-
examples/javascript/webpack.config.js | 1 +
spec/BasicSpec.js | 23 +-
39 files changed, 1115 insertions(+), 964 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index b0019cd..c833e5e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,17 +1,17 @@
language: node_js
node_js:
- - "0.12"
- - "0.10"
- "4"
- "5"
- "6"
env:
- - WEBPACK=webpack@1
+ - WEBPACK_VERSION=1
+ - WEBPACK_VERSION=2
before_install:
- stty columns 120
install:
- npm install --ignore-scripts
- npm rm webpack
- - npm install $WEBPACK --ignore-scripts || true
+ - npm rm extract-text-webpack-plugin
+ - npm install webpack@$WEBPACK_VERSION extract-text-webpack-plugin@$WEBPACK_VERSION --ignore-scripts || true
script:
- npm test
diff --git a/examples/appcache/dist/webpack-1/bundle.js b/examples/appcache/dist/webpack-1/bundle.js
index 6e76564..6158f61 100644
--- a/examples/appcache/dist/webpack-1/bundle.js
+++ b/examples/appcache/dist/webpack-1/bundle.js
@@ -42,7 +42,7 @@
/************************************************************************/
/******/ ([
/* 0 */
-/***/ function(module, exports, __webpack_require__) {
+/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(1);
var h1 = document.createElement('h1');
@@ -50,11 +50,11 @@
document.body.appendChild(h1);
-/***/ },
+/***/ }),
/* 1 */
-/***/ function(module, exports) {
+/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
-/***/ }
+/***/ })
/******/ ]);
\ No newline at end of file
diff --git a/examples/appcache/dist/webpack-1/manifest.appcache b/examples/appcache/dist/webpack-1/manifest.appcache
index 4ef33e6..95445d5 100644
--- a/examples/appcache/dist/webpack-1/manifest.appcache
+++ b/examples/appcache/dist/webpack-1/manifest.appcache
@@ -1,5 +1,5 @@
CACHE MANIFEST
-# 7f3ef819c597c3951a64
+# f688cbdde5a6e721015e
0714810ae3fb211173e2964249507195.png
bundle.js
diff --git a/examples/appcache/dist/webpack-2/bundle.js b/examples/appcache/dist/webpack-2/bundle.js
index ad0b33d..0d7adbe 100644
--- a/examples/appcache/dist/webpack-2/bundle.js
+++ b/examples/appcache/dist/webpack-2/bundle.js
@@ -1,69 +1,80 @@
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
-
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
-
+/******/
/******/ // Check if module is in cache
-/******/ if(installedModules[moduleId])
+/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
-
+/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
-
+/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
-
+/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
-
+/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
-
-
+/******/
+/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
-
+/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
-
-/******/ // identity function for calling harmory imports with the correct context
+/******/
+/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
-
-/******/ // define getter function for harmory exports
+/******/
+/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
-/******/ Object.defineProperty(exports, name, {
-/******/ configurable: false,
-/******/ enumerable: true,
-/******/ get: getter
-/******/ });
+/******/ if(!__webpack_require__.o(exports, name)) {
+/******/ Object.defineProperty(exports, name, {
+/******/ configurable: false,
+/******/ enumerable: true,
+/******/ get: getter
+/******/ });
+/******/ }
/******/ };
-
+/******/
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = function(module) {
+/******/ var getter = module && module.__esModule ?
+/******/ function getDefault() { return module['default']; } :
+/******/ function getModuleExports() { return module; };
+/******/ __webpack_require__.d(getter, 'a', getter);
+/******/ return getter;
+/******/ };
+/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
-
+/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
-
+/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
-/***/ function(module, exports) {
+/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
-/***/ },
+/***/ }),
/* 1 */
-/***/ function(module, exports, __webpack_require__) {
+/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(0);
var h1 = document.createElement('h1');
@@ -71,5 +82,5 @@ h1.innerHTML = 'Hello world!';
document.body.appendChild(h1);
-/***/ }
+/***/ })
/******/ ]);
\ No newline at end of file
diff --git a/examples/appcache/dist/webpack-2/manifest.appcache b/examples/appcache/dist/webpack-2/manifest.appcache
index 74eed74..29e22b4 100644
--- a/examples/appcache/dist/webpack-2/manifest.appcache
+++ b/examples/appcache/dist/webpack-2/manifest.appcache
@@ -1,5 +1,5 @@
CACHE MANIFEST
-# 6ee6c7ddf81fcd66e06a
+# 737de2033617f9f6144d
0714810ae3fb211173e2964249507195.png
bundle.js
diff --git a/examples/appcache/webpack.config.js b/examples/appcache/webpack.config.js
index af2147c..1ff488e 100755
--- a/examples/appcache/webpack.config.js
+++ b/examples/appcache/webpack.config.js
@@ -5,6 +5,7 @@ var ExtractTextPlugin = require('extract-text-webpack-plugin');
var webpackMajorVersion = require('webpack/package.json').version.split('.')[0];
module.exports = {
+ context: __dirname,
entry: './example.js',
output: {
path: path.join(__dirname, 'dist/webpack-' + webpackMajorVersion),
diff --git a/examples/build-examples.js b/examples/build-examples.js
index d4573b3..15e1772 100644
--- a/examples/build-examples.js
+++ b/examples/build-examples.js
@@ -8,9 +8,19 @@ var webpackMajorVersion = require('webpack/package.json').version.split('.')[0];
var fs = require('fs');
var path = require('path');
-var execSync = require('child_process').execSync;
var rimraf = require('rimraf');
-var webpackBin = path.resolve(__dirname, '..', 'node_modules', '.bin', 'webpack');
+var webpack = require('webpack');
+var ExtractTextPlugin = require('extract-text-webpack-plugin');
+
+if (webpackMajorVersion === '2') {
+ var extractOriginal = ExtractTextPlugin.extract;
+ ExtractTextPlugin.extract = function (fallback, use) {
+ return extractOriginal({
+ fallback: fallback,
+ use: use
+ });
+ };
+}
var examples = fs.readdirSync(__dirname).filter(function (file) {
return fs.statSync(path.join(__dirname, file)).isDirectory();
@@ -19,6 +29,25 @@ var examples = fs.readdirSync(__dirname).filter(function (file) {
examples.forEach(function (exampleName) {
var examplePath = path.join(__dirname, exampleName);
var configFile = path.join(examplePath, 'webpack.config.js');
+
rimraf.sync(path.join(examplePath, 'dist', 'webpack-' + webpackMajorVersion));
- execSync(webpackBin + ' --context "' + examplePath + '" --config "' + configFile + '"');
+ webpack(require(configFile), function (err, stats) {
+ if (err) {
+ console.error(err.stack || err);
+ if (err.details) {
+ console.error(err.details);
+ }
+ return;
+ }
+
+ const info = stats.toJson();
+
+ if (stats.hasErrors()) {
+ console.error(info.errors);
+ }
+
+ if (stats.hasWarnings()) {
+ console.warn(info.warnings);
+ }
+ });
});
diff --git a/examples/custom-template/dist/webpack-1/bundle.js b/examples/custom-template/dist/webpack-1/bundle.js
index 6e76564..6158f61 100644
--- a/examples/custom-template/dist/webpack-1/bundle.js
+++ b/examples/custom-template/dist/webpack-1/bundle.js
@@ -42,7 +42,7 @@
/************************************************************************/
/******/ ([
/* 0 */
-/***/ function(module, exports, __webpack_require__) {
+/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(1);
var h1 = document.createElement('h1');
@@ -50,11 +50,11 @@
document.body.appendChild(h1);
-/***/ },
+/***/ }),
/* 1 */
-/***/ function(module, exports) {
+/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
-/***/ }
+/***/ })
/******/ ]);
\ No newline at end of file
diff --git a/examples/custom-template/dist/webpack-1/index.html b/examples/custom-template/dist/webpack-1/index.html
index 1ceade2..d68bf44 100644
--- a/examples/custom-template/dist/webpack-1/index.html
+++ b/examples/custom-template/dist/webpack-1/index.html
@@ -9,4 +9,4 @@
Partial