Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,564 changes: 4,340 additions & 1,224 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
"eslint-config-webpack": "^4.4.2",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-jsdoc": "^52.0.0",
"eslint-plugin-jsdoc": "^62.0.0",
"eslint-plugin-n": "^17.21.0",
"eslint-plugin-prettier": "^5.5.3",
"eslint-plugin-unicorn": "^60.0.0",
"eslint-plugin-unicorn": "^62.0.0",
"file-loader": "^6.2.0",
"globals": "^16.3.0",
"globals": "^17.0.0",
"husky": "^7.0.0",
"jest": "^28.1.3",
"jest-environment-jsdom": "^28.1.3",
Expand Down
3 changes: 2 additions & 1 deletion src/hmr/hotModuleReplacement.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const noDocument = typeof document === "undefined";

const { forEach } = Array.prototype;

// eslint-disable-next-line jsdoc/no-restricted-syntax
/* eslint-disable jsdoc/reject-function-type */
/**
* @param {Function} fn any function
* @param {number} time time
Expand All @@ -38,6 +38,7 @@ function debounce(fn, time) {
timeout = setTimeout(functionCall, time);
};
}
/* eslint-enable jsdoc/reject-function-type */

/**
* @returns {void}
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const CODE_GENERATION_RESULT = {
runtimeRequirements: new Set(),
};

// eslint-disable-next-line jsdoc/no-restricted-syntax
// eslint-disable-next-line jsdoc/reject-any-type
/** @typedef {{ context: string | null, identifier: string, identifierIndex: number, content: Buffer, sourceMap?: Buffer, media?: string, supports?: string, layer?: any, assetsInfo?: Map<string, AssetInfo>, assets?: { [key: string]: Source }}} CssModuleDependency */
/** @typedef {Module & { content: Buffer, media?: string, sourceMap?: Buffer, supports?: string, layer?: string, assets?: { [key: string]: Source }, assetsInfo?: Map<string, AssetInfo> }} CssModule */
/** @typedef {{ new(dependency: CssModuleDependency): CssModule }} CssModuleConstructor */
Expand Down Expand Up @@ -795,7 +795,7 @@ class MiniCssExtractPlugin {
compilation.runtimeTemplate.requestShortener,
);

