Add JS-CATCH-FALLBACK-01 rule and update npm packages
Add PHP-ALIAS-01 rule: prohibit field aliasing in serialization 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
50
node_modules/webpack/lib/css/CssGenerator.js
generated
vendored
50
node_modules/webpack/lib/css/CssGenerator.js
generated
vendored
@@ -12,10 +12,10 @@ const InitFragment = require("../InitFragment");
|
||||
const {
|
||||
CSS_TYPE,
|
||||
CSS_TYPES,
|
||||
JS_AND_CSS_TYPES,
|
||||
JS_TYPE,
|
||||
JS_TYPES
|
||||
} = require("../ModuleSourceTypesConstants");
|
||||
JAVASCRIPT_AND_CSS_TYPES,
|
||||
JAVASCRIPT_TYPE,
|
||||
JAVASCRIPT_TYPES
|
||||
} = require("../ModuleSourceTypeConstants");
|
||||
const RuntimeGlobals = require("../RuntimeGlobals");
|
||||
const Template = require("../Template");
|
||||
const CssImportDependency = require("../dependencies/CssImportDependency");
|
||||
@@ -23,8 +23,6 @@ const { getUndoPath } = require("../util/identifier");
|
||||
const memoize = require("../util/memoize");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssAutoGeneratorOptions} CssAutoGeneratorOptions */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssGlobalGeneratorOptions} CssGlobalGeneratorOptions */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */
|
||||
/** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
|
||||
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
||||
@@ -36,6 +34,7 @@ const memoize = require("../util/memoize");
|
||||
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
||||
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
||||
/** @typedef {import("../Module").SourceType} SourceType */
|
||||
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../NormalModule")} NormalModule */
|
||||
@@ -51,13 +50,12 @@ const getCssModulesPlugin = memoize(() => require("./CssModulesPlugin"));
|
||||
|
||||
class CssGenerator extends Generator {
|
||||
/**
|
||||
* @param {CssAutoGeneratorOptions | CssGlobalGeneratorOptions | CssModuleGeneratorOptions} options options
|
||||
* @param {CssModuleGeneratorOptions} options options
|
||||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
*/
|
||||
constructor(options, moduleGraph) {
|
||||
super();
|
||||
this.convention = options.exportsConvention;
|
||||
this.localIdentName = options.localIdentName;
|
||||
this.options = options;
|
||||
this._exportsOnly = options.exportsOnly;
|
||||
this._esModule = options.esModule;
|
||||
this._moduleGraph = moduleGraph;
|
||||
@@ -127,7 +125,7 @@ class CssGenerator extends Generator {
|
||||
const moduleSourceContent = /** @type {Source} */ (
|
||||
this.generate(module, {
|
||||
...generateContext,
|
||||
type: "css"
|
||||
type: CSS_TYPE
|
||||
})
|
||||
);
|
||||
|
||||
@@ -266,7 +264,7 @@ class CssGenerator extends Generator {
|
||||
generate(module, generateContext) {
|
||||
const exportType = /** @type {BuildMeta} */ (module.buildMeta).exportType;
|
||||
const source =
|
||||
generateContext.type === "javascript"
|
||||
generateContext.type === JAVASCRIPT_TYPE
|
||||
? exportType === "link"
|
||||
? new ReplaceSource(new RawSource(""))
|
||||
: new ReplaceSource(/** @type {Source} */ (module.originalSource()))
|
||||
@@ -330,7 +328,7 @@ class CssGenerator extends Generator {
|
||||
};
|
||||
|
||||
switch (generateContext.type) {
|
||||
case "javascript": {
|
||||
case JAVASCRIPT_TYPE: {
|
||||
const isCSSModule = /** @type {BuildMeta} */ (module.buildMeta)
|
||||
.isCSSModule;
|
||||
const defaultExport = generateJSDefaultExport();
|
||||
@@ -374,14 +372,15 @@ class CssGenerator extends Generator {
|
||||
if (!usedName) {
|
||||
continue;
|
||||
}
|
||||
let identifier = Template.toIdentifier(usedName);
|
||||
|
||||
let identifier = Template.toIdentifier(usedName);
|
||||
if (RESERVED_IDENTIFIER.has(identifier)) {
|
||||
identifier = `_${identifier}`;
|
||||
}
|
||||
const i = 0;
|
||||
let i = 0;
|
||||
while (usedIdentifiers.has(identifier)) {
|
||||
identifier = Template.toIdentifier(name + i);
|
||||
i += 1;
|
||||
}
|
||||
usedIdentifiers.add(identifier);
|
||||
generateContext.concatenationScope.registerExport(name, identifier);
|
||||
@@ -428,7 +427,7 @@ class CssGenerator extends Generator {
|
||||
}.exports = {\n${exports.join(",\n")}\n}${needNsObj ? ")" : ""};`
|
||||
);
|
||||
}
|
||||
case "css": {
|
||||
case CSS_TYPE: {
|
||||
if (!this._generatesJsOnly(module)) {
|
||||
generateContext.runtimeRequirements.add(RuntimeGlobals.hasCssModules);
|
||||
}
|
||||
@@ -448,12 +447,12 @@ class CssGenerator extends Generator {
|
||||
*/
|
||||
generateError(error, module, generateContext) {
|
||||
switch (generateContext.type) {
|
||||
case "javascript": {
|
||||
case JAVASCRIPT_TYPE: {
|
||||
return new RawSource(
|
||||
`throw new Error(${JSON.stringify(error.message)});`
|
||||
);
|
||||
}
|
||||
case "css": {
|
||||
case CSS_TYPE: {
|
||||
return new RawSource(`/**\n ${error.message} \n**/`);
|
||||
}
|
||||
default:
|
||||
@@ -467,32 +466,35 @@ class CssGenerator extends Generator {
|
||||
*/
|
||||
getTypes(module) {
|
||||
if (this._generatesJsOnly(module)) {
|
||||
return JS_TYPES;
|
||||
return JAVASCRIPT_TYPES;
|
||||
}
|
||||
const sourceTypes = new Set();
|
||||
const connections = this._moduleGraph.getIncomingConnections(module);
|
||||
for (const connection of connections) {
|
||||
if (connection.dependency instanceof CssImportDependency) {
|
||||
continue;
|
||||
}
|
||||
if (!connection.originModule) {
|
||||
continue;
|
||||
}
|
||||
if (connection.originModule.type.split("/")[0] !== CSS_TYPE) {
|
||||
sourceTypes.add(JS_TYPE);
|
||||
sourceTypes.add(JAVASCRIPT_TYPE);
|
||||
}
|
||||
}
|
||||
if (sourceTypes.has(JS_TYPE)) {
|
||||
return JS_AND_CSS_TYPES;
|
||||
if (sourceTypes.has(JAVASCRIPT_TYPE)) {
|
||||
return JAVASCRIPT_AND_CSS_TYPES;
|
||||
}
|
||||
return CSS_TYPES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {NormalModule} module the module
|
||||
* @param {string=} type source type
|
||||
* @param {SourceType=} type source type
|
||||
* @returns {number} estimate size of the module
|
||||
*/
|
||||
getSize(module, type) {
|
||||
switch (type) {
|
||||
case "javascript": {
|
||||
case JAVASCRIPT_TYPE: {
|
||||
const cssData = /** @type {BuildInfo} */ (module.buildInfo).cssData;
|
||||
if (!cssData) {
|
||||
return 42;
|
||||
@@ -513,7 +515,7 @@ class CssGenerator extends Generator {
|
||||
|
||||
return stringifiedExports.length + 42;
|
||||
}
|
||||
case "css": {
|
||||
case CSS_TYPE: {
|
||||
const originalSource = module.originalSource();
|
||||
|
||||
if (!originalSource) {
|
||||
|
||||
Reference in New Issue
Block a user