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:
34
node_modules/webpack/lib/dependencies/CachedConstDependency.js
generated
vendored
Executable file → Normal file
34
node_modules/webpack/lib/dependencies/CachedConstDependency.js
generated
vendored
Executable file → Normal file
@@ -22,15 +22,22 @@ const NullDependency = require("./NullDependency");
|
||||
class CachedConstDependency extends NullDependency {
|
||||
/**
|
||||
* @param {string} expression expression
|
||||
* @param {Range} range range
|
||||
* @param {Range | null} range range
|
||||
* @param {string} identifier identifier
|
||||
* @param {number=} place place where we inject the expression
|
||||
*/
|
||||
constructor(expression, range, identifier) {
|
||||
constructor(
|
||||
expression,
|
||||
range,
|
||||
identifier,
|
||||
place = CachedConstDependency.PLACE_MODULE
|
||||
) {
|
||||
super();
|
||||
|
||||
this.expression = expression;
|
||||
this.range = range;
|
||||
this.identifier = identifier;
|
||||
this.place = place;
|
||||
this._hashUpdate = undefined;
|
||||
}
|
||||
|
||||
@@ -38,7 +45,7 @@ class CachedConstDependency extends NullDependency {
|
||||
* @returns {string} hash update
|
||||
*/
|
||||
_createHashUpdate() {
|
||||
return `${this.identifier}${this.range}${this.expression}`;
|
||||
return `${this.place}${this.identifier}${this.range}${this.expression}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,6 +70,7 @@ class CachedConstDependency extends NullDependency {
|
||||
write(this.expression);
|
||||
write(this.range);
|
||||
write(this.identifier);
|
||||
write(this.place);
|
||||
|
||||
super.serialize(context);
|
||||
}
|
||||
@@ -76,11 +84,15 @@ class CachedConstDependency extends NullDependency {
|
||||
this.expression = read();
|
||||
this.range = read();
|
||||
this.identifier = read();
|
||||
this.place = read();
|
||||
|
||||
super.deserialize(context);
|
||||
}
|
||||
}
|
||||
|
||||
CachedConstDependency.PLACE_MODULE = 10;
|
||||
CachedConstDependency.PLACE_CHUNK = 20;
|
||||
|
||||
makeSerializable(
|
||||
CachedConstDependency,
|
||||
"webpack/lib/dependencies/CachedConstDependency"
|
||||
@@ -95,25 +107,27 @@ CachedConstDependency.Template = class CachedConstDependencyTemplate extends (
|
||||
* @param {DependencyTemplateContext} templateContext the context object
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(dependency, source, { initFragments }) {
|
||||
apply(dependency, source, { initFragments, chunkInitFragments }) {
|
||||
const dep = /** @type {CachedConstDependency} */ (dependency);
|
||||
|
||||
initFragments.push(
|
||||
(dep.place === CachedConstDependency.PLACE_MODULE
|
||||
? initFragments
|
||||
: chunkInitFragments
|
||||
).push(
|
||||
new InitFragment(
|
||||
`var ${dep.identifier} = ${dep.expression};\n`,
|
||||
InitFragment.STAGE_CONSTANTS,
|
||||
0,
|
||||
// For a chunk we inject expression after imports
|
||||
dep.place === CachedConstDependency.PLACE_MODULE ? 0 : 10,
|
||||
`const ${dep.identifier}`
|
||||
)
|
||||
);
|
||||
|
||||
if (typeof dep.range === "number") {
|
||||
source.insert(dep.range, dep.identifier);
|
||||
|
||||
return;
|
||||
} else if (dep.range !== null) {
|
||||
source.replace(dep.range[0], dep.range[1] - 1, dep.identifier);
|
||||
}
|
||||
|
||||
source.replace(dep.range[0], dep.range[1] - 1, dep.identifier);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user