diff --git a/.travis.yml b/.travis.yml index cae6ac14..9dbf513b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ env: - WEBPACK_VERSION=1 EXTRACT_PLUGIN_VERSION=1 - WEBPACK_VERSION=2 EXTRACT_PLUGIN_VERSION=2 - WEBPACK_VERSION=3 EXTRACT_PLUGIN_VERSION=3.0.0-beta.3 + - WEBPACK_VERSION=4.0.0-beta.1 EXTRACT_PLUGIN_VERSION=4.0.0-alpha.0 before_install: - stty columns 120 install: @@ -14,5 +15,14 @@ install: - npm rm webpack - npm rm extract-text-webpack-plugin - npm install webpack@$WEBPACK_VERSION extract-text-webpack-plugin@$EXTRACT_PLUGIN_VERSION --ignore-scripts || true +matrix: + exclude: + - env: WEBPACK_VERSION=4.0.0-beta.1 EXTRACT_PLUGIN_VERSION=4.0.0-alpha.0 + node_js: "4" + - env: WEBPACK_VERSION=4.0.0-beta.1 EXTRACT_PLUGIN_VERSION=4.0.0-alpha.0 + node_js: "5" + include: + - env: WEBPACK_VERSION=4.0.0-beta.1 EXTRACT_PLUGIN_VERSION=4.0.0-alpha.0 + node_js: "8" script: - npm test diff --git a/examples/appcache/dist/webpack-4/0714810ae3fb211173e2964249507195.png b/examples/appcache/dist/webpack-4/0714810ae3fb211173e2964249507195.png new file mode 100644 index 00000000..d71b3d78 Binary files /dev/null and b/examples/appcache/dist/webpack-4/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/appcache/dist/webpack-4/bundle.js b/examples/appcache/dist/webpack-4/bundle.js new file mode 100644 index 00000000..53bdab35 --- /dev/null +++ b/examples/appcache/dist/webpack-4/bundle.js @@ -0,0 +1,92 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ 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; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // 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 = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(4); +var h1 = document.createElement('h1'); +h1.innerHTML = 'Hello world!'; +document.body.appendChild(h1); + + +/***/ }), +/* 1 */, +/* 2 */, +/* 3 */, +/* 4 */ +/***/ (function(module, exports) { + +// removed by extract-text-webpack-plugin + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/examples/appcache/dist/webpack-4/index.html b/examples/appcache/dist/webpack-4/index.html new file mode 100644 index 00000000..536e8a47 --- /dev/null +++ b/examples/appcache/dist/webpack-4/index.html @@ -0,0 +1 @@ +Example template \ No newline at end of file diff --git a/examples/appcache/dist/webpack-4/manifest.appcache b/examples/appcache/dist/webpack-4/manifest.appcache new file mode 100644 index 00000000..3345da36 --- /dev/null +++ b/examples/appcache/dist/webpack-4/manifest.appcache @@ -0,0 +1,9 @@ +CACHE MANIFEST +# 95a89258cd32fe3f01e3 + +0714810ae3fb211173e2964249507195.png +bundle.js +styles.css + +NETWORK: +* diff --git a/examples/appcache/dist/webpack-4/styles.css b/examples/appcache/dist/webpack-4/styles.css new file mode 100644 index 00000000..232a2cdb --- /dev/null +++ b/examples/appcache/dist/webpack-4/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/build-examples.js b/examples/build-examples.js index adf81ebe..f4f0f9cb 100644 --- a/examples/build-examples.js +++ b/examples/build-examples.js @@ -30,8 +30,23 @@ examples.forEach(function (exampleName) { var examplePath = path.join(__dirname, exampleName); var configFile = path.join(examplePath, 'webpack.config.js'); + var config = require(configFile); + if (webpackMajorVersion === '4') { + config.plugins.unshift(new webpack.LoaderOptionsPlugin({ + options: { + context: process.cwd() // or the same value as `context` + } + })); + config.mode = 'production'; + config.optimization = { minimizer: [] }; + if (config.module && config.module.loaders) { + config.module.rules = config.module.loaders; + delete config.module.loaders; + } + } + rimraf.sync(path.join(examplePath, 'dist', 'webpack-' + webpackMajorVersion)); - webpack(require(configFile), function (err, stats) { + webpack(config, function (err, stats) { if (err) { console.error(err.stack || err); if (err.details) { diff --git a/examples/custom-template/dist/webpack-4/0714810ae3fb211173e2964249507195.png b/examples/custom-template/dist/webpack-4/0714810ae3fb211173e2964249507195.png new file mode 100644 index 00000000..d71b3d78 Binary files /dev/null and b/examples/custom-template/dist/webpack-4/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/custom-template/dist/webpack-4/bundle.js b/examples/custom-template/dist/webpack-4/bundle.js new file mode 100644 index 00000000..53bdab35 --- /dev/null +++ b/examples/custom-template/dist/webpack-4/bundle.js @@ -0,0 +1,92 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ 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; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // 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 = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(4); +var h1 = document.createElement('h1'); +h1.innerHTML = 'Hello world!'; +document.body.appendChild(h1); + + +/***/ }), +/* 1 */, +/* 2 */, +/* 3 */, +/* 4 */ +/***/ (function(module, exports) { + +// removed by extract-text-webpack-plugin + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/examples/custom-template/dist/webpack-4/index.html b/examples/custom-template/dist/webpack-4/index.html new file mode 100644 index 00000000..d68bf441 --- /dev/null +++ b/examples/custom-template/dist/webpack-4/index.html @@ -0,0 +1,12 @@ + + + + + Webpack App + + + +

Partial

