Skip to content

Commit 9b272cf

Browse files
mastilverjantimon
authored andcommitted
make test passes for webpack@1 and webapck@2 (jantimon#642)
* test(ci): start testing using webpack@2 * test(examples): update examples output files * chore(travis): remove deprecaded node versions
1 parent 7a43f10 commit 9b272cf

File tree

39 files changed

+1127
-976
lines changed

39 files changed

+1127
-976
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
language: node_js
22
node_js:
3-
- "0.12"
4-
- "0.10"
53
- "4"
64
- "5"
75
- "6"
86
env:
9-
- WEBPACK=webpack@1
7+
- WEBPACK_VERSION=1
8+
- WEBPACK_VERSION=2
109
before_install:
1110
- stty columns 120
1211
install:
1312
- npm install --ignore-scripts
1413
- npm rm webpack
15-
- npm install $WEBPACK --ignore-scripts || true
14+
- npm rm extract-text-webpack-plugin
15+
- npm install webpack@$WEBPACK_VERSION extract-text-webpack-plugin@$WEBPACK_VERSION --ignore-scripts || true
1616
script:
1717
- npm test

examples/appcache/dist/webpack-1/bundle.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@
4242
/************************************************************************/
4343
/******/ ([
4444
/* 0 */
45-
/***/ function(module, exports, __webpack_require__) {
45+
/***/ (function(module, exports, __webpack_require__) {
4646

4747
__webpack_require__(1);
4848
var h1 = document.createElement('h1');
4949
h1.innerHTML = 'Hello world!';
5050
document.body.appendChild(h1);
5151

5252

53-
/***/ },
53+
/***/ }),
5454
/* 1 */
55-
/***/ function(module, exports) {
55+
/***/ (function(module, exports) {
5656

5757
// removed by extract-text-webpack-plugin
5858

59-
/***/ }
59+
/***/ })
6060
/******/ ]);

examples/appcache/dist/webpack-1/manifest.appcache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# 7f3ef819c597c3951a64
2+
# f688cbdde5a6e721015e
33

44
0714810ae3fb211173e2964249507195.png
55
bundle.js
Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,86 @@
11
/******/ (function(modules) { // webpackBootstrap
22
/******/ // The module cache
33
/******/ var installedModules = {};
4-
4+
/******/
55
/******/ // The require function
66
/******/ function __webpack_require__(moduleId) {
7-
7+
/******/
88
/******/ // Check if module is in cache
9-
/******/ if(installedModules[moduleId])
9+
/******/ if(installedModules[moduleId]) {
1010
/******/ return installedModules[moduleId].exports;
11-
11+
/******/ }
1212
/******/ // Create a new module (and put it into the cache)
1313
/******/ var module = installedModules[moduleId] = {
1414
/******/ i: moduleId,
1515
/******/ l: false,
1616
/******/ exports: {}
1717
/******/ };
18-
18+
/******/
1919
/******/ // Execute the module function
2020
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21-
21+
/******/
2222
/******/ // Flag the module as loaded
2323
/******/ module.l = true;
24-
24+
/******/
2525
/******/ // Return the exports of the module
2626
/******/ return module.exports;
2727
/******/ }
28-
29-
28+
/******/
29+
/******/
3030
/******/ // expose the modules object (__webpack_modules__)
3131
/******/ __webpack_require__.m = modules;
32-
32+
/******/
3333
/******/ // expose the module cache
3434
/******/ __webpack_require__.c = installedModules;
35-
36-
/******/ // identity function for calling harmory imports with the correct context
35+
/******/
36+
/******/ // identity function for calling harmony imports with the correct context
3737
/******/ __webpack_require__.i = function(value) { return value; };
38-
39-
/******/ // define getter function for harmory exports
38+
/******/
39+
/******/ // define getter function for harmony exports
4040
/******/ __webpack_require__.d = function(exports, name, getter) {
41-
/******/ Object.defineProperty(exports, name, {
42-
/******/ configurable: false,
43-
/******/ enumerable: true,
44-
/******/ get: getter
45-
/******/ });
41+
/******/ if(!__webpack_require__.o(exports, name)) {
42+
/******/ Object.defineProperty(exports, name, {
43+
/******/ configurable: false,
44+
/******/ enumerable: true,
45+
/******/ get: getter
46+
/******/ });
47+
/******/ }
4648
/******/ };
47-
49+
/******/
50+
/******/ // getDefaultExport function for compatibility with non-harmony modules
51+
/******/ __webpack_require__.n = function(module) {
52+
/******/ var getter = module && module.__esModule ?
53+
/******/ function getDefault() { return module['default']; } :
54+
/******/ function getModuleExports() { return module; };
55+
/******/ __webpack_require__.d(getter, 'a', getter);
56+
/******/ return getter;
57+
/******/ };
58+
/******/
4859
/******/ // Object.prototype.hasOwnProperty.call
4960
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
50-
61+
/******/
5162
/******/ // __webpack_public_path__
5263
/******/ __webpack_require__.p = "";
53-
64+
/******/
5465
/******/ // Load entry module and return exports
5566
/******/ return __webpack_require__(__webpack_require__.s = 1);
5667
/******/ })
5768
/************************************************************************/
5869
/******/ ([
5970
/* 0 */
60-
/***/ function(module, exports) {
71+
/***/ (function(module, exports) {
6172

6273
// removed by extract-text-webpack-plugin
6374

64-
/***/ },
75+
/***/ }),
6576
/* 1 */
66-
/***/ function(module, exports, __webpack_require__) {
77+
/***/ (function(module, exports, __webpack_require__) {
6778

6879
__webpack_require__(0);
6980
var h1 = document.createElement('h1');
7081
h1.innerHTML = 'Hello world!';
7182
document.body.appendChild(h1);
7283

7384

74-
/***/ }
85+
/***/ })
7586
/******/ ]);

examples/appcache/dist/webpack-2/manifest.appcache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# 6ee6c7ddf81fcd66e06a
2+
# 737de2033617f9f6144d
33

44
0714810ae3fb211173e2964249507195.png
55
bundle.js

examples/appcache/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var ExtractTextPlugin = require('extract-text-webpack-plugin');
55
var webpackMajorVersion = require('webpack/package.json').version.split('.')[0];
66

77
module.exports = {
8+
context: __dirname,
89
entry: './example.js',
910
output: {
1011
path: path.join(__dirname, 'dist/webpack-' + webpackMajorVersion),

examples/build-examples.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,19 @@ var webpackMajorVersion = require('webpack/package.json').version.split('.')[0];
88

99
var fs = require('fs');
1010
var path = require('path');
11-
var execSync = require('child_process').execSync;
1211
var rimraf = require('rimraf');
13-
var webpackBin = path.resolve(__dirname, '..', 'node_modules', '.bin', 'webpack');
12+
var webpack = require('webpack');
13+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
14+
15+
if (webpackMajorVersion === '2') {
16+
var extractOriginal = ExtractTextPlugin.extract;
17+
ExtractTextPlugin.extract = function (fallback, use) {
18+
return extractOriginal({
19+
fallback: fallback,
20+
use: use
21+
});
22+
};
23+
}
1424

1525
var examples = fs.readdirSync(__dirname).filter(function (file) {
1626
return fs.statSync(path.join(__dirname, file)).isDirectory();
@@ -19,6 +29,25 @@ var examples = fs.readdirSync(__dirname).filter(function (file) {
1929
examples.forEach(function (exampleName) {
2030
var examplePath = path.join(__dirname, exampleName);
2131
var configFile = path.join(examplePath, 'webpack.config.js');
32+
2233
rimraf.sync(path.join(examplePath, 'dist', 'webpack-' + webpackMajorVersion));
23-
execSync(webpackBin + ' --context "' + examplePath + '" --config "' + configFile + '"');
34+
webpack(require(configFile), function (err, stats) {
35+
if (err) {
36+
console.error(err.stack || err);
37+
if (err.details) {
38+
console.error(err.details);
39+
}
40+
return;
41+
}
42+
43+
const info = stats.toJson();
44+
45+
if (stats.hasErrors()) {
46+
console.error(info.errors);
47+
}
48+
49+
if (stats.hasWarnings()) {
50+
console.warn(info.warnings);
51+
}
52+
});
2453
});

examples/custom-template/dist/webpack-1/bundle.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@
4242
/************************************************************************/
4343
/******/ ([
4444
/* 0 */
45-
/***/ function(module, exports, __webpack_require__) {
45+
/***/ (function(module, exports, __webpack_require__) {
4646

4747
__webpack_require__(1);
4848
var h1 = document.createElement('h1');
4949
h1.innerHTML = 'Hello world!';
5050
document.body.appendChild(h1);
5151

5252

53-
/***/ },
53+
/***/ }),
5454
/* 1 */
55-
/***/ function(module, exports) {
55+
/***/ (function(module, exports) {
5656

5757
// removed by extract-text-webpack-plugin
5858

59-
/***/ }
59+
/***/ })
6060
/******/ ]);

examples/custom-template/dist/webpack-1/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
<h2>Partial</h2>
1010
<img src="0714810ae3fb211173e2964249507195.png">
1111
<script type="text/javascript" src="bundle.js"></script></body>
12-
</html>
12+
</html>
Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,86 @@
11
/******/ (function(modules) { // webpackBootstrap
22
/******/ // The module cache
33
/******/ var installedModules = {};
4-
4+
/******/
55
/******/ // The require function
66
/******/ function __webpack_require__(moduleId) {
7-
7+
/******/
88
/******/ // Check if module is in cache
9-
/******/ if(installedModules[moduleId])
9+
/******/ if(installedModules[moduleId]) {
1010
/******/ return installedModules[moduleId].exports;
11-
11+
/******/ }
1212
/******/ // Create a new module (and put it into the cache)
1313
/******/ var module = installedModules[moduleId] = {
1414
/******/ i: moduleId,
1515
/******/ l: false,
1616
/******/ exports: {}
1717
/******/ };
18-
18+
/******/
1919
/******/ // Execute the module function
2020
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21-
21+
/******/
2222
/******/ // Flag the module as loaded
2323
/******/ module.l = true;
24-
24+
/******/
2525
/******/ // Return the exports of the module
2626
/******/ return module.exports;
2727
/******/ }
28-
29-
28+
/******/
29+
/******/
3030
/******/ // expose the modules object (__webpack_modules__)
3131
/******/ __webpack_require__.m = modules;
32-
32+
/******/
3333
/******/ // expose the module cache
3434
/******/ __webpack_require__.c = installedModules;
35-
36-
/******/ // identity function for calling harmory imports with the correct context
35+
/******/
36+
/******/ // identity function for calling harmony imports with the correct context
3737
/******/ __webpack_require__.i = function(value) { return value; };
38-
39-
/******/ // define getter function for harmory exports
38+
/******/
39+
/******/ // define getter function for harmony exports
4040
/******/ __webpack_require__.d = function(exports, name, getter) {
41-
/******/ Object.defineProperty(exports, name, {
42-
/******/ configurable: false,
43-
/******/ enumerable: true,
44-
/******/ get: getter
45-
/******/ });
41+
/******/ if(!__webpack_require__.o(exports, name)) {
42+
/******/ Object.defineProperty(exports, name, {
43+
/******/ configurable: false,
44+
/******/ enumerable: true,
45+
/******/ get: getter
46+
/******/ });
47+
/******/ }
4648
/******/ };
47-
49+
/******/
50+
/******/ // getDefaultExport function for compatibility with non-harmony modules
51+
/******/ __webpack_require__.n = function(module) {
52+
/******/ var getter = module && module.__esModule ?
53+
/******/ function getDefault() { return module['default']; } :
54+
/******/ function getModuleExports() { return module; };
55+
/******/ __webpack_require__.d(getter, 'a', getter);
56+
/******/ return getter;
57+
/******/ };
58+
/******/
4859
/******/ // Object.prototype.hasOwnProperty.call
4960
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
50-
61+
/******/
5162
/******/ // __webpack_public_path__
5263
/******/ __webpack_require__.p = "";
53-
64+
/******/
5465
/******/ // Load entry module and return exports
5566
/******/ return __webpack_require__(__webpack_require__.s = 1);
5667
/******/ })
5768
/************************************************************************/
5869
/******/ ([
5970
/* 0 */
60-
/***/ function(module, exports) {
71+
/***/ (function(module, exports) {
6172

6273
// removed by extract-text-webpack-plugin
6374

64-
/***/ },
75+
/***/ }),
6576
/* 1 */
66-
/***/ function(module, exports, __webpack_require__) {
77+
/***/ (function(module, exports, __webpack_require__) {
6778

6879
__webpack_require__(0);
6980
var h1 = document.createElement('h1');
7081
h1.innerHTML = 'Hello world!';
7182
document.body.appendChild(h1);
7283

7384

74-
/***/ }
85+
/***/ })
7586
/******/ ]);

0 commit comments

Comments
 (0)