Skip to content

Commit edaeda7

Browse files
committed
test(index): add test case for checkCssChunk option
1 parent 9af7499 commit edaeda7

File tree

10 files changed

+308
-0
lines changed

10 files changed

+308
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.async { background: blue; }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './in-async.css';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.in-async { background: green; }
2+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.async { background: blue; }
2+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
body { background: red; }
2+
Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
/******/ (function(modules) { // webpackBootstrap
2+
/******/ // install a JSONP callback for chunk loading
3+
/******/ function webpackJsonpCallback(data) {
4+
/******/ var chunkIds = data[0];
5+
/******/ var moreModules = data[1];
6+
/******/
7+
/******/
8+
/******/ // add "moreModules" to the modules object,
9+
/******/ // then flag all "chunkIds" as loaded and fire callback
10+
/******/ var moduleId, chunkId, i = 0, resolves = [];
11+
/******/ for(;i < chunkIds.length; i++) {
12+
/******/ chunkId = chunkIds[i];
13+
/******/ if(installedChunks[chunkId]) {
14+
/******/ resolves.push(installedChunks[chunkId][0]);
15+
/******/ }
16+
/******/ installedChunks[chunkId] = 0;
17+
/******/ }
18+
/******/ for(moduleId in moreModules) {
19+
/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
20+
/******/ modules[moduleId] = moreModules[moduleId];
21+
/******/ }
22+
/******/ }
23+
/******/ if(parentJsonpFunction) parentJsonpFunction(data);
24+
/******/
25+
/******/ while(resolves.length) {
26+
/******/ resolves.shift()();
27+
/******/ }
28+
/******/
29+
/******/ };
30+
/******/
31+
/******/
32+
/******/ // The module cache
33+
/******/ var installedModules = {};
34+
/******/
35+
/******/ // object to store loaded CSS chunks
36+
/******/ var installedCssChunks = {
37+
/******/ 0: 0
38+
/******/ }
39+
/******/
40+
/******/ function cssLinkHref(chunkId) {
41+
/******/ var href = "" + ({}[chunkId]||chunkId) + ".css";
42+
/******/ var fullhref = __webpack_require__.p + href;
43+
/******/ return {href: href, fullhref: fullhref};
44+
/******/ }
45+
/******/
46+
/******/ // object to store loaded and loading chunks
47+
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
48+
/******/ // Promise = chunk loading, 0 = chunk loaded
49+
/******/ var installedChunks = {
50+
/******/ 0: 0
51+
/******/ };
52+
/******/
53+
/******/
54+
/******/
55+
/******/ // script path function
56+
/******/ function jsonpScriptSrc(chunkId) {
57+
/******/ return __webpack_require__.p + "" + ({}[chunkId]||chunkId) + ".js"
58+
/******/ }
59+
/******/
60+
/******/ // The require function
61+
/******/ function __webpack_require__(moduleId) {
62+
/******/
63+
/******/ // Check if module is in cache
64+
/******/ if(installedModules[moduleId]) {
65+
/******/ return installedModules[moduleId].exports;
66+
/******/ }
67+
/******/ // Create a new module (and put it into the cache)
68+
/******/ var module = installedModules[moduleId] = {
69+
/******/ i: moduleId,
70+
/******/ l: false,
71+
/******/ exports: {}
72+
/******/ };
73+
/******/
74+
/******/ // Execute the module function
75+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
76+
/******/
77+
/******/ // Flag the module as loaded
78+
/******/ module.l = true;
79+
/******/
80+
/******/ // Return the exports of the module
81+
/******/ return module.exports;
82+
/******/ }
83+
/******/
84+
/******/ // This file contains only the entry chunk.
85+
/******/ // The chunk loading function for additional chunks
86+
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
87+
/******/ var promises = [];
88+
/******/
89+
/******/
90+
/******/ // mini-css-extract-plugin CSS loading
91+
/******/
92+
/******/ if(installedCssChunks[chunkId]) promises.push(installedCssChunks[chunkId]);
93+
/******/ else if(installedCssChunks[chunkId] !== 0) {
94+
/******/ promises.push(installedCssChunks[chunkId] = new Promise(function(resolve, reject) {
95+
/******/ var hrefData = cssLinkHref(chunkId);
96+
/******/ var href = hrefData.href;
97+
/******/ var fullhref = hrefData.fullhref;
98+
/******/ var existingLinkTags = document.getElementsByTagName("link");
99+
/******/ for(var i = 0; i < existingLinkTags.length; i++) {
100+
/******/ var tag = existingLinkTags[i];
101+
/******/ var dataHref = tag.getAttribute("data-href") || tag.getAttribute("href");
102+
/******/ if(tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref)) return resolve();
103+
/******/ }
104+
/******/ var existingStyleTags = document.getElementsByTagName("style");
105+
/******/ for(var i = 0; i < existingStyleTags.length; i++) {
106+
/******/ var tag = existingStyleTags[i];
107+
/******/ var dataHref = tag.getAttribute("data-href");
108+
/******/ if(dataHref === href || dataHref === fullhref) return resolve();
109+
/******/ }
110+
/******/ var linkTag = document.createElement("link");
111+
/******/ linkTag.rel = "stylesheet";
112+
/******/ linkTag.type = "text/css";
113+
/******/ linkTag.onload = resolve;
114+
/******/ linkTag.onerror = function(event) {
115+
/******/ var request = event && event.target && event.target.src || fullhref;
116+
/******/ var err = new Error("Loading CSS chunk " + chunkId + " failed.\n(" + request + ")");
117+
/******/ err.request = request;
118+
/******/ reject(err);
119+
/******/ };
120+
/******/ linkTag.href = fullhref;
121+
/******/ var head = document.getElementsByTagName("head")[0];
122+
/******/ head.appendChild(linkTag);
123+
/******/ }).then(function() {
124+
/******/ installedCssChunks[chunkId] = 0;
125+
/******/ }));
126+
/******/ }
127+
/******/
128+
/******/ // JSONP chunk loading for javascript
129+
/******/
130+
/******/ var installedChunkData = installedChunks[chunkId];
131+
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
132+
/******/
133+
/******/ // a Promise means "currently loading".
134+
/******/ if(installedChunkData) {
135+
/******/ promises.push(installedChunkData[2]);
136+
/******/ } else {
137+
/******/ // setup Promise in chunk cache
138+
/******/ var promise = new Promise(function(resolve, reject) {
139+
/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
140+
/******/ });
141+
/******/ promises.push(installedChunkData[2] = promise);
142+
/******/
143+
/******/ // start chunk loading
144+
/******/ var head = document.getElementsByTagName('head')[0];
145+
/******/ var script = document.createElement('script');
146+
/******/ var onScriptComplete;
147+
/******/
148+
/******/ script.charset = 'utf-8';
149+
/******/ script.timeout = 120;
150+
/******/ if (__webpack_require__.nc) {
151+
/******/ script.setAttribute("nonce", __webpack_require__.nc);
152+
/******/ }
153+
/******/ script.src = jsonpScriptSrc(chunkId);
154+
/******/
155+
/******/ onScriptComplete = function (event) {
156+
/******/ // avoid mem leaks in IE.
157+
/******/ script.onerror = script.onload = null;
158+
/******/ clearTimeout(timeout);
159+
/******/ var chunk = installedChunks[chunkId];
160+
/******/ if(chunk !== 0) {
161+
/******/ if(chunk) {
162+
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
163+
/******/ var realSrc = event && event.target && event.target.src;
164+
/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
165+
/******/ error.type = errorType;
166+
/******/ error.request = realSrc;
167+
/******/ chunk[1](error);
168+
/******/ }
169+
/******/ installedChunks[chunkId] = undefined;
170+
/******/ }
171+
/******/ };
172+
/******/ var timeout = setTimeout(function(){
173+
/******/ onScriptComplete({ type: 'timeout', target: script });
174+
/******/ }, 120000);
175+
/******/ script.onerror = script.onload = onScriptComplete;
176+
/******/ head.appendChild(script);
177+
/******/ }
178+
/******/ }
179+
/******/ return Promise.all(promises);
180+
/******/ };
181+
/******/
182+
/******/ // expose the modules object (__webpack_modules__)
183+
/******/ __webpack_require__.m = modules;
184+
/******/
185+
/******/ // expose the module cache
186+
/******/ __webpack_require__.c = installedModules;
187+
/******/
188+
/******/ // define getter function for harmony exports
189+
/******/ __webpack_require__.d = function(exports, name, getter) {
190+
/******/ if(!__webpack_require__.o(exports, name)) {
191+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
192+
/******/ }
193+
/******/ };
194+
/******/
195+
/******/ // define __esModule on exports
196+
/******/ __webpack_require__.r = function(exports) {
197+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
198+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
199+
/******/ }
200+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
201+
/******/ };
202+
/******/
203+
/******/ // create a fake namespace object
204+
/******/ // mode & 1: value is a module id, require it
205+
/******/ // mode & 2: merge all properties of value into the ns
206+
/******/ // mode & 4: return value when already ns object
207+
/******/ // mode & 8|1: behave like require
208+
/******/ __webpack_require__.t = function(value, mode) {
209+
/******/ if(mode & 1) value = __webpack_require__(value);
210+
/******/ if(mode & 8) return value;
211+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
212+
/******/ var ns = Object.create(null);
213+
/******/ __webpack_require__.r(ns);
214+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
215+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
216+
/******/ return ns;
217+
/******/ };
218+
/******/
219+
/******/ // getDefaultExport function for compatibility with non-harmony modules
220+
/******/ __webpack_require__.n = function(module) {
221+
/******/ var getter = module && module.__esModule ?
222+
/******/ function getDefault() { return module['default']; } :
223+
/******/ function getModuleExports() { return module; };
224+
/******/ __webpack_require__.d(getter, 'a', getter);
225+
/******/ return getter;
226+
/******/ };
227+
/******/
228+
/******/ // Object.prototype.hasOwnProperty.call
229+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
230+
/******/
231+
/******/ // __webpack_public_path__
232+
/******/ __webpack_require__.p = "";
233+
/******/
234+
/******/ // on error function for async loading
235+
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
236+
/******/
237+
/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
238+
/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
239+
/******/ jsonpArray.push = webpackJsonpCallback;
240+
/******/ jsonpArray = jsonpArray.slice();
241+
/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
242+
/******/ var parentJsonpFunction = oldJsonpFunction;
243+
/******/
244+
/******/
245+
/******/ // Load entry module and return exports
246+
/******/ return __webpack_require__(__webpack_require__.s = 0);
247+
/******/ })
248+
/************************************************************************/
249+
/******/ ([
250+
/* 0 */
251+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
252+
253+
"use strict";
254+
__webpack_require__.r(__webpack_exports__);
255+
/* harmony import */ var _main_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
256+
/* harmony import */ var _main_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_main_css__WEBPACK_IMPORTED_MODULE_0__);
257+
258+
259+
__webpack_require__.e(/* import() */ 1).then(__webpack_require__.bind(null, 3));
260+
261+
__webpack_require__.e(/* import() */ 2).then(__webpack_require__.t.bind(null, 6, 7));
262+
263+
264+
/***/ }),
265+
/* 1 */
266+
/***/ (function(module, exports, __webpack_require__) {
267+
268+
// extracted by mini-css-extract-plugin
269+
270+
/***/ })
271+
/******/ ]);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.in-async { background: green; }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import './main.css';
2+
3+
import('./async');
4+
5+
import('./async.css');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
body { background: red; }
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const Self = require('../../../');
2+
3+
module.exports = {
4+
entry: './index.js',
5+
module: {
6+
rules: [
7+
{
8+
test: /\.css$/,
9+
use: [
10+
Self.loader,
11+
'css-loader',
12+
],
13+
},
14+
],
15+
},
16+
plugins: [
17+
new Self({
18+
filename: '[name].css',
19+
checkCssChunk: false,
20+
}),
21+
],
22+
};

0 commit comments

Comments
 (0)