+ + + diff --git a/examples/custom-template/dist/webpack-4/styles.css b/examples/custom-template/dist/webpack-4/styles.css new file mode 100644 index 00000000..232a2cdb --- /dev/null +++ b/examples/custom-template/dist/webpack-4/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/default/dist/webpack-4/bundle.js b/examples/default/dist/webpack-4/bundle.js new file mode 100644 index 00000000..93e99b50 --- /dev/null +++ b/examples/default/dist/webpack-4/bundle.js @@ -0,0 +1,420 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ 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; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // 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 = 4); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +var stylesInDom = {}, + memoize = function(fn) { + var memo; + return function () { + if (typeof memo === "undefined") memo = fn.apply(this, arguments); + return memo; + }; + }, + isOldIE = memoize(function() { + return /msie [6-9]\b/.test(self.navigator.userAgent.toLowerCase()); + }), + getHeadElement = memoize(function () { + return document.head || document.getElementsByTagName("head")[0]; + }), + singletonElement = null, + singletonCounter = 0, + styleElementsInsertedAtTop = []; + +module.exports = function(list, options) { + if(typeof DEBUG !== "undefined" && DEBUG) { + if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment"); + } + + options = options || {}; + // Force single-tag solution on IE6-9, which has a hard limit on the # of \ No newline at end of file diff --git a/examples/inline/dist/webpack-4/styles.css b/examples/inline/dist/webpack-4/styles.css new file mode 100644 index 00000000..232a2cdb --- /dev/null +++ b/examples/inline/dist/webpack-4/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/jade-loader/dist/webpack-4/0714810ae3fb211173e2964249507195.png b/examples/jade-loader/dist/webpack-4/0714810ae3fb211173e2964249507195.png new file mode 100644 index 00000000..d71b3d78 Binary files /dev/null and b/examples/jade-loader/dist/webpack-4/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/jade-loader/dist/webpack-4/bundle.js b/examples/jade-loader/dist/webpack-4/bundle.js new file mode 100644 index 00000000..17d9d37a --- /dev/null +++ b/examples/jade-loader/dist/webpack-4/bundle.js @@ -0,0 +1,378 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ 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; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // 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 = 4); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__.p + "0714810ae3fb211173e2964249507195.png"; + +/***/ }), +/* 1 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/** + * Merge two attribute objects giving precedence + * to values in object `b`. Classes are special-cased + * allowing for arrays and merging/joining appropriately + * resulting in a string. + * + * @param {Object} a + * @param {Object} b + * @return {Object} a + * @api private + */ + +exports.merge = function merge(a, b) { + if (arguments.length === 1) { + var attrs = a[0]; + for (var i = 1; i < a.length; i++) { + attrs = merge(attrs, a[i]); + } + return attrs; + } + var ac = a['class']; + var bc = b['class']; + + if (ac || bc) { + ac = ac || []; + bc = bc || []; + if (!Array.isArray(ac)) ac = [ac]; + if (!Array.isArray(bc)) bc = [bc]; + a['class'] = ac.concat(bc).filter(nulls); + } + + for (var key in b) { + if (key != 'class') { + a[key] = b[key]; + } + } + + return a; +}; + +/** + * Filter null `val`s. + * + * @param {*} val + * @return {Boolean} + * @api private + */ + +function nulls(val) { + return val != null && val !== ''; +} + +/** + * join array as classes. + * + * @param {*} val + * @return {String} + */ +exports.joinClasses = joinClasses; +function joinClasses(val) { + return (Array.isArray(val) ? val.map(joinClasses) : + (val && typeof val === 'object') ? Object.keys(val).filter(function (key) { return val[key]; }) : + [val]).filter(nulls).join(' '); +} + +/** + * Render the given classes. + * + * @param {Array} classes + * @param {Array.} escaped + * @return {String} + */ +exports.cls = function cls(classes, escaped) { + var buf = []; + for (var i = 0; i < classes.length; i++) { + if (escaped && escaped[i]) { + buf.push(exports.escape(joinClasses([classes[i]]))); + } else { + buf.push(joinClasses(classes[i])); + } + } + var text = joinClasses(buf); + if (text.length) { + return ' class="' + text + '"'; + } else { + return ''; + } +}; + + +exports.style = function (val) { + if (val && typeof val === 'object') { + return Object.keys(val).map(function (style) { + return style + ':' + val[style]; + }).join(';'); + } else { + return val; + } +}; +/** + * Render the given attribute. + * + * @param {String} key + * @param {String} val + * @param {Boolean} escaped + * @param {Boolean} terse + * @return {String} + */ +exports.attr = function attr(key, val, escaped, terse) { + if (key === 'style') { + val = exports.style(val); + } + if ('boolean' == typeof val || null == val) { + if (val) { + return ' ' + (terse ? key : key + '="' + key + '"'); + } else { + return ''; + } + } else if (0 == key.indexOf('data') && 'string' != typeof val) { + if (JSON.stringify(val).indexOf('&') !== -1) { + console.warn('Since Jade 2.0.0, ampersands (`&`) in data attributes ' + + 'will be escaped to `&`'); + }; + if (val && typeof val.toISOString === 'function') { + console.warn('Jade will eliminate the double quotes around dates in ' + + 'ISO form after 2.0.0'); + } + return ' ' + key + "='" + JSON.stringify(val).replace(/'/g, ''') + "'"; + } else if (escaped) { + if (val && typeof val.toISOString === 'function') { + console.warn('Jade will stringify dates in ISO form after 2.0.0'); + } + return ' ' + key + '="' + exports.escape(val) + '"'; + } else { + if (val && typeof val.toISOString === 'function') { + console.warn('Jade will stringify dates in ISO form after 2.0.0'); + } + return ' ' + key + '="' + val + '"'; + } +}; + +/** + * Render the given attributes object. + * + * @param {Object} obj + * @param {Object} escaped + * @return {String} + */ +exports.attrs = function attrs(obj, terse){ + var buf = []; + + var keys = Object.keys(obj); + + if (keys.length) { + for (var i = 0; i < keys.length; ++i) { + var key = keys[i] + , val = obj[key]; + + if ('class' == key) { + if (val = joinClasses(val)) { + buf.push(' ' + key + '="' + val + '"'); + } + } else { + buf.push(exports.attr(key, val, false, terse)); + } + } + } + + return buf.join(''); +}; + +/** + * Escape the given string of `html`. + * + * @param {String} html + * @return {String} + * @api private + */ + +var jade_encode_html_rules = { + '&': '&', + '<': '<', + '>': '>', + '"': '"' +}; +var jade_match_html = /[&<>"]/g; + +function jade_encode_char(c) { + return jade_encode_html_rules[c] || c; +} + +exports.escape = jade_escape; +function jade_escape(html){ + var result = String(html).replace(jade_match_html, jade_encode_char); + if (result === '' + html) return html; + else return result; +}; + +/** + * Re-throw the given `err` in context to the + * the jade in `filename` at the given `lineno`. + * + * @param {Error} err + * @param {String} filename + * @param {String} lineno + * @api private + */ + +exports.rethrow = function rethrow(err, filename, lineno, str){ + if (!(err instanceof Error)) throw err; + if ((typeof window != 'undefined' || !filename) && !str) { + err.message += ' on line ' + lineno; + throw err; + } + try { + str = str || __webpack_require__(1).readFileSync(filename, 'utf8') + } catch (ex) { + rethrow(err, null, lineno) + } + var context = 3 + , lines = str.split('\n') + , start = Math.max(lineno - context, 0) + , end = Math.min(lines.length, lineno + context); + + // Error context + var context = lines.slice(start, end).map(function(line, i){ + var curr = i + start + 1; + return (curr == lineno ? ' > ' : ' ') + + curr + + '| ' + + line; + }).join('\n'); + + // Alter exception message + err.path = filename; + err.message = (filename || 'Jade') + ':' + lineno + + '\n' + context + '\n\n' + err.message; + throw err; +}; + +exports.DebugItem = function DebugItem(lineno, filename) { + this.lineno = lineno; + this.filename = filename; +} + + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +var jade = __webpack_require__(2); + +module.exports = function template(locals) { +var buf = []; +var jade_mixins = {}; +var jade_interp; +;var locals_for_with = (locals || {});(function (time) { +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(""); +} + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +__webpack_require__(8); +// Use the same template for the frontend code +var template = __webpack_require__(3); + +setInterval(function () { + var div = document.getElementById('main'); + div.innerHTML = template({ time: new Date() }); + div.style.color = 'navy'; +}, 1000); + + +/***/ }), +/* 5 */, +/* 6 */, +/* 7 */, +/* 8 */ +/***/ (function(module, exports) { + +// removed by extract-text-webpack-plugin + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/examples/jade-loader/dist/webpack-4/favicon.ico b/examples/jade-loader/dist/webpack-4/favicon.ico new file mode 100644 index 00000000..be74abd6 Binary files /dev/null and b/examples/jade-loader/dist/webpack-4/favicon.ico differ diff --git a/examples/jade-loader/dist/webpack-4/index.html b/examples/jade-loader/dist/webpack-4/index.html new file mode 100644 index 00000000..51385f90 --- /dev/null +++ b/examples/jade-loader/dist/webpack-4/index.html @@ -0,0 +1 @@ +Jade demo
Current time

