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

- \ No newline at end of file + diff --git a/examples/custom-template/dist/webpack-2/bundle.js b/examples/custom-template/dist/webpack-2/bundle.js index ad0b33d..0d7adbe 100644 --- a/examples/custom-template/dist/webpack-2/bundle.js +++ b/examples/custom-template/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/custom-template/dist/webpack-2/index.html b/examples/custom-template/dist/webpack-2/index.html index 1ceade2..d68bf44 100644 --- a/examples/custom-template/dist/webpack-2/index.html +++ b/examples/custom-template/dist/webpack-2/index.html @@ -9,4 +9,4 @@

Partial

- \ No newline at end of file + diff --git a/examples/custom-template/template.html b/examples/custom-template/template.html index 0e33b24..75e6ef4 100644 --- a/examples/custom-template/template.html +++ b/examples/custom-template/template.html @@ -6,6 +6,6 @@ - <%= require('html!./partial.html') %> + <%= require('html-loader!./partial.html') %> - \ No newline at end of file + diff --git a/examples/custom-template/webpack.config.js b/examples/custom-template/webpack.config.js index 4ab3e11..ddfc302 100755 --- a/examples/custom-template/webpack.config.js +++ b/examples/custom-template/webpack.config.js @@ -4,6 +4,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/default/dist/webpack-1/bundle.js b/examples/default/dist/webpack-1/bundle.js index bc576be..bf93906 100644 --- a/examples/default/dist/webpack-1/bundle.js +++ b/examples/default/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,9 +50,9 @@ document.body.appendChild(h1); -/***/ }, +/***/ }), /* 1 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { // style-loader: Adds some css to the DOM by adding a \ No newline at end of file diff --git a/examples/inline/webpack.config.js b/examples/inline/webpack.config.js index d479daf..15cabfd 100755 --- a/examples/inline/webpack.config.js +++ b/examples/inline/webpack.config.js @@ -4,6 +4,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), @@ -13,7 +14,7 @@ module.exports = { module: { loaders: [ { test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') }, - { test: /\.jade$/, loader: 'jade' } + { test: /\.jade$/, loader: 'jade-loader' } ] }, plugins: [ diff --git a/examples/jade-loader/dist/webpack-1/bundle.js b/examples/jade-loader/dist/webpack-1/bundle.js index b44cf0a..555e786 100644 --- a/examples/jade-loader/dist/webpack-1/bundle.js +++ b/examples/jade-loader/dist/webpack-1/bundle.js @@ -42,7 +42,7 @@ /************************************************************************/ /******/ ([ /* 0 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { 'use strict'; __webpack_require__(1); @@ -56,18 +56,18 @@ }, 1000); -/***/ }, +/***/ }), /* 1 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { // removed by extract-text-webpack-plugin -/***/ }, +/***/ }), /* 2 */, /* 3 */, /* 4 */, /* 5 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { var jade = __webpack_require__(6); @@ -79,9 +79,9 @@ buf.push("
Current time

" + (jade.escape((jade_interp = time.toISOString()) == null ? '' : jade_interp)) + "

");}.call(this,"time" in locals_for_with?locals_for_with.time:typeof time!=="undefined"?time:undefined));;return buf.join(""); } -/***/ }, +/***/ }), /* 6 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { 'use strict'; @@ -331,17 +331,17 @@ } -/***/ }, +/***/ }), /* 7 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { /* (ignored) */ -/***/ }, +/***/ }), /* 8 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__.p + "0714810ae3fb211173e2964249507195.png"; -/***/ } +/***/ }) /******/ ]); \ No newline at end of file diff --git a/examples/jade-loader/dist/webpack-2/bundle.js b/examples/jade-loader/dist/webpack-2/bundle.js index 4e44afa..aef75c6 100644 --- a/examples/jade-loader/dist/webpack-2/bundle.js +++ b/examples/jade-loader/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 = 2); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { // removed by extract-text-webpack-plugin -/***/ }, +/***/ }), /* 1 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { var jade = __webpack_require__(4); @@ -75,12 +86,12 @@ var jade_interp; buf.push("
Current time

" + (jade.escape((jade_interp = time.toISOString()) == null ? '' : jade_interp)) + "

");}.call(this,"time" in locals_for_with?locals_for_with.time:typeof time!=="undefined"?time:undefined));;return buf.join(""); } -/***/ }, +/***/ }), /* 2 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { "use strict"; -'use strict'; + __webpack_require__(0); // Use the same template for the frontend code var template = __webpack_require__(1); @@ -92,18 +103,18 @@ setInterval(function () { }, 1000); -/***/ }, +/***/ }), /* 3 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__.p + "0714810ae3fb211173e2964249507195.png"; -/***/ }, +/***/ }), /* 4 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { "use strict"; -'use strict'; + /** * Merge two attribute objects giving precedence @@ -351,11 +362,11 @@ exports.DebugItem = function DebugItem(lineno, filename) { } -/***/ }, +/***/ }), /* 5 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { /* (ignored) */ -/***/ } +/***/ }) /******/ ]); \ No newline at end of file diff --git a/examples/jade-loader/webpack.config.js b/examples/jade-loader/webpack.config.js index 2da72bc..26c0f66 100755 --- a/examples/jade-loader/webpack.config.js +++ b/examples/jade-loader/webpack.config.js @@ -3,6 +3,7 @@ var HtmlWebpackPlugin = require('../..'); 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/javascript-advanced/dist/webpack-1/bundle.js b/examples/javascript-advanced/dist/webpack-1/bundle.js index 8a83022..6680bd1 100644 --- a/examples/javascript-advanced/dist/webpack-1/bundle.js +++ b/examples/javascript-advanced/dist/webpack-1/bundle.js @@ -42,24 +42,24 @@ /************************************************************************/ /******/ ([ /* 0 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { eval("__webpack_require__(1);\n\nvar universal = __webpack_require__(5);\nvar h1 = document.createElement('h1');\nh1.innerHTML = universal();\n\ndocument.body.appendChild(h1);\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./example.js\n// module id = 0\n// module chunks = 0\n//# sourceURL=webpack:///./example.js?"); -/***/ }, +/***/ }), /* 1 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { eval("// removed by extract-text-webpack-plugin\n\n//////////////////\n// WEBPACK FOOTER\n// ./main.css\n// module id = 1\n// module chunks = 0\n//# sourceURL=webpack:///./main.css?"); -/***/ }, +/***/ }), /* 2 */, /* 3 */, /* 4 */, /* 5 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { eval("// This file is used for frontend and backend\n'use strict';\n\n// If compiled by the html-webpack-plugin\n// HTML_WEBPACK_PLUGIN is set to true:\nvar backend = typeof HTML_WEBPACK_PLUGIN !== 'undefined';\n\nmodule.exports = function () {\n return 'Hello World from ' + (backend ? 'backend' : 'frontend');\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./universial.js\n// module id = 5\n// module chunks = 0\n//# sourceURL=webpack:///./universial.js?"); -/***/ } +/***/ }) /******/ ]); \ No newline at end of file diff --git a/examples/javascript-advanced/dist/webpack-2/bundle.js b/examples/javascript-advanced/dist/webpack-2/bundle.js index 902bd24..e0b6b46 100644 --- a/examples/javascript-advanced/dist/webpack-2/bundle.js +++ b/examples/javascript-advanced/dist/webpack-2/bundle.js @@ -1,78 +1,89 @@ /******/ (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 = 2); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ -/***/ function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("// This file is used for frontend and backend\n'use strict';\n\n// If compiled by the html-webpack-plugin\n// HTML_WEBPACK_PLUGIN is set to true:\nvar backend = typeof HTML_WEBPACK_PLUGIN !== 'undefined';\n\nmodule.exports = function () {\n return 'Hello World from ' + (backend ? 'backend' : 'frontend');\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./universial.js\n// module id = 0\n// module chunks = 0\n\n//# sourceURL=webpack:///./universial.js?"); +eval("// This file is used for frontend and backend\n\n\n// If compiled by the html-webpack-plugin\n// HTML_WEBPACK_PLUGIN is set to true:\nvar backend = typeof HTML_WEBPACK_PLUGIN !== 'undefined';\n\nmodule.exports = function () {\n return 'Hello World from ' + (backend ? 'backend' : 'frontend');\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./universial.js\n// module id = 0\n// module chunks = 0\n\n//# sourceURL=webpack:///./universial.js?"); -/***/ }, +/***/ }), /* 1 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { eval("// removed by extract-text-webpack-plugin\n\n//////////////////\n// WEBPACK FOOTER\n// ./main.css\n// module id = 1\n// module chunks = 0\n\n//# sourceURL=webpack:///./main.css?"); -/***/ }, +/***/ }), /* 2 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { eval("__webpack_require__(1);\n\nvar universal = __webpack_require__(0);\nvar h1 = document.createElement('h1');\nh1.innerHTML = universal();\n\ndocument.body.appendChild(h1);\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./example.js\n// module id = 2\n// module chunks = 0\n\n//# sourceURL=webpack:///./example.js?"); -/***/ } +/***/ }) /******/ ]); \ No newline at end of file diff --git a/examples/javascript-advanced/webpack.config.js b/examples/javascript-advanced/webpack.config.js index 965697b..d1d3d63 100644 --- a/examples/javascript-advanced/webpack.config.js +++ b/examples/javascript-advanced/webpack.config.js @@ -3,6 +3,7 @@ var HtmlWebpackPlugin = require('../..'); 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/javascript/dist/webpack-1/bundle.js b/examples/javascript/dist/webpack-1/bundle.js index 8a83022..6680bd1 100644 --- a/examples/javascript/dist/webpack-1/bundle.js +++ b/examples/javascript/dist/webpack-1/bundle.js @@ -42,24 +42,24 @@ /************************************************************************/ /******/ ([ /* 0 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { eval("__webpack_require__(1);\n\nvar universal = __webpack_require__(5);\nvar h1 = document.createElement('h1');\nh1.innerHTML = universal();\n\ndocument.body.appendChild(h1);\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./example.js\n// module id = 0\n// module chunks = 0\n//# sourceURL=webpack:///./example.js?"); -/***/ }, +/***/ }), /* 1 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { eval("// removed by extract-text-webpack-plugin\n\n//////////////////\n// WEBPACK FOOTER\n// ./main.css\n// module id = 1\n// module chunks = 0\n//# sourceURL=webpack:///./main.css?"); -/***/ }, +/***/ }), /* 2 */, /* 3 */, /* 4 */, /* 5 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { eval("// This file is used for frontend and backend\n'use strict';\n\n// If compiled by the html-webpack-plugin\n// HTML_WEBPACK_PLUGIN is set to true:\nvar backend = typeof HTML_WEBPACK_PLUGIN !== 'undefined';\n\nmodule.exports = function () {\n return 'Hello World from ' + (backend ? 'backend' : 'frontend');\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./universial.js\n// module id = 5\n// module chunks = 0\n//# sourceURL=webpack:///./universial.js?"); -/***/ } +/***/ }) /******/ ]); \ No newline at end of file diff --git a/examples/javascript/dist/webpack-1/index.html b/examples/javascript/dist/webpack-1/index.html index 0ab3bbd..88e071b 100644 --- a/examples/javascript/dist/webpack-1/index.html +++ b/examples/javascript/dist/webpack-1/index.html @@ -1,2 +1,2 @@ -Hello World from backend2016-10-29T07:02:05.646Z

Partial

+Hello World from backend2017-04-17T17:13:11.491Z

Partial

\ No newline at end of file diff --git a/examples/javascript/dist/webpack-2/bundle.js b/examples/javascript/dist/webpack-2/bundle.js index 902bd24..e0b6b46 100644 --- a/examples/javascript/dist/webpack-2/bundle.js +++ b/examples/javascript/dist/webpack-2/bundle.js @@ -1,78 +1,89 @@ /******/ (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 = 2); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ -/***/ function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("// This file is used for frontend and backend\n'use strict';\n\n// If compiled by the html-webpack-plugin\n// HTML_WEBPACK_PLUGIN is set to true:\nvar backend = typeof HTML_WEBPACK_PLUGIN !== 'undefined';\n\nmodule.exports = function () {\n return 'Hello World from ' + (backend ? 'backend' : 'frontend');\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./universial.js\n// module id = 0\n// module chunks = 0\n\n//# sourceURL=webpack:///./universial.js?"); +eval("// This file is used for frontend and backend\n\n\n// If compiled by the html-webpack-plugin\n// HTML_WEBPACK_PLUGIN is set to true:\nvar backend = typeof HTML_WEBPACK_PLUGIN !== 'undefined';\n\nmodule.exports = function () {\n return 'Hello World from ' + (backend ? 'backend' : 'frontend');\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./universial.js\n// module id = 0\n// module chunks = 0\n\n//# sourceURL=webpack:///./universial.js?"); -/***/ }, +/***/ }), /* 1 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { eval("// removed by extract-text-webpack-plugin\n\n//////////////////\n// WEBPACK FOOTER\n// ./main.css\n// module id = 1\n// module chunks = 0\n\n//# sourceURL=webpack:///./main.css?"); -/***/ }, +/***/ }), /* 2 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { eval("__webpack_require__(1);\n\nvar universal = __webpack_require__(0);\nvar h1 = document.createElement('h1');\nh1.innerHTML = universal();\n\ndocument.body.appendChild(h1);\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./example.js\n// module id = 2\n// module chunks = 0\n\n//# sourceURL=webpack:///./example.js?"); -/***/ } +/***/ }) /******/ ]); \ No newline at end of file diff --git a/examples/javascript/dist/webpack-2/index.html b/examples/javascript/dist/webpack-2/index.html index 299dba1..71f92f6 100644 --- a/examples/javascript/dist/webpack-2/index.html +++ b/examples/javascript/dist/webpack-2/index.html @@ -1,2 +1,2 @@ -Hello World from backend2016-07-02T10:27:15.263Z

