From 04b79efb7cbeb6d45ce7ca5a30381d3cf314c7c4 Mon Sep 17 00:00:00 2001 From: zackjackson Date: Sun, 27 Jan 2019 13:25:32 -0800 Subject: [PATCH] test: added hmr test case updating js hash and adding hmr test cases --- package.json | 2 +- src/hmr/.eslintrc.js | 23 -- src/hmr/hotModuleReplacement.js | 72 +++-- test/cases/hmr/a.css | 1 + test/cases/hmr/b.css | 5 + test/cases/hmr/c.css | 5 + test/cases/hmr/expected/main.css | 14 + test/cases/hmr/index.css | 2 + test/cases/hmr/webpack.config.js | 28 ++ .../expected/main.52d8306d460bb8ad1388.js | 253 ++++++++++++++++++ .../expected/main.73e85e9f40154bbb5412.js | 253 ++++++++++++++++++ ...6e1512072d65b9db.c747f8a6eecaeef208b9.css} | 0 ...f0222.js => style.74b98ee6c7507ed560f7.js} | 2 + ...674590ef68e758b3.da149d34018298af23b9.css} | 0 .../expected/style.c335d5d236ba55a3fbff.js | 12 + 15 files changed, 620 insertions(+), 52 deletions(-) delete mode 100644 src/hmr/.eslintrc.js create mode 100644 test/cases/hmr/a.css create mode 100644 test/cases/hmr/b.css create mode 100644 test/cases/hmr/c.css create mode 100644 test/cases/hmr/expected/main.css create mode 100644 test/cases/hmr/index.css create mode 100644 test/cases/hmr/webpack.config.js create mode 100644 test/cases/js-hash/expected/main.52d8306d460bb8ad1388.js create mode 100644 test/cases/js-hash/expected/main.73e85e9f40154bbb5412.js rename test/cases/js-hash/expected/{style.11a76e1512072d65b9db.35ee3780b5b76904cef5.css => style.11a76e1512072d65b9db.c747f8a6eecaeef208b9.css} (100%) rename test/cases/js-hash/expected/{style.25d094fb4a6ef6ef0222.js => style.74b98ee6c7507ed560f7.js} (85%) rename test/cases/js-hash/expected/{style.822a674590ef68e758b3.ca7d26e87c697b1c7039.css => style.822a674590ef68e758b3.da149d34018298af23b9.css} (100%) create mode 100644 test/cases/js-hash/expected/style.c335d5d236ba55a3fbff.js diff --git a/package.json b/package.json index 079f7472..361d266d 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "release:ci": "conventional-github-releaser -p angular", "release:validate": "commitlint --from=$(git describe --tags --abbrev=0) --to=$(git rev-parse HEAD)", "security": "npm audit", - "test": "jest", + "test": "jest -u", "test:watch": "jest --watch", "test:coverage": "jest --collectCoverageFrom='src/**/*.js' --coverage", "test:manual": "webpack-dev-server test/manual/src/index.js --open --config test/manual/webpack.config.js", diff --git a/src/hmr/.eslintrc.js b/src/hmr/.eslintrc.js deleted file mode 100644 index 97ca3a15..00000000 --- a/src/hmr/.eslintrc.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = { - "parserOptions": { - "ecmaVersion": 5, - "sourceType": "module", - }, - globals: { - document: true - }, - plugins: ['prettier'], - extends: ['@webpack-contrib/eslint-config-webpack'], - rules: { - 'prettier/prettier': [ - 'error', - {singleQuote: true, trailingComma: 'es5', arrowParens: 'avoid'}, - ], - 'class-methods-use-this': 'off', - 'no-undefined': 'off', - 'func-style': ["error", "declaration", {"allowArrowFunctions": false}], - 'prefer-rest-params': 0, - 'prefer-spread': 0, - 'prefer-destructuring': 0 - }, -}; diff --git a/src/hmr/hotModuleReplacement.js b/src/hmr/hotModuleReplacement.js index 652102af..934742bc 100644 --- a/src/hmr/hotModuleReplacement.js +++ b/src/hmr/hotModuleReplacement.js @@ -1,34 +1,48 @@ -const normalizeUrl = require('normalize-url'); +/* global document, window */ +/* eslint func-names: 0 */ +/* eslint no-var: 0 */ +/* eslint vars-on-top: 0 */ +/* eslint prefer-arrow-func: 0 */ +/* eslint prefer-rest-params: 0 */ +/* eslint prefer-arrow-callback: 0 */ -const srcByModuleId = Object.create(null); +var normalizeUrl = require('normalize-url'); -const noDocument = typeof document === 'undefined'; +var srcByModuleId = Object.create(null); + +var noDocument = typeof document === 'undefined'; + +var forEach = Array.prototype.forEach; function debounce(fn, time) { - let timeout; + var timeout = 0; // eslint-disable-next-line func-names return function() { - const functionCall = () => fn.apply(this, arguments); + var self = this; + var args = arguments; + + // eslint-disable-next-line prefer-rest-params + var functionCall = function functionCall() { + return fn.apply(self, args); + }; clearTimeout(timeout); timeout = setTimeout(functionCall, time); }; } -const forEach = Array.prototype.forEach; - function noop() {} function getCurrentScriptUrl(moduleId) { - let src = srcByModuleId[moduleId]; + var src = srcByModuleId[moduleId]; if (!src) { if (document.currentScript) { src = document.currentScript.src; } else { - const scripts = document.getElementsByTagName('script'); - const lastScriptTag = scripts[scripts.length - 1]; + var scripts = document.getElementsByTagName('script'); + var lastScriptTag = scripts[scripts.length - 1]; if (lastScriptTag) { src = lastScriptTag.src; @@ -41,16 +55,16 @@ function getCurrentScriptUrl(moduleId) { if (!src) { return null; } - const splitResult = src.split(/([^\\/]+)\.js$/); - const filename = splitResult && splitResult[1]; + var splitResult = src.split(/([^\\/]+)\.js$/); + var filename = splitResult && splitResult[1]; if (!filename) { return [src.replace('.js', '.css')]; } if (!fileMap) { return [src.replace('.js', '.css')]; } - return fileMap.split(',').map(mapRule => { - const reg = new RegExp(`${filename}\\.js$`, 'g'); + return fileMap.split(',').map(function(mapRule) { + var reg = new RegExp(`${filename}\\.js$`, 'g'); return normalizeUrl( src.replace(reg, `${mapRule.replace(/{fileName}/g, filename)}.css`), { stripWWW: false } @@ -71,16 +85,16 @@ function updateCss(el, url) { if (!url || !(url.indexOf('.css') > -1)) return; el.visited = true; - const newEl = el.cloneNode(); + var newEl = el.cloneNode(); // eslint-disable-line vars-on-top newEl.isLoaded = false; - newEl.addEventListener('load', () => { + newEl.addEventListener('load', function() { newEl.isLoaded = true; el.parentNode.removeChild(el); }); - newEl.addEventListener('error', () => { + newEl.addEventListener('error', function() { newEl.isLoaded = true; el.parentNode.removeChild(el); }); @@ -90,10 +104,10 @@ function updateCss(el, url) { } function getReloadUrl(href, src) { + var ret; href = normalizeUrl(href, { stripWWW: false }); - let ret; // eslint-disable-next-line array-callback-return - src.some(url => { + src.some(function(url) { if (href.indexOf(src) > -1) { ret = url; } @@ -102,13 +116,14 @@ function getReloadUrl(href, src) { } function reloadStyle(src) { - const elements = document.querySelectorAll('link'); - let loaded = false; + var elements = document.querySelectorAll('link'); + var loaded = false; + + forEach.call(elements, function(el) { + var url = getReloadUrl(el.href, src); - forEach.call(elements, el => { if (el.visited === true) return; - const url = getReloadUrl(el.href, src); if (url) { updateCss(el, url); loaded = true; @@ -119,8 +134,8 @@ function reloadStyle(src) { } function reloadAll() { - const elements = document.querySelectorAll('link'); - forEach.call(elements, el => { + var elements = document.querySelectorAll('link'); + forEach.call(elements, function(el) { if (el.visited === true) return; updateCss(el); }); @@ -131,11 +146,12 @@ module.exports = function(moduleId, options) { return noop; } - const getScriptSrc = getCurrentScriptUrl(moduleId); + // eslint-disable-next-line vars-on-top + var getScriptSrc = getCurrentScriptUrl(moduleId); function update() { - const src = getScriptSrc(options.filename); - const reloaded = reloadStyle(src); + var src = getScriptSrc(options.filename); + var reloaded = reloadStyle(src); if (reloaded && !options.reloadAll) { console.log('[HMR] css reload %s', src.join(' ')); } else { diff --git a/test/cases/hmr/a.css b/test/cases/hmr/a.css new file mode 100644 index 00000000..31fc5b8a --- /dev/null +++ b/test/cases/hmr/a.css @@ -0,0 +1 @@ +body { background: red; } diff --git a/test/cases/hmr/b.css b/test/cases/hmr/b.css new file mode 100644 index 00000000..11559583 --- /dev/null +++ b/test/cases/hmr/b.css @@ -0,0 +1,5 @@ +.b { background: red; } + +@import url("https://some/external/css"); + +.b { color: yellow; } diff --git a/test/cases/hmr/c.css b/test/cases/hmr/c.css new file mode 100644 index 00000000..9c41dd1f --- /dev/null +++ b/test/cases/hmr/c.css @@ -0,0 +1,5 @@ +.c { background: red; } +@import './a.css'; +@import url("https://some/other/external/css"); + +.c { color: yellow; } diff --git a/test/cases/hmr/expected/main.css b/test/cases/hmr/expected/main.css new file mode 100644 index 00000000..cd5dacee --- /dev/null +++ b/test/cases/hmr/expected/main.css @@ -0,0 +1,14 @@ +@import url(https://some/other/external/css); +@import url(https://some/external/css); +body { background: red; } + +.c { background: red; } + +.c { color: yellow; } + +.b { background: red; } + +.b { color: yellow; } + + + diff --git a/test/cases/hmr/index.css b/test/cases/hmr/index.css new file mode 100644 index 00000000..c03e069d --- /dev/null +++ b/test/cases/hmr/index.css @@ -0,0 +1,2 @@ +@import './c.css'; +@import './b.css'; diff --git a/test/cases/hmr/webpack.config.js b/test/cases/hmr/webpack.config.js new file mode 100644 index 00000000..aa6fcb8d --- /dev/null +++ b/test/cases/hmr/webpack.config.js @@ -0,0 +1,28 @@ +const Self = require('../../../'); + +module.exports = { + entry: './index.css', + module: { + rules: [ + { + test: /\.css$/, + use: [ + { + loader: Self.loader, + options: { + hmr: true, + modules: true, + reloadAll: true + }, + }, + 'css-loader', + ], + }, + ], + }, + plugins: [ + new Self({ + filename: '[name].css', + }), + ], +}; diff --git a/test/cases/js-hash/expected/main.52d8306d460bb8ad1388.js b/test/cases/js-hash/expected/main.52d8306d460bb8ad1388.js new file mode 100644 index 00000000..802b62bd --- /dev/null +++ b/test/cases/js-hash/expected/main.52d8306d460bb8ad1388.js @@ -0,0 +1,253 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // install a JSONP callback for chunk loading +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0]; +/******/ var moreModules = data[1]; +/******/ +/******/ +/******/ // add "moreModules" to the modules object, +/******/ // then flag all "chunkIds" as loaded and fire callback +/******/ var moduleId, chunkId, i = 0, resolves = []; +/******/ for(;i < chunkIds.length; i++) { +/******/ chunkId = chunkIds[i]; +/******/ if(installedChunks[chunkId]) { +/******/ resolves.push(installedChunks[chunkId][0]); +/******/ } +/******/ installedChunks[chunkId] = 0; +/******/ } +/******/ for(moduleId in moreModules) { +/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) { +/******/ modules[moduleId] = moreModules[moduleId]; +/******/ } +/******/ } +/******/ if(parentJsonpFunction) parentJsonpFunction(data); +/******/ +/******/ while(resolves.length) { +/******/ resolves.shift()(); +/******/ } +/******/ +/******/ }; +/******/ +/******/ +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // object to store loaded CSS chunks +/******/ var installedCssChunks = { +/******/ 0: 0 +/******/ } +/******/ +/******/ // object to store loaded and loading chunks +/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched +/******/ // Promise = chunk loading, 0 = chunk loaded +/******/ var installedChunks = { +/******/ 0: 0 +/******/ }; +/******/ +/******/ +/******/ +/******/ // script path function +/******/ function jsonpScriptSrc(chunkId) { +/******/ return __webpack_require__.p + "" + ({"1":"style"}[chunkId]||chunkId) + "." + {"1":"c335d5d236ba55a3fbff"}[chunkId] + ".js" +/******/ } +/******/ +/******/ // 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; +/******/ } +/******/ +/******/ // This file contains only the entry chunk. +/******/ // The chunk loading function for additional chunks +/******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // mini-css-extract-plugin CSS loading +/******/ var cssChunks = {"1":1}; +/******/ if(installedCssChunks[chunkId]) promises.push(installedCssChunks[chunkId]); +/******/ else if(installedCssChunks[chunkId] !== 0 && cssChunks[chunkId]) { +/******/ promises.push(installedCssChunks[chunkId] = new Promise(function(resolve, reject) { +/******/ var href = "" + ({"1":"style"}[chunkId]||chunkId) + "." + {"1":"822a674590ef68e758b3"}[chunkId] + "." + {"1":"da149d34018298af23b9"}[chunkId] + ".css"; +/******/ var fullhref = __webpack_require__.p + href; +/******/ var existingLinkTags = document.getElementsByTagName("link"); +/******/ for(var i = 0; i < existingLinkTags.length; i++) { +/******/ var tag = existingLinkTags[i]; +/******/ var dataHref = tag.getAttribute("data-href") || tag.getAttribute("href"); +/******/ if(tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref)) return resolve(); +/******/ } +/******/ var existingStyleTags = document.getElementsByTagName("style"); +/******/ for(var i = 0; i < existingStyleTags.length; i++) { +/******/ var tag = existingStyleTags[i]; +/******/ var dataHref = tag.getAttribute("data-href"); +/******/ if(dataHref === href || dataHref === fullhref) return resolve(); +/******/ } +/******/ var linkTag = document.createElement("link"); +/******/ linkTag.rel = "stylesheet"; +/******/ linkTag.type = "text/css"; +/******/ linkTag.onload = resolve; +/******/ linkTag.onerror = function(event) { +/******/ var request = event && event.target && event.target.src || fullhref; +/******/ var err = new Error("Loading CSS chunk " + chunkId + " failed.\n(" + request + ")"); +/******/ err.request = request; +/******/ delete installedCssChunks[chunkId] +/******/ linkTag.parentNode.removeChild(linkTag) +/******/ reject(err); +/******/ }; +/******/ linkTag.href = fullhref; +/******/ +/******/ var head = document.getElementsByTagName("head")[0]; +/******/ head.appendChild(linkTag); +/******/ }).then(function() { +/******/ installedCssChunks[chunkId] = 0; +/******/ })); +/******/ } +/******/ +/******/ // JSONP chunk loading for javascript +/******/ +/******/ var installedChunkData = installedChunks[chunkId]; +/******/ if(installedChunkData !== 0) { // 0 means "already installed". +/******/ +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); +/******/ +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ var onScriptComplete; +/******/ +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120; +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); +/******/ } +/******/ script.src = jsonpScriptSrc(chunkId); +/******/ +/******/ onScriptComplete = function (event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ head.appendChild(script); +/******/ } +/******/ } +/******/ return Promise.all(promises); +/******/ }; +/******/ +/******/ // 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, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // 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 = ""; +/******/ +/******/ // on error function for async loading +/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; +/******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ var parentJsonpFunction = oldJsonpFunction; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__.e(/* import() | style */ 1).then(__webpack_require__.t.bind(null, 1, 7)); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/test/cases/js-hash/expected/main.73e85e9f40154bbb5412.js b/test/cases/js-hash/expected/main.73e85e9f40154bbb5412.js new file mode 100644 index 00000000..a6efa2bd --- /dev/null +++ b/test/cases/js-hash/expected/main.73e85e9f40154bbb5412.js @@ -0,0 +1,253 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // install a JSONP callback for chunk loading +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0]; +/******/ var moreModules = data[1]; +/******/ +/******/ +/******/ // add "moreModules" to the modules object, +/******/ // then flag all "chunkIds" as loaded and fire callback +/******/ var moduleId, chunkId, i = 0, resolves = []; +/******/ for(;i < chunkIds.length; i++) { +/******/ chunkId = chunkIds[i]; +/******/ if(installedChunks[chunkId]) { +/******/ resolves.push(installedChunks[chunkId][0]); +/******/ } +/******/ installedChunks[chunkId] = 0; +/******/ } +/******/ for(moduleId in moreModules) { +/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) { +/******/ modules[moduleId] = moreModules[moduleId]; +/******/ } +/******/ } +/******/ if(parentJsonpFunction) parentJsonpFunction(data); +/******/ +/******/ while(resolves.length) { +/******/ resolves.shift()(); +/******/ } +/******/ +/******/ }; +/******/ +/******/ +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // object to store loaded CSS chunks +/******/ var installedCssChunks = { +/******/ 0: 0 +/******/ } +/******/ +/******/ // object to store loaded and loading chunks +/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched +/******/ // Promise = chunk loading, 0 = chunk loaded +/******/ var installedChunks = { +/******/ 0: 0 +/******/ }; +/******/ +/******/ +/******/ +/******/ // script path function +/******/ function jsonpScriptSrc(chunkId) { +/******/ return __webpack_require__.p + "" + ({"1":"style"}[chunkId]||chunkId) + "." + {"1":"74b98ee6c7507ed560f7"}[chunkId] + ".js" +/******/ } +/******/ +/******/ // 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; +/******/ } +/******/ +/******/ // This file contains only the entry chunk. +/******/ // The chunk loading function for additional chunks +/******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // mini-css-extract-plugin CSS loading +/******/ var cssChunks = {"1":1}; +/******/ if(installedCssChunks[chunkId]) promises.push(installedCssChunks[chunkId]); +/******/ else if(installedCssChunks[chunkId] !== 0 && cssChunks[chunkId]) { +/******/ promises.push(installedCssChunks[chunkId] = new Promise(function(resolve, reject) { +/******/ var href = "" + ({"1":"style"}[chunkId]||chunkId) + "." + {"1":"11a76e1512072d65b9db"}[chunkId] + "." + {"1":"c747f8a6eecaeef208b9"}[chunkId] + ".css"; +/******/ var fullhref = __webpack_require__.p + href; +/******/ var existingLinkTags = document.getElementsByTagName("link"); +/******/ for(var i = 0; i < existingLinkTags.length; i++) { +/******/ var tag = existingLinkTags[i]; +/******/ var dataHref = tag.getAttribute("data-href") || tag.getAttribute("href"); +/******/ if(tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref)) return resolve(); +/******/ } +/******/ var existingStyleTags = document.getElementsByTagName("style"); +/******/ for(var i = 0; i < existingStyleTags.length; i++) { +/******/ var tag = existingStyleTags[i]; +/******/ var dataHref = tag.getAttribute("data-href"); +/******/ if(dataHref === href || dataHref === fullhref) return resolve(); +/******/ } +/******/ var linkTag = document.createElement("link"); +/******/ linkTag.rel = "stylesheet"; +/******/ linkTag.type = "text/css"; +/******/ linkTag.onload = resolve; +/******/ linkTag.onerror = function(event) { +/******/ var request = event && event.target && event.target.src || fullhref; +/******/ var err = new Error("Loading CSS chunk " + chunkId + " failed.\n(" + request + ")"); +/******/ err.request = request; +/******/ delete installedCssChunks[chunkId] +/******/ linkTag.parentNode.removeChild(linkTag) +/******/ reject(err); +/******/ }; +/******/ linkTag.href = fullhref; +/******/ +/******/ var head = document.getElementsByTagName("head")[0]; +/******/ head.appendChild(linkTag); +/******/ }).then(function() { +/******/ installedCssChunks[chunkId] = 0; +/******/ })); +/******/ } +/******/ +/******/ // JSONP chunk loading for javascript +/******/ +/******/ var installedChunkData = installedChunks[chunkId]; +/******/ if(installedChunkData !== 0) { // 0 means "already installed". +/******/ +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); +/******/ +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ var onScriptComplete; +/******/ +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120; +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); +/******/ } +/******/ script.src = jsonpScriptSrc(chunkId); +/******/ +/******/ onScriptComplete = function (event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ head.appendChild(script); +/******/ } +/******/ } +/******/ return Promise.all(promises); +/******/ }; +/******/ +/******/ // 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, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // 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 = ""; +/******/ +/******/ // on error function for async loading +/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; +/******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ var parentJsonpFunction = oldJsonpFunction; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__.e(/* import() | style */ 1).then(__webpack_require__.t.bind(null, 1, 7)); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/test/cases/js-hash/expected/style.11a76e1512072d65b9db.35ee3780b5b76904cef5.css b/test/cases/js-hash/expected/style.11a76e1512072d65b9db.c747f8a6eecaeef208b9.css similarity index 100% rename from test/cases/js-hash/expected/style.11a76e1512072d65b9db.35ee3780b5b76904cef5.css rename to test/cases/js-hash/expected/style.11a76e1512072d65b9db.c747f8a6eecaeef208b9.css diff --git a/test/cases/js-hash/expected/style.25d094fb4a6ef6ef0222.js b/test/cases/js-hash/expected/style.74b98ee6c7507ed560f7.js similarity index 85% rename from test/cases/js-hash/expected/style.25d094fb4a6ef6ef0222.js rename to test/cases/js-hash/expected/style.74b98ee6c7507ed560f7.js index 21f472ef..54ca4d2f 100644 --- a/test/cases/js-hash/expected/style.25d094fb4a6ef6ef0222.js +++ b/test/cases/js-hash/expected/style.74b98ee6c7507ed560f7.js @@ -5,6 +5,8 @@ // extracted by mini-css-extract-plugin module.exports = {"a":"wX52cuPepLZcpDx5S3yYO"}; + if(false) { var cssReload; } + /***/ }) ]]); \ No newline at end of file diff --git a/test/cases/js-hash/expected/style.822a674590ef68e758b3.ca7d26e87c697b1c7039.css b/test/cases/js-hash/expected/style.822a674590ef68e758b3.da149d34018298af23b9.css similarity index 100% rename from test/cases/js-hash/expected/style.822a674590ef68e758b3.ca7d26e87c697b1c7039.css rename to test/cases/js-hash/expected/style.822a674590ef68e758b3.da149d34018298af23b9.css diff --git a/test/cases/js-hash/expected/style.c335d5d236ba55a3fbff.js b/test/cases/js-hash/expected/style.c335d5d236ba55a3fbff.js new file mode 100644 index 00000000..54ca4d2f --- /dev/null +++ b/test/cases/js-hash/expected/style.c335d5d236ba55a3fbff.js @@ -0,0 +1,12 @@ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],[ +/* 0 */, +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +// extracted by mini-css-extract-plugin +module.exports = {"a":"wX52cuPepLZcpDx5S3yYO"}; + if(false) { var cssReload; } + + +/***/ }) +]]); \ No newline at end of file