1999-01-01T05:00:00.000Z

\ No newline at end of file diff --git a/examples/jade-loader/dist/webpack-4/styles.css b/examples/jade-loader/dist/webpack-4/styles.css new file mode 100644 index 00000000..232a2cdb --- /dev/null +++ b/examples/jade-loader/dist/webpack-4/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/javascript-advanced/dist/webpack-4/0714810ae3fb211173e2964249507195.png b/examples/javascript-advanced/dist/webpack-4/0714810ae3fb211173e2964249507195.png new file mode 100644 index 00000000..d71b3d78 Binary files /dev/null and b/examples/javascript-advanced/dist/webpack-4/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/javascript-advanced/dist/webpack-4/bundle.js b/examples/javascript-advanced/dist/webpack-4/bundle.js new file mode 100644 index 00000000..d095771c --- /dev/null +++ b/examples/javascript-advanced/dist/webpack-4/bundle.js @@ -0,0 +1,95 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ 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; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // 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, __webpack_require__) { + +"use strict"; +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//# sourceURL=webpack:///./universial.js?"); + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +eval("__webpack_require__(5);\n\nvar universal = __webpack_require__(0);\nvar h1 = document.createElement('h1');\nh1.innerHTML = universal();\n\ndocument.body.appendChild(h1);\n\n\n//# sourceURL=webpack:///./example.js?"); + +/***/ }), +/* 2 */, +/* 3 */, +/* 4 */, +/* 5 */ +/***/ (function(module, exports) { + +eval("// removed by extract-text-webpack-plugin\n\n//# sourceURL=webpack:///./main.css?"); + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/examples/javascript-advanced/dist/webpack-4/index.html b/examples/javascript-advanced/dist/webpack-4/index.html new file mode 100644 index 00000000..61d6408d --- /dev/null +++ b/examples/javascript-advanced/dist/webpack-4/index.html @@ -0,0 +1,2 @@ +Webpack AppHello World from backend -

Partial