Partial

+Hello World from backend2017-04-17T17:12:14.752Z

Partial

\ No newline at end of file diff --git a/examples/javascript/webpack.config.js b/examples/javascript/webpack.config.js index 965697b..d1d3d63 100644 --- a/examples/javascript/webpack.config.js +++ b/examples/javascript/webpack.config.js @@ -3,6 +3,7 @@ var HtmlWebpackPlugin = require('../..'); 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/spec/BasicSpec.js b/spec/BasicSpec.js index 9e9be76..9294a64 100644 --- a/spec/BasicSpec.js +++ b/spec/BasicSpec.js @@ -17,8 +17,20 @@ var webpack = require('webpack'); var rimraf = require('rimraf'); var _ = require('lodash'); var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin'); +var ExtractTextPlugin = require('extract-text-webpack-plugin'); +var webpackMajorVersion = require('webpack/package.json').version.split('.')[0]; var HtmlWebpackPlugin = require('../index.js'); +if (webpackMajorVersion === '2') { + var extractOriginal = ExtractTextPlugin.extract; + ExtractTextPlugin.extract = function (fallback, use) { + return extractOriginal({ + fallback: fallback, + use: use + }); + }; +} + var OUTPUT_DIR = path.join(__dirname, '../dist'); jasmine.getEnv().defaultTimeoutInterval = 30000; @@ -405,7 +417,6 @@ describe('HtmlWebpackPlugin', function () { }); it('should work with the css extract plugin', function (done) { - var ExtractTextPlugin = require('extract-text-webpack-plugin'); testHtmlPlugin({ entry: path.join(__dirname, 'fixtures/theme.js'), output: { @@ -425,7 +436,6 @@ describe('HtmlWebpackPlugin', function () { }); it('should work with the css extract plugin on windows and protocol relative urls support (#205)', function (done) { - var ExtractTextPlugin = require('extract-text-webpack-plugin'); testHtmlPlugin({ entry: path.join(__dirname, 'fixtures/theme.js'), output: { @@ -446,7 +456,6 @@ describe('HtmlWebpackPlugin', function () { }); it('should allow to add cache hashes to with the css assets', function (done) { - var ExtractTextPlugin = require('extract-text-webpack-plugin'); testHtmlPlugin({ entry: path.join(__dirname, 'fixtures/theme.js'), output: { @@ -466,7 +475,6 @@ describe('HtmlWebpackPlugin', function () { }); it('should inject css files when using the extract text plugin', function (done) { - var ExtractTextPlugin = require('extract-text-webpack-plugin'); testHtmlPlugin({ entry: path.join(__dirname, 'fixtures/theme.js'), output: { @@ -486,7 +494,6 @@ describe('HtmlWebpackPlugin', function () { }); it('should allow to add cache hashes to with injected css assets', function (done) { - var ExtractTextPlugin = require('extract-text-webpack-plugin'); testHtmlPlugin({ entry: path.join(__dirname, 'fixtures/theme.js'), output: { @@ -506,7 +513,6 @@ describe('HtmlWebpackPlugin', function () { }); it('should output xhtml link stylesheet tag', function (done) { - var ExtractTextPlugin = require('extract-text-webpack-plugin'); testHtmlPlugin({ entry: path.join(__dirname, 'fixtures/theme.js'), output: { @@ -684,7 +690,6 @@ describe('HtmlWebpackPlugin', function () { }); it('should inject js css files even if the html file is incomplete', function (done) { - var ExtractTextPlugin = require('extract-text-webpack-plugin'); testHtmlPlugin({ entry: path.join(__dirname, 'fixtures/theme.js'), output: { @@ -1167,7 +1172,7 @@ describe('HtmlWebpackPlugin', function () { plugins: [ new HtmlWebpackPlugin({ inject: false, - template: 'jade!' + path.join(__dirname, 'fixtures/template.jade') + template: 'jade-loader!' + path.join(__dirname, 'fixtures/template.jade') }), examplePlugin ] @@ -1179,8 +1184,6 @@ describe('HtmlWebpackPlugin', function () { it('works with commons chunk plugin', function (done) { testHtmlPlugin({ - debug: true, - verbose: true, entry: { util: path.join(__dirname, 'fixtures/util.js'), index: path.join(__dirname, 'fixtures/index.js')