if (modules.size > 0) {
if (modules && modules.size > 0) {
const { hashFunction, hashDigest, hashDigestLength } = outputOptions;
const { createHash } = compiler.webpack.util;
const hash = createHash(/** @type {string} */ (hashFunction));
Expand Down
4 changes: 2 additions & 2 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const MiniCssExtractPlugin = require("./index");
/** @typedef {import("webpack").NormalModule} NormalModule */
/** @typedef {import("./index.js").LoaderOptions} LoaderOptions */

// eslint-disable-next-line jsdoc/no-restricted-syntax
// eslint-disable-next-line jsdoc/reject-function-type
/** @typedef {{[key: string]: string | Function }} Locals */

// eslint-disable-next-line jsdoc/no-restricted-syntax
// eslint-disable-next-line jsdoc/reject-any-type
/** @typedef {any} EXPECTED_ANY */

/**
Expand Down
8 changes: 5 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const path = require("path");
/** @typedef {import("webpack").Compilation} Compilation */
/** @typedef {import("webpack").Module} Module */

// eslint-disable-next-line jsdoc/no-restricted-syntax
// eslint-disable-next-line jsdoc/reject-any-type
/** @typedef {import("webpack").LoaderContext<any>} LoaderContext */

/**
Expand Down Expand Up @@ -36,7 +36,7 @@ function findModuleById(compilation, id) {
return null;
}

// eslint-disable-next-line jsdoc/no-restricted-syntax
/* eslint-disable jsdoc/reject-any-type */
/**
* @param {LoaderContext} loaderContext loader context
* @param {string | Buffer} code code
Expand All @@ -54,6 +54,7 @@ function evalModuleCode(loaderContext, code, filename) {

return module.exports;
}
/* eslint-enable jsdoc/reject-any-type */

/**
* @param {string} a a
Expand Down Expand Up @@ -203,14 +204,15 @@ function getUndoPath(filename, outputPath, enforceRelative) {
: append;
}

// eslint-disable-next-line jsdoc/no-restricted-syntax
/* eslint-disable jsdoc/reject-function-type */
/**
* @param {string | Function} value local
* @returns {string} stringified local
*/
function stringifyLocal(value) {
return typeof value === "function" ? value.toString() : JSON.stringify(value);
}
/* eslint-enable jsdoc/reject-function-type */

/**
* @param {string} str string
Expand Down
1 change: 0 additions & 1 deletion test/HMR.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* @jest-environment jsdom
*/
/* global document */
/* eslint-env browser */

import hotModuleReplacement from "../src/hmr/hotModuleReplacement";
import { hotLoader } from "../src/loader";
Expand Down
30 changes: 0 additions & 30 deletions test/__snapshots__/emit-option.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,35 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`emit option should invalidate the cache with disabled "emit" option: assets 1`] = `
Array [
"main.js",
"static/react.svg",
]
`;

exports[`emit option should invalidate the cache with disabled "emit" option: assets 2`] = `
Array [
"main.js",
]
`;

exports[`emit option should invalidate the cache with disabled "emit" option: emittedAssets 1`] = `
Array [
"main.js",
"static/react.svg",
]
`;

exports[`emit option should invalidate the cache with disabled "emit" option: emittedAssets 2`] = `Array []`;

exports[`emit option should invalidate the cache with disabled "emit" option: errors 1`] = `Array []`;

exports[`emit option should invalidate the cache with disabled "emit" option: errors 2`] = `Array []`;

exports[`emit option should invalidate the cache with disabled "emit" option: warnings 1`] = `Array []`;

exports[`emit option should invalidate the cache with disabled "emit" option: warnings 2`] = `Array []`;

exports[`emit option should work when emit option is "false": assets 1`] = `
Array [
"main.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use strict";
(self["webpackChunk"] = self["webpackChunk"] || []).push([[0],{

/***/ 2:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/***/ 2
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
// extracted by mini-css-extract-plugin


/***/ })
/***/ }

}]);
6 changes: 3 additions & 3 deletions test/cases/chunkFilename-fullhash/expected/webpack-5/async.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use strict";
(self["webpackChunk"] = self["webpackChunk"] || []).push([[0],{

/***/ 2:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/***/ 2
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
// extracted by mini-css-extract-plugin


/***/ })
/***/ }

}]);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/cases/devtool-source-map/expected/main.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 19 additions & 11 deletions test/cases/hmr-locals/expected/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({

/***/ "../../../src/hmr/hotModuleReplacement.js":
/***/ "../../../src/hmr/hotModuleReplacement.js"
/*!************************************************!*\
!*** ../../../src/hmr/hotModuleReplacement.js ***!
\************************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
(module, __unused_webpack_exports, __webpack_require__) {

/* global document */
/*
Expand All @@ -22,7 +22,7 @@ const noDocument = typeof document === "undefined";

const { forEach } = Array.prototype;

// eslint-disable-next-line jsdoc/no-restricted-syntax
/* eslint-disable jsdoc/reject-function-type */
/**
* @param {Function} fn any function
* @param {number} time time
Expand All @@ -47,6 +47,7 @@ function debounce(fn, time) {
timeout = setTimeout(functionCall, time);
};
}
/* eslint-enable jsdoc/reject-function-type */

/**
* @returns {void}
Expand Down Expand Up @@ -310,13 +311,13 @@ module.exports = function (moduleId, options) {
};


/***/ }),
/***/ },

/***/ "../../../src/hmr/normalize-url.js":
/***/ "../../../src/hmr/normalize-url.js"
/*!*****************************************!*\
!*** ../../../src/hmr/normalize-url.js ***!
\*****************************************/
/***/ ((module) => {
(module) {

/**
* @param {string[]} pathComponents path components
Expand Down Expand Up @@ -367,13 +368,13 @@ module.exports = function normalizeUrl(urlString) {
};


/***/ }),
/***/ },

/***/ "./index.css":
/***/ "./index.css"
/*!*******************!*\
!*** ./index.css ***!
\*******************/
/***/ ((module, __webpack_exports__, __webpack_require__) => {
(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
Expand Down Expand Up @@ -405,7 +406,7 @@ __webpack_require__.r(__webpack_exports__);
}


/***/ })
/***/ }

/******/ });
/************************************************************************/
Expand All @@ -420,6 +421,12 @@ __webpack_require__.r(__webpack_exports__);
/******/ if (cachedModule.error !== undefined) throw cachedModule.error;
/******/ return cachedModule.exports;
/******/ }
/******/ // Check if module exists (development only)
/******/ if (__webpack_modules__[moduleId] === undefined) {
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
/******/ e.code = 'MODULE_NOT_FOUND';
/******/ throw e;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ id: moduleId,
Expand Down Expand Up @@ -836,7 +843,8 @@ __webpack_require__.r(__webpack_exports__);
/******/ update.m,
/******/ promises,
/******/ currentUpdateApplyHandlers,
/******/ updatedModules
/******/ updatedModules,
/******/ update.css
/******/ );
/******/ return promises;
/******/ }, [])
Expand Down
30 changes: 19 additions & 11 deletions test/cases/hmr/expected/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({

/***/ "../../../src/hmr/hotModuleReplacement.js":
/***/ "../../../src/hmr/hotModuleReplacement.js"
/*!************************************************!*\
!*** ../../../src/hmr/hotModuleReplacement.js ***!
\************************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
(module, __unused_webpack_exports, __webpack_require__) {

/* global document */
/*
Expand All @@ -22,7 +22,7 @@ const noDocument = typeof document === "undefined";

const { forEach } = Array.prototype;

// eslint-disable-next-line jsdoc/no-restricted-syntax
/* eslint-disable jsdoc/reject-function-type */
/**
* @param {Function} fn any function
* @param {number} time time
Expand All @@ -47,6 +47,7 @@ function debounce(fn, time) {
timeout = setTimeout(functionCall, time);
};
}
/* eslint-enable jsdoc/reject-function-type */

/**
* @returns {void}
Expand Down Expand Up @@ -310,13 +311,13 @@ module.exports = function (moduleId, options) {
};


/***/ }),
/***/ },

/***/ "../../../src/hmr/normalize-url.js":
/***/ "../../../src/hmr/normalize-url.js"
/*!*****************************************!*\
!*** ../../../src/hmr/normalize-url.js ***!
\*****************************************/
/***/ ((module) => {
(module) {

/**
* @param {string[]} pathComponents path components
Expand Down Expand Up @@ -367,13 +368,13 @@ module.exports = function normalizeUrl(urlString) {
};


/***/ }),
/***/ },

/***/ "./index.css":
/***/ "./index.css"
/*!*******************!*\
!*** ./index.css ***!
\*******************/
/***/ ((module, __webpack_exports__, __webpack_require__) => {
(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
Expand Down Expand Up @@ -402,7 +403,7 @@ __webpack_require__.r(__webpack_exports__);
}


/***/ })
/***/ }

/******/ });
/************************************************************************/
Expand All @@ -417,6 +418,12 @@ __webpack_require__.r(__webpack_exports__);
/******/ if (cachedModule.error !== undefined) throw cachedModule.error;
/******/ return cachedModule.exports;
/******/ }
/******/ // Check if module exists (development only)
/******/ if (__webpack_modules__[moduleId] === undefined) {
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
/******/ e.code = 'MODULE_NOT_FOUND';
/******/ throw e;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ id: moduleId,
Expand Down Expand Up @@ -821,7 +828,8 @@ __webpack_require__.r(__webpack_exports__);
/******/ update.m,
/******/ promises,
/******/ currentUpdateApplyHandlers,
/******/ updatedModules
/******/ updatedModules,
/******/ update.css
/******/ );
/******/ return promises;
/******/ }, [])
Expand Down
Loading
Loading