+ \ No newline at end of file diff --git a/examples/javascript-advanced/dist/webpack-4/styles.css b/examples/javascript-advanced/dist/webpack-4/styles.css new file mode 100644 index 00000000..232a2cdb --- /dev/null +++ b/examples/javascript-advanced/dist/webpack-4/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/javascript/dist/webpack-4/0714810ae3fb211173e2964249507195.png b/examples/javascript/dist/webpack-4/0714810ae3fb211173e2964249507195.png new file mode 100644 index 00000000..d71b3d78 Binary files /dev/null and b/examples/javascript/dist/webpack-4/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/javascript/dist/webpack-4/bundle.js b/examples/javascript/dist/webpack-4/bundle.js new file mode 100644 index 00000000..d095771c --- /dev/null +++ b/examples/javascript/dist/webpack-4/bundle.js @@ -0,0 +1,95 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ 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; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // 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, __webpack_require__) { + +"use strict"; +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//# sourceURL=webpack:///./universial.js?"); + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +eval("__webpack_require__(5);\n\nvar universal = __webpack_require__(0);\nvar h1 = document.createElement('h1');\nh1.innerHTML = universal();\n\ndocument.body.appendChild(h1);\n\n\n//# sourceURL=webpack:///./example.js?"); + +/***/ }), +/* 2 */, +/* 3 */, +/* 4 */, +/* 5 */ +/***/ (function(module, exports) { + +eval("// removed by extract-text-webpack-plugin\n\n//# sourceURL=webpack:///./main.css?"); + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/examples/javascript/dist/webpack-4/index.html b/examples/javascript/dist/webpack-4/index.html new file mode 100644 index 00000000..b0bcd096 --- /dev/null +++ b/examples/javascript/dist/webpack-4/index.html @@ -0,0 +1,2 @@ +Hello World from backend2018-02-14T04:00:28.077Z

Partial

+ \ No newline at end of file diff --git a/examples/javascript/dist/webpack-4/styles.css b/examples/javascript/dist/webpack-4/styles.css new file mode 100644 index 00000000..232a2cdb --- /dev/null +++ b/examples/javascript/dist/webpack-4/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-4/0714810ae3fb211173e2964249507195.png b/examples/sort-manually/dist/webpack-4/0714810ae3fb211173e2964249507195.png new file mode 100644 index 00000000..d71b3d78 Binary files /dev/null and b/examples/sort-manually/dist/webpack-4/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/sort-manually/dist/webpack-4/a.js b/examples/sort-manually/dist/webpack-4/a.js new file mode 100644 index 00000000..e6b4de3b --- /dev/null +++ b/examples/sort-manually/dist/webpack-4/a.js @@ -0,0 +1,92 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ 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; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // 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); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ 2: +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(8); +var h1 = document.createElement('h1'); +h1.innerHTML = 'a!'; +document.body.appendChild(h1); + + +/***/ }), + +/***/ 8: +/***/ (function(module, exports) { + +// removed by extract-text-webpack-plugin + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-4/b.js b/examples/sort-manually/dist/webpack-4/b.js new file mode 100644 index 00000000..7dbca5d4 --- /dev/null +++ b/examples/sort-manually/dist/webpack-4/b.js @@ -0,0 +1,84 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ 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; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // 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 = 4); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ 4: +/***/ (function(module, exports) { + +var h1 = document.createElement('h1'); +h1.innerHTML = 'b!'; +document.body.appendChild(h1); + + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-4/c.js b/examples/sort-manually/dist/webpack-4/c.js new file mode 100644 index 00000000..0398b415 --- /dev/null +++ b/examples/sort-manually/dist/webpack-4/c.js @@ -0,0 +1,83 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ 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; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // 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 */, +/* 1 */ +/***/ (function(module, exports) { + +var h1 = document.createElement('h1'); +h1.innerHTML = 'c!'; +document.body.appendChild(h1); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-4/d.js b/examples/sort-manually/dist/webpack-4/d.js new file mode 100644 index 00000000..57ea10fb --- /dev/null +++ b/examples/sort-manually/dist/webpack-4/d.js @@ -0,0 +1,84 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ 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; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // 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 = 3); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ 3: +/***/ (function(module, exports) { + +var h1 = document.createElement('h1'); +h1.innerHTML = 'd!'; +document.body.appendChild(h1); + + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-4/e.js b/examples/sort-manually/dist/webpack-4/e.js new file mode 100644 index 00000000..4b3a5a83 --- /dev/null +++ b/examples/sort-manually/dist/webpack-4/e.js @@ -0,0 +1,82 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ 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; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // 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 = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +var h1 = document.createElement('h1'); +h1.innerHTML = 'e!'; +document.body.appendChild(h1); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-4/first-file.html b/examples/sort-manually/dist/webpack-4/first-file.html new file mode 100644 index 00000000..afacda4b --- /dev/null +++ b/examples/sort-manually/dist/webpack-4/first-file.html @@ -0,0 +1,11 @@ + + + + + Example template + + + + + + \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-4/second-file.html b/examples/sort-manually/dist/webpack-4/second-file.html new file mode 100644 index 00000000..d6d80d35 --- /dev/null +++ b/examples/sort-manually/dist/webpack-4/second-file.html @@ -0,0 +1,11 @@ + + + + + Example template + + + + + + \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-4/styles.css b/examples/sort-manually/dist/webpack-4/styles.css new file mode 100644 index 00000000..232a2cdb --- /dev/null +++ b/examples/sort-manually/dist/webpack-4/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/index.js b/index.js index f98abce2..141d3a0d 100644 --- a/index.js +++ b/index.js @@ -42,6 +42,20 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) { this.options.filename = path.relative(compiler.options.output.path, filename); } + // setup hooks for webpack 4 + if (compiler.hooks) { + compiler.hooks.compilation.tap('HtmlWebpackPluginHooks', function (compilation) { + var SyncWaterfallHook = require('tapable').SyncWaterfallHook; + var AsyncSeriesWaterfallHook = require('tapable').AsyncSeriesWaterfallHook; + compilation.hooks.htmlWebpackPluginAlterChunks = new SyncWaterfallHook(['chunks', 'objectWithPluginRef']); + compilation.hooks.htmlWebpackPluginBeforeHtmlGeneration = new AsyncSeriesWaterfallHook(['pluginArgs']); + compilation.hooks.htmlWebpackPluginBeforeHtmlProcessing = new AsyncSeriesWaterfallHook(['pluginArgs']); + compilation.hooks.htmlWebpackPluginAlterAssetTags = new AsyncSeriesWaterfallHook(['pluginArgs']); + compilation.hooks.htmlWebpackPluginAfterHtmlProcessing = new AsyncSeriesWaterfallHook(['pluginArgs']); + compilation.hooks.htmlWebpackPluginAfterEmit = new AsyncSeriesWaterfallHook(['pluginArgs']); + }); + } + compiler.plugin('make', function (compilation, callback) { // Compile the template (queued) compilationPromise = childCompiler.compileTemplate(self.options.template, compiler.context, self.options.filename, compilation) @@ -69,9 +83,14 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) { // Filter chunks (options.chunks and options.excludeCHunks) var chunks = self.filterChunks(allChunks, self.options.chunks, self.options.excludeChunks); // Sort chunks - chunks = self.sortChunks(chunks, self.options.chunksSortMode); + chunks = self.sortChunks(chunks, self.options.chunksSortMode, compilation.chunkGroups); // Let plugins alter the chunks and the chunk sorting - chunks = compilation.applyPluginsWaterfall('html-webpack-plugin-alter-chunks', chunks, { plugin: self }); + if (compilation.hooks) { + chunks = compilation.hooks.htmlWebpackPluginAlterChunks.call(chunks, { plugin: self }); + } else { + // Before Webpack 4 + chunks = compilation.applyPluginsWaterfall('html-webpack-plugin-alter-chunks', chunks, { plugin: self }); + } // Get assets var assets = self.htmlWebpackPluginAssets(compilation, chunks); // If this is a hot update compilation, move on! @@ -313,7 +332,12 @@ HtmlWebpackPlugin.prototype.addFileToAssets = function (filename, compilation) { }) .then(function (results) { var basename = path.basename(filename); - compilation.fileDependencies.push(filename); + if (compilation.fileDependencies.add) { + compilation.fileDependencies.add(filename); + } else { + // Before Webpack 4 - fileDepenencies was an array + compilation.fileDependencies.push(filename); + } compilation.assets[basename] = { source: function () { return results.source; @@ -329,7 +353,7 @@ HtmlWebpackPlugin.prototype.addFileToAssets = function (filename, compilation) { /** * Helper to sort chunks */ -HtmlWebpackPlugin.prototype.sortChunks = function (chunks, sortMode) { +HtmlWebpackPlugin.prototype.sortChunks = function (chunks, sortMode, chunkGroups) { // Sort mode auto by default: if (typeof sortMode === 'undefined') { sortMode = 'auto'; @@ -342,9 +366,12 @@ HtmlWebpackPlugin.prototype.sortChunks = function (chunks, sortMode) { if (sortMode === 'none') { return chunkSorter.none(chunks); } + if (sortMode === 'manual') { + return chunkSorter.manual(chunks, this.options.chunks); + } // Check if the given sort mode is a valid chunkSorter sort mode if (typeof chunkSorter[sortMode] !== 'undefined') { - return chunkSorter[sortMode](chunks, this.options.chunks); + return chunkSorter[sortMode](chunks, chunkGroups); } throw new Error('"' + sortMode + '" is not a valid chunk sort mode'); }; @@ -640,16 +667,48 @@ HtmlWebpackPlugin.prototype.getAssetFiles = function (assets) { * a function that helps to merge given plugin arguments with processed ones */ HtmlWebpackPlugin.prototype.applyPluginsAsyncWaterfall = function (compilation) { - var promisedApplyPluginsAsyncWaterfall = Promise.promisify(compilation.applyPluginsAsyncWaterfall, {context: compilation}); - return function (eventName, requiresResult, pluginArgs) { - return promisedApplyPluginsAsyncWaterfall(eventName, pluginArgs) - .then(function (result) { - if (requiresResult && !result) { - compilation.warnings.push(new Error('Using ' + eventName + ' without returning a result is deprecated.')); - } - return _.extend(pluginArgs, result); - }); - }; + if (compilation.hooks) { + return function (eventName, requiresResult, pluginArgs) { + var ccEventName = trainCaseToCamelCase(eventName); + if (!compilation.hooks[ccEventName]) { + compilation.errors.push( + new Error('No hook found for ' + eventName) + ); + } + + return compilation.hooks[ccEventName].promise(pluginArgs); + }; + } else { + // Before Webpack 4 + var promisedApplyPluginsAsyncWaterfall = Promise.promisify( + compilation.applyPluginsAsyncWaterfall, + { context: compilation } + ); + return function (eventName, requiresResult, pluginArgs) { + return promisedApplyPluginsAsyncWaterfall(eventName, pluginArgs) + .then(function (result) { + if (requiresResult && !result) { + compilation.warnings.push( + new Error('Using ' + eventName + ' without returning a result is deprecated.') + ); + } + return _.extend(pluginArgs, result); + }); + }; + } }; +/** + * Takes a string in train case and transforms it to camel case + * + * Example: 'hello-my-world' to 'helloMyWorld' + * + * @param {string} word + */ +function trainCaseToCamelCase (word) { + return word.replace(/-([\w])/g, function (match, p1) { + return p1.toUpperCase(); + }); +} + module.exports = HtmlWebpackPlugin; diff --git a/lib/chunksorter.js b/lib/chunksorter.js index 75f1a11a..da2b9b36 100644 --- a/lib/chunksorter.js +++ b/lib/chunksorter.js @@ -3,7 +3,7 @@ var toposort = require('toposort'); var _ = require('lodash'); -/* +/** Sorts dependencies between chunks by their "parents" attribute. This function sorts chunks based on their dependencies with each other. @@ -16,13 +16,17 @@ var _ = require('lodash'); highest level chunks that use the lower-level chunks. @param {Array} chunks an array of chunks as generated by the html-webpack-plugin. - It is assumed that each entry contains at least the properties "id" - (containing the chunk id) and "parents" (array containing the ids of the + - For webpack < 4, It is assumed that each entry contains at least the properties + "id" (containing the chunk id) and "parents" (array containing the ids of the parent chunks). + - For webpack 4+ the see the chunkGroups param for parent-child relationships + + @param {Array} chunks an array of ChunkGroups that has a getParents method. + Each ChunkGroup contains a list of chunks in order. @return {Array} A topologically sorted version of the input chunks */ -module.exports.dependency = function (chunks) { +module.exports.dependency = function (chunks, chunkGroups) { if (!chunks) { return chunks; } @@ -37,22 +41,52 @@ module.exports.dependency = function (chunks) { // Next, we add an edge for each parent relationship into the graph var edges = []; - chunks.forEach(function (chunk) { - if (chunk.parents) { - // Add an edge for each parent (parent -> child) - chunk.parents.forEach(function (parentId) { - // webpack2 chunk.parents are chunks instead of string id(s) - var parentChunk = _.isObject(parentId) ? parentId : nodeMap[parentId]; - // If the parent chunk does not exist (e.g. because of an excluded chunk) - // we ignore that parent - if (parentChunk) { - edges.push([parentChunk, chunk]); - } + if (chunkGroups) { + // Add an edge for each parent (parent -> child) + edges = chunkGroups.reduce(function (result, chunkGroup) { + return result.concat( + Array.from(chunkGroup.parentsIterable, function (parentGroup) { + return [parentGroup, chunkGroup]; + }) + ); + }, []); + var sortedGroups = toposort.array(chunkGroups, edges); + // flatten chunkGroup into chunks + var sortedChunks = sortedGroups + .reduce(function (result, chunkGroup) { + return result.concat(chunkGroup.chunks); + }, []) + .map(function (chunk) { + // use the chunk from the list passed in, since it may be a filtered list + return nodeMap[chunk.id]; + }) + .filter(function (chunk, index, self) { + // make sure exists (ie excluded chunks not in nodeMap) + var exists = !!chunk; + // make sure we have a unique list + var unique = self.indexOf(chunk) === index; + return exists && unique; }); - } - }); - // We now perform a topological sorting on the input chunks and built edges - return toposort.array(chunks, edges); + return sortedChunks; + } else { + // before webpack 4 there was no chunkGroups + chunks.forEach(function (chunk) { + if (chunk.parents) { + // Add an edge for each parent (parent -> child) + chunk.parents.forEach(function (parentId) { + // webpack2 chunk.parents are chunks instead of string id(s) + var parentChunk = _.isObject(parentId) ? parentId : nodeMap[parentId]; + // If the parent chunk does not exist (e.g. because of an excluded chunk) + // we ignore that parent + if (parentChunk) { + edges.push([parentChunk, chunk]); + } + }); + } + }); + // We now perform a topological sorting on the input chunks and built edges + return toposort.array(chunks, edges); + } }; /** diff --git a/lib/compiler.js b/lib/compiler.js index 9c8a2243..747ef31f 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -78,10 +78,20 @@ module.exports.compileTemplate = function compileTemplate (template, context, ou reject(err); } else { // Replace [hash] placeholders in filename - var outputName = compilation.mainTemplate.applyPluginsWaterfall('asset-path', outputOptions.filename, { - hash: childCompilation.hash, - chunk: entries[0] - }); + // In webpack 4 the plugin interface changed, so check for available fns + var outputName = compilation.mainTemplate.getAssetPath + ? compilation.mainTemplate.hooks.assetPath.call(outputOptions.filename, { + hash: childCompilation.hash, + chunk: entries[0] + }) + : compilation.mainTemplate.applyPluginsWaterfall( + 'asset-path', + outputOptions.filename, + { + hash: childCompilation.hash, + chunk: entries[0] + }); + // Restore the parent compilation to the state like it // was before the child compilation compilation.assets[outputName] = assetsBeforeCompilation[outputName]; diff --git a/package.json b/package.json index 81b45289..fabbe4a1 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "jade": "^1.11.0", "jade-loader": "^0.8.0", "jasmine": "^2.5.2", + "jasmine-diff-matchers": "^2.0.0", "rimraf": "^2.5.4", "semistandard": "8.0.0", "style-loader": "^0.13.1", @@ -63,6 +64,7 @@ "toposort": "^1.0.0" }, "peerDependencies": { - "webpack": "1 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3" + "extract-text-webpack-plugin": "1 || 2 || 3.0.0-beta.3 || ^4.0.0-alpha.0", + "webpack": "1 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3 || ^4.0.0-beta.1" } } diff --git a/spec/BasicSpec.js b/spec/BasicSpec.js index 00291b8f..b70f2ea3 100644 --- a/spec/BasicSpec.js +++ b/spec/BasicSpec.js @@ -16,9 +16,15 @@ var fs = require('fs'); 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 extractTextPluginMajorVersion = require('extract-text-webpack-plugin/package.json').version.split('.')[0]; +var webpackMajorVersion = Number(require('webpack/package.json').version.split('.')[0]); +if (isNaN(webpackMajorVersion)) { + throw new Error('Cannot parse webpack major version'); +} +if (webpackMajorVersion < 4) { + var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin'); +} var HtmlWebpackPlugin = require('../index.js'); if (Number(extractTextPluginMajorVersion) > 1) { @@ -35,7 +41,41 @@ var OUTPUT_DIR = path.join(__dirname, '../dist'); jasmine.getEnv().defaultTimeoutInterval = 30000; +function transformCommonChunkConfigToOptimization (config) { + if (config.name === 'common') { + return { + splitChunks: { + cacheGroups: { + commons: { + chunks: 'initial', + name: config.name, + enforce: true + } + } + } + }; + } else { + throw new Error('Unrecognized common chunk config'); + } +} + function testHtmlPlugin (webpackConfig, expectedResults, outputFile, done, expectErrors, expectWarnings) { + if (webpackMajorVersion >= 4) { + webpackConfig.mode = 'development'; + if (webpackConfig.module && webpackConfig.module.loaders) { + webpackConfig.module.rules = webpackConfig.module.loaders; + delete webpackConfig.module.loaders; + } + } + if (webpackConfig.__commonsChunk) { + if (webpackMajorVersion < 4) { + webpackConfig.plugins = webpackConfig.plugins || []; + webpackConfig.plugins.unshift(new CommonsChunkPlugin(webpackConfig.__commonsChunk)); + } else { + webpackConfig.optimization = transformCommonChunkConfigToOptimization(webpackConfig.__commonsChunk); + } + delete webpackConfig.__commonsChunk; + } outputFile = outputFile || 'index.html'; webpack(webpackConfig, function (err, stats) { expect(err).toBeFalsy(); @@ -99,6 +139,26 @@ function getChunksInfoFromStats (stats) { return chunksInfo; } +function tapCompilationEvent (compilation, eventName, handler) { + // Webpack 4 has a new interface + if (compilation.hooks) { + return compilation.hooks[trainCaseToCamelCase(eventName)].tapAsync( + 'AsyncPlugin' + tapCompilationEvent.counter++, + handler + ); + } else { + return compilation.plugin(eventName, handler); + } +} +// There's probably a better way to do this +tapCompilationEvent.counter = 0; + +function trainCaseToCamelCase (word) { + return word.replace(/-([\w])/g, function (match, p1) { + return p1.toUpperCase(); + }); +} + describe('HtmlWebpackPlugin', function () { beforeEach(function (done) { rimraf(OUTPUT_DIR, done); @@ -728,7 +788,7 @@ describe('HtmlWebpackPlugin', function () { var examplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-alter-asset-tags', function (object, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-alter-asset-tags', function (object, callback) { expect(typeof object.body).toBe('object'); expect(typeof object.head).toBe('object'); eventFired = true; @@ -737,6 +797,8 @@ describe('HtmlWebpackPlugin', function () { }); } }; + + var shouldExpectWarnings = webpackMajorVersion < 4; testHtmlPlugin({ entry: { app: path.join(__dirname, 'fixtures/index.js') @@ -752,7 +814,8 @@ describe('HtmlWebpackPlugin', function () { }, [], null, function () { expect(eventFired).toBe(true); done(); - }, false, true); + }, false, + shouldExpectWarnings); }); it('passes chunks to the html-webpack-plugin-alter-asset-tags event', function (done) { @@ -760,13 +823,15 @@ describe('HtmlWebpackPlugin', function () { var examplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-alter-asset-tags', function (object, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-alter-asset-tags', function (object, callback) { chunks = object.chunks; callback(); }); }); } }; + + var shouldExpectWarnings = webpackMajorVersion < 4; testHtmlPlugin({ entry: { app: path.join(__dirname, 'fixtures/index.js') @@ -782,14 +847,15 @@ describe('HtmlWebpackPlugin', function () { }, [], null, function () { expect(chunks).toBeDefined(); done(); - }, false, true); + }, false, + shouldExpectWarnings); }); it('allows events to add a no-value attribute', function (done) { var examplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-alter-asset-tags', function (pluginArgs, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-alter-asset-tags', function (pluginArgs, callback) { pluginArgs.body = pluginArgs.body.map(function (tag) { if (tag.tagName === 'script') { tag.attributes.async = true; @@ -822,7 +888,7 @@ describe('HtmlWebpackPlugin', function () { var examplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-alter-asset-tags', function (pluginArgs, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-alter-asset-tags', function (pluginArgs, callback) { pluginArgs.body = pluginArgs.body.map(function (tag) { if (tag.tagName === 'script') { tag.attributes.async = false; @@ -856,13 +922,15 @@ describe('HtmlWebpackPlugin', function () { var examplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-before-html-processing', function (object, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-before-html-processing', function (object, callback) { eventFired = true; callback(); }); }); } }; + + var shouldExpectWarnings = webpackMajorVersion < 4; testHtmlPlugin({ entry: { app: path.join(__dirname, 'fixtures/index.js') @@ -878,7 +946,8 @@ describe('HtmlWebpackPlugin', function () { }, [], null, function () { expect(eventFired).toBe(true); done(); - }, false, true); + }, false, + shouldExpectWarnings); }); it('fires the html-webpack-plugin-after-html-processing event', function (done) { @@ -886,13 +955,14 @@ describe('HtmlWebpackPlugin', function () { var examplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-after-html-processing', function (object, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-after-html-processing', function (object, callback) { eventFired = true; callback(); }); }); } }; + var shouldExpectWarnings = webpackMajorVersion < 4; testHtmlPlugin({ entry: { app: path.join(__dirname, 'fixtures/index.js') @@ -908,7 +978,8 @@ describe('HtmlWebpackPlugin', function () { }, [], null, function () { expect(eventFired).toBe(true); done(); - }, false, true); + }, false, + shouldExpectWarnings); }); it('fires the html-webpack-plugin-after-emit event', function (done) { @@ -916,7 +987,7 @@ describe('HtmlWebpackPlugin', function () { var examplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-after-emit', function (object, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-after-emit', function (object, callback) { eventFired = true; callback(); }); @@ -946,7 +1017,7 @@ describe('HtmlWebpackPlugin', function () { var examplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-after-html-processing', function (object, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-after-html-processing', function (object, callback) { eventFired = true; object.html += 'Injected by plugin'; callback(); @@ -954,6 +1025,8 @@ describe('HtmlWebpackPlugin', function () { }); } }; + + var shouldExpectWarnings = webpackMajorVersion < 4; testHtmlPlugin({ entry: { app: path.join(__dirname, 'fixtures/index.js') @@ -969,7 +1042,8 @@ describe('HtmlWebpackPlugin', function () { }, ['Injected by plugin'], null, function () { expect(eventFired).toBe(true); done(); - }, false, true); + }, false, + shouldExpectWarnings); }); it('allows to modify sequentially the html during html-webpack-plugin-after-html-processing event by edit the given arguments object', function (done) { @@ -978,7 +1052,7 @@ describe('HtmlWebpackPlugin', function () { var examplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-after-html-processing', function (object, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-after-html-processing', function (object, callback) { eventFiredForFirstPlugin = true; object.html += 'Injected by first plugin'; callback(null, object); @@ -989,7 +1063,7 @@ describe('HtmlWebpackPlugin', function () { var secondExamplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-after-html-processing', function (object, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-after-html-processing', function (object, callback) { eventFiredForSecondPlugin = true; object.html += ' Injected by second plugin'; callback(null); @@ -998,6 +1072,7 @@ describe('HtmlWebpackPlugin', function () { } }; + var shouldExpectWarnings = webpackMajorVersion < 4; testHtmlPlugin({ entry: { app: path.join(__dirname, 'fixtures/index.js') @@ -1015,7 +1090,8 @@ describe('HtmlWebpackPlugin', function () { expect(eventFiredForFirstPlugin).toBe(true); expect(eventFiredForSecondPlugin).toBe(true); done(); - }, false, true); + }, false, + shouldExpectWarnings); }); it('allows to modify sequentially the html during html-webpack-plugin-after-html-processing event either by edit the given arguments object or by return a new object in the callback', function (done) { @@ -1024,7 +1100,7 @@ describe('HtmlWebpackPlugin', function () { var examplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-after-html-processing', function (object, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-after-html-processing', function (object, callback) { eventFiredForFirstPlugin = true; var result = _.extend(object, { html: object.html + 'Injected by first plugin' @@ -1037,7 +1113,7 @@ describe('HtmlWebpackPlugin', function () { var secondExamplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-after-html-processing', function (object, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-after-html-processing', function (object, callback) { eventFiredForSecondPlugin = true; object.html += ' Injected by second plugin'; callback(null); @@ -1046,6 +1122,7 @@ describe('HtmlWebpackPlugin', function () { } }; + var shouldExpectWarnings = webpackMajorVersion < 4; testHtmlPlugin({ entry: { app: path.join(__dirname, 'fixtures/index.js') @@ -1063,7 +1140,8 @@ describe('HtmlWebpackPlugin', function () { expect(eventFiredForFirstPlugin).toBe(true); expect(eventFiredForSecondPlugin).toBe(true); done(); - }, false, true); + }, false, + shouldExpectWarnings); }); it('allows to modify sequentially the html during html-webpack-plugin-after-html-processing event by return a new object in the callback', function (done) { @@ -1072,7 +1150,7 @@ describe('HtmlWebpackPlugin', function () { var examplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-after-html-processing', function (object, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-after-html-processing', function (object, callback) { eventFiredForFirstPlugin = true; var result = _.extend(object, { html: object.html + 'Injected by first plugin' @@ -1085,7 +1163,7 @@ describe('HtmlWebpackPlugin', function () { var secondExamplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-after-html-processing', function (object, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-after-html-processing', function (object, callback) { eventFiredForSecondPlugin = true; var result = _.extend(object, { html: object.html + ' Injected by second plugin' @@ -1121,7 +1199,7 @@ describe('HtmlWebpackPlugin', function () { var examplePlugin = { apply: function (compiler) { compiler.plugin('compilation', function (compilation) { - compilation.plugin('html-webpack-plugin-before-html-processing', function (object, callback) { + tapCompilationEvent(compilation, 'html-webpack-plugin-before-html-processing', function (object, callback) { eventFired = true; object.assets.js.push('funky-script.js'); object.html += 'Injected by plugin'; @@ -1130,6 +1208,8 @@ describe('HtmlWebpackPlugin', function () { }); } }; + + var shouldExpectWarnings = webpackMajorVersion < 4; testHtmlPlugin({ entry: { app: path.join(__dirname, 'fixtures/index.js') @@ -1145,7 +1225,8 @@ describe('HtmlWebpackPlugin', function () { }, ['Injected by plugin', '