build: update npm install command to use --legacy-peer-deps
This change modifies the build scripts to use --legacy-peer-deps flag when installing npm dependencies to resolve potential peer dependency conflicts during the build process. The change is applied to both bash (build.sh) and batch (build.bat) build scripts.
This commit is contained in:
+70
-169
@@ -2,32 +2,16 @@
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var assert = require('assert');
|
||||
var estraverse = require('estraverse');
|
||||
var esrecurse = require('esrecurse');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
|
||||
var estraverse__default = /*#__PURE__*/_interopDefaultLegacy(estraverse);
|
||||
var esrecurse__default = /*#__PURE__*/_interopDefaultLegacy(esrecurse);
|
||||
|
||||
/**
|
||||
* @fileoverview Assertion utilities.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
/**
|
||||
* Throws an error if the given condition is not truthy.
|
||||
* @param {boolean} condition The condition to check.
|
||||
* @param {string} message The message to include with the error.
|
||||
* @returns {void}
|
||||
* @throws {Error} When the condition is not truthy.
|
||||
*/
|
||||
function assert(condition, message = "Assertion failed.") {
|
||||
if (!condition) {
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
|
||||
@@ -389,9 +373,10 @@ const { Syntax: Syntax$2 } = estraverse__default["default"];
|
||||
* @param {Scope} scope scope
|
||||
* @param {Block} block block
|
||||
* @param {boolean} isMethodDefinition is method definition
|
||||
* @param {boolean} useDirective use directive
|
||||
* @returns {boolean} is strict scope
|
||||
*/
|
||||
function isStrictScope(scope, block, isMethodDefinition) {
|
||||
function isStrictScope(scope, block, isMethodDefinition, useDirective) {
|
||||
let body;
|
||||
|
||||
// When upper scope is exists and strict, inner scope is also strict.
|
||||
@@ -431,29 +416,41 @@ function isStrictScope(scope, block, isMethodDefinition) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Search for a 'use strict' directive.
|
||||
for (let i = 0, iz = body.body.length; i < iz; ++i) {
|
||||
const stmt = body.body[i];
|
||||
// Search 'use strict' directive.
|
||||
if (useDirective) {
|
||||
for (let i = 0, iz = body.body.length; i < iz; ++i) {
|
||||
const stmt = body.body[i];
|
||||
|
||||
/*
|
||||
* Check if the current statement is a directive.
|
||||
* If it isn't, then we're past the directive prologue
|
||||
* so stop the search because directives cannot
|
||||
* appear after this point.
|
||||
*
|
||||
* Some parsers set `directive:null` on non-directive
|
||||
* statements, so the `typeof` check is safer than
|
||||
* checking for property existence.
|
||||
*/
|
||||
if (typeof stmt.directive !== "string") {
|
||||
break;
|
||||
if (stmt.type !== Syntax$2.DirectiveStatement) {
|
||||
break;
|
||||
}
|
||||
if (stmt.raw === "\"use strict\"" || stmt.raw === "'use strict'") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let i = 0, iz = body.body.length; i < iz; ++i) {
|
||||
const stmt = body.body[i];
|
||||
|
||||
if (stmt.directive === "use strict") {
|
||||
return true;
|
||||
if (stmt.type !== Syntax$2.ExpressionStatement) {
|
||||
break;
|
||||
}
|
||||
const expr = stmt.expression;
|
||||
|
||||
if (expr.type !== Syntax$2.Literal || typeof expr.value !== "string") {
|
||||
break;
|
||||
}
|
||||
if (expr.raw !== null && expr.raw !== undefined) {
|
||||
if (expr.raw === "\"use strict\"" || expr.raw === "'use strict'") {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (expr.value === "use strict") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -510,8 +507,7 @@ class Scope {
|
||||
/**
|
||||
* The tainted variables of this scope, as <code>{ Variable.name :
|
||||
* boolean }</code>.
|
||||
* @member {Map} Scope#taints
|
||||
*/
|
||||
* @member {Map} Scope#taints */
|
||||
this.taints = new Map();
|
||||
|
||||
/**
|
||||
@@ -602,7 +598,7 @@ class Scope {
|
||||
* @member {boolean} Scope#isStrict
|
||||
*/
|
||||
this.isStrict = scopeManager.isStrictModeSupported()
|
||||
? isStrictScope(this, block, isMethodDefinition)
|
||||
? isStrictScope(this, block, isMethodDefinition, scopeManager.__useDirective())
|
||||
: false;
|
||||
|
||||
/**
|
||||
@@ -690,7 +686,7 @@ class Scope {
|
||||
|
||||
// To override by function scopes.
|
||||
// References in default parameters isn't resolved to variables which are in their function body.
|
||||
__isValidResolution(ref, variable) { // eslint-disable-line class-methods-use-this, no-unused-vars -- Desired as instance method with signature
|
||||
__isValidResolution(ref, variable) { // eslint-disable-line class-methods-use-this, no-unused-vars
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -724,17 +720,17 @@ class Scope {
|
||||
}
|
||||
|
||||
__addDeclaredVariablesOfNode(variable, node) {
|
||||
if (node === null || node === void 0) {
|
||||
if (node === null || node === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
let variables = this.__declaredVariables.get(node);
|
||||
|
||||
if (variables === null || variables === void 0) {
|
||||
if (variables === null || variables === undefined) {
|
||||
variables = [];
|
||||
this.__declaredVariables.set(node, variables);
|
||||
}
|
||||
if (!variables.includes(variable)) {
|
||||
if (variables.indexOf(variable) === -1) {
|
||||
variables.push(variable);
|
||||
}
|
||||
}
|
||||
@@ -774,7 +770,7 @@ class Scope {
|
||||
__referencing(node, assign, writeExpr, maybeImplicitGlobal, partial, init) {
|
||||
|
||||
// because Array element may be null
|
||||
if (!node || (node.type !== Syntax$2.Identifier && node.type !== "JSXIdentifier")) {
|
||||
if (!node || node.type !== Syntax$2.Identifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -816,8 +812,8 @@ class Scope {
|
||||
resolve(ident) {
|
||||
let ref, i, iz;
|
||||
|
||||
assert(this.__isClosed(), "Scope should be closed.");
|
||||
assert(ident.type === Syntax$2.Identifier, "Target should be identifier.");
|
||||
assert__default["default"](this.__isClosed(), "Scope should be closed.");
|
||||
assert__default["default"](ident.type === Syntax$2.Identifier, "Target should be identifier.");
|
||||
for (i = 0, iz = this.references.length; i < iz; ++i) {
|
||||
ref = this.references[i];
|
||||
if (ref.identifier === ident) {
|
||||
@@ -841,7 +837,7 @@ class Scope {
|
||||
* @function Scope#isArgumentsMaterialized
|
||||
* @returns {boolean} arguemnts materialized
|
||||
*/
|
||||
isArgumentsMaterialized() { // eslint-disable-line class-methods-use-this -- Desired as instance method
|
||||
isArgumentsMaterialized() { // eslint-disable-line class-methods-use-this
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -850,7 +846,7 @@ class Scope {
|
||||
* @function Scope#isThisMaterialized
|
||||
* @returns {boolean} this materialized
|
||||
*/
|
||||
isThisMaterialized() { // eslint-disable-line class-methods-use-this -- Desired as instance method
|
||||
isThisMaterialized() { // eslint-disable-line class-methods-use-this
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -867,9 +863,6 @@ class Scope {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Global scope.
|
||||
*/
|
||||
class GlobalScope extends Scope {
|
||||
constructor(scopeManager, block) {
|
||||
super(scopeManager, "global", null, block, false);
|
||||
@@ -931,18 +924,12 @@ class GlobalScope extends Scope {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Module scope.
|
||||
*/
|
||||
class ModuleScope extends Scope {
|
||||
constructor(scopeManager, upperScope, block) {
|
||||
super(scopeManager, "module", upperScope, block, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function expression name scope.
|
||||
*/
|
||||
class FunctionExpressionNameScope extends Scope {
|
||||
constructor(scopeManager, upperScope, block) {
|
||||
super(scopeManager, "function-expression-name", upperScope, block, false);
|
||||
@@ -959,18 +946,12 @@ class FunctionExpressionNameScope extends Scope {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Catch scope.
|
||||
*/
|
||||
class CatchScope extends Scope {
|
||||
constructor(scopeManager, upperScope, block) {
|
||||
super(scopeManager, "catch", upperScope, block, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* With statement scope.
|
||||
*/
|
||||
class WithScope extends Scope {
|
||||
constructor(scopeManager, upperScope, block) {
|
||||
super(scopeManager, "with", upperScope, block, false);
|
||||
@@ -993,27 +974,18 @@ class WithScope extends Scope {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Block scope.
|
||||
*/
|
||||
class BlockScope extends Scope {
|
||||
constructor(scopeManager, upperScope, block) {
|
||||
super(scopeManager, "block", upperScope, block, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch scope.
|
||||
*/
|
||||
class SwitchScope extends Scope {
|
||||
constructor(scopeManager, upperScope, block) {
|
||||
super(scopeManager, "switch", upperScope, block, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function scope.
|
||||
*/
|
||||
class FunctionScope extends Scope {
|
||||
constructor(scopeManager, upperScope, block, isMethodDefinition) {
|
||||
super(scopeManager, "function", upperScope, block, isMethodDefinition);
|
||||
@@ -1045,7 +1017,7 @@ class FunctionScope extends Scope {
|
||||
|
||||
const variable = this.set.get("arguments");
|
||||
|
||||
assert(variable, "Always have arguments variable.");
|
||||
assert__default["default"](variable, "Always have arguments variable.");
|
||||
return variable.tainted || variable.references.length !== 0;
|
||||
}
|
||||
|
||||
@@ -1091,36 +1063,24 @@ class FunctionScope extends Scope {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope of for, for-in, and for-of statements.
|
||||
*/
|
||||
class ForScope extends Scope {
|
||||
constructor(scopeManager, upperScope, block) {
|
||||
super(scopeManager, "for", upperScope, block, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class scope.
|
||||
*/
|
||||
class ClassScope extends Scope {
|
||||
constructor(scopeManager, upperScope, block) {
|
||||
super(scopeManager, "class", upperScope, block, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class field initializer scope.
|
||||
*/
|
||||
class ClassFieldInitializerScope extends Scope {
|
||||
constructor(scopeManager, upperScope, block) {
|
||||
super(scopeManager, "class-field-initializer", upperScope, block, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class static block scope.
|
||||
*/
|
||||
class ClassStaticBlockScope extends Scope {
|
||||
constructor(scopeManager, upperScope, block) {
|
||||
super(scopeManager, "class-static-block", upperScope, block, true);
|
||||
@@ -1166,6 +1126,10 @@ class ScopeManager {
|
||||
this.__declaredVariables = new WeakMap();
|
||||
}
|
||||
|
||||
__useDirective() {
|
||||
return this.__options.directive;
|
||||
}
|
||||
|
||||
__isOptimistic() {
|
||||
return this.__options.optimistic;
|
||||
}
|
||||
@@ -1174,10 +1138,6 @@ class ScopeManager {
|
||||
return this.__options.ignoreEval;
|
||||
}
|
||||
|
||||
__isJSXEnabled() {
|
||||
return this.__options.jsx === true;
|
||||
}
|
||||
|
||||
isGlobalReturn() {
|
||||
return this.__options.nodejsScope || this.__options.sourceType === "commonjs";
|
||||
}
|
||||
@@ -1297,13 +1257,13 @@ class ScopeManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
attach() { } // eslint-disable-line class-methods-use-this -- Desired as instance method
|
||||
attach() { } // eslint-disable-line class-methods-use-this
|
||||
|
||||
detach() { } // eslint-disable-line class-methods-use-this -- Desired as instance method
|
||||
detach() { } // eslint-disable-line class-methods-use-this
|
||||
|
||||
__nestScope(scope) {
|
||||
if (scope instanceof GlobalScope) {
|
||||
assert(this.__currentScope === null);
|
||||
assert__default["default"](this.__currentScope === null);
|
||||
this.globalScope = scope;
|
||||
}
|
||||
this.__currentScope = scope;
|
||||
@@ -1397,12 +1357,9 @@ const { Syntax: Syntax$1 } = estraverse__default["default"];
|
||||
* @returns {any} Last elment
|
||||
*/
|
||||
function getLast(xs) {
|
||||
return xs.at(-1) || null;
|
||||
return xs[xs.length - 1] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visitor for destructuring patterns.
|
||||
*/
|
||||
class PatternVisitor extends esrecurse__default["default"].Visitor {
|
||||
static isPattern(node) {
|
||||
const nodeType = node.type;
|
||||
@@ -1431,7 +1388,7 @@ class PatternVisitor extends esrecurse__default["default"].Visitor {
|
||||
|
||||
this.callback(pattern, {
|
||||
topLevel: pattern === this.rootPattern,
|
||||
rest: lastRestElement !== null && lastRestElement !== void 0 && lastRestElement.argument === pattern,
|
||||
rest: lastRestElement !== null && lastRestElement !== undefined && lastRestElement.argument === pattern,
|
||||
assignments: this.assignments
|
||||
});
|
||||
}
|
||||
@@ -1557,7 +1514,7 @@ function traverseIdentifierInPattern(options, rootPattern, referencer, callback)
|
||||
visitor.visit(rootPattern);
|
||||
|
||||
// Process the right hand nodes recursively.
|
||||
if (referencer !== null && referencer !== void 0) {
|
||||
if (referencer !== null && referencer !== undefined) {
|
||||
visitor.rightHandNodes.forEach(referencer.visit, referencer);
|
||||
}
|
||||
}
|
||||
@@ -1568,9 +1525,6 @@ function traverseIdentifierInPattern(options, rootPattern, referencer, callback)
|
||||
// FIXME: Now, we don't create module environment, because the context is
|
||||
// implementation dependent.
|
||||
|
||||
/**
|
||||
* Visitor for import specifiers.
|
||||
*/
|
||||
class Importer extends esrecurse__default["default"].Visitor {
|
||||
constructor(declaration, referencer) {
|
||||
super(null, referencer.options);
|
||||
@@ -1617,9 +1571,7 @@ class Importer extends esrecurse__default["default"].Visitor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Referencing variables and creating bindings.
|
||||
*/
|
||||
// Referencing variables and creating bindings.
|
||||
class Referencer extends esrecurse__default["default"].Visitor {
|
||||
constructor(options, scopeManager) {
|
||||
super(null, options);
|
||||
@@ -1783,6 +1735,8 @@ class Referencer extends esrecurse__default["default"].Visitor {
|
||||
));
|
||||
}
|
||||
|
||||
this.visit(node.superClass);
|
||||
|
||||
this.scopeManager.__nestClassScope(node);
|
||||
|
||||
if (node.id) {
|
||||
@@ -1793,8 +1747,6 @@ class Referencer extends esrecurse__default["default"].Visitor {
|
||||
node
|
||||
));
|
||||
}
|
||||
|
||||
this.visit(node.superClass);
|
||||
this.visit(node.body);
|
||||
|
||||
this.close(node);
|
||||
@@ -1904,7 +1856,7 @@ class Referencer extends esrecurse__default["default"].Visitor {
|
||||
this.currentScope().__define(pattern,
|
||||
new Definition(
|
||||
Variable.CatchClause,
|
||||
pattern,
|
||||
node.param,
|
||||
node,
|
||||
null,
|
||||
null,
|
||||
@@ -1943,7 +1895,7 @@ class Referencer extends esrecurse__default["default"].Visitor {
|
||||
this.currentScope().__referencing(node);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line class-methods-use-this -- Desired as instance method
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
PrivateIdentifier() {
|
||||
|
||||
// Do nothing.
|
||||
@@ -1993,9 +1945,9 @@ class Referencer extends esrecurse__default["default"].Visitor {
|
||||
this.visitProperty(node);
|
||||
}
|
||||
|
||||
BreakStatement() {} // eslint-disable-line class-methods-use-this -- Desired as instance method
|
||||
BreakStatement() {} // eslint-disable-line class-methods-use-this
|
||||
|
||||
ContinueStatement() {} // eslint-disable-line class-methods-use-this -- Desired as instance method
|
||||
ContinueStatement() {} // eslint-disable-line class-methods-use-this
|
||||
|
||||
LabeledStatement(node) {
|
||||
this.visit(node.body);
|
||||
@@ -2110,7 +2062,7 @@ class Referencer extends esrecurse__default["default"].Visitor {
|
||||
}
|
||||
|
||||
ImportDeclaration(node) {
|
||||
assert(this.scopeManager.__isES6() && this.scopeManager.isModule(), "ImportDeclaration should appear when the mode is ES6 and in the module context.");
|
||||
assert__default["default"](this.scopeManager.__isES6() && this.scopeManager.isModule(), "ImportDeclaration should appear when the mode is ES6 and in the module context.");
|
||||
|
||||
const importer = new Importer(node, this);
|
||||
|
||||
@@ -2154,67 +2106,15 @@ class Referencer extends esrecurse__default["default"].Visitor {
|
||||
this.visit(local);
|
||||
}
|
||||
|
||||
MetaProperty() { // eslint-disable-line class-methods-use-this -- Desired as instance method
|
||||
MetaProperty() { // eslint-disable-line class-methods-use-this
|
||||
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
JSXIdentifier(node) {
|
||||
|
||||
// Special case: "this" should not count as a reference
|
||||
if (this.scopeManager.__isJSXEnabled() && node.name !== "this") {
|
||||
this.currentScope().__referencing(node);
|
||||
}
|
||||
}
|
||||
|
||||
JSXMemberExpression(node) {
|
||||
this.visit(node.object);
|
||||
}
|
||||
|
||||
JSXElement(node) {
|
||||
if (this.scopeManager.__isJSXEnabled()) {
|
||||
this.visit(node.openingElement);
|
||||
node.children.forEach(this.visit, this);
|
||||
} else {
|
||||
this.visitChildren(node);
|
||||
}
|
||||
}
|
||||
|
||||
JSXOpeningElement(node) {
|
||||
if (this.scopeManager.__isJSXEnabled()) {
|
||||
|
||||
const nameNode = node.name;
|
||||
const isComponentName = nameNode.type === "JSXIdentifier" && nameNode.name[0].toUpperCase() === nameNode.name[0];
|
||||
const isComponent = isComponentName || nameNode.type === "JSXMemberExpression";
|
||||
|
||||
// we only want to visit JSXIdentifier nodes if they are capitalized
|
||||
if (isComponent) {
|
||||
this.visit(nameNode);
|
||||
}
|
||||
}
|
||||
|
||||
node.attributes.forEach(this.visit, this);
|
||||
}
|
||||
|
||||
JSXAttribute(node) {
|
||||
if (node.value) {
|
||||
this.visit(node.value);
|
||||
}
|
||||
}
|
||||
|
||||
JSXExpressionContainer(node) {
|
||||
this.visit(node.expression);
|
||||
}
|
||||
|
||||
JSXNamespacedName(node) {
|
||||
this.visit(node.namespace);
|
||||
this.visit(node.name);
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set sw=4 ts=4 et tw=80 : */
|
||||
|
||||
const version = "8.4.0";
|
||||
const version = "7.2.2";
|
||||
|
||||
/*
|
||||
Copyright (C) 2012-2014 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
@@ -2249,6 +2149,7 @@ const version = "8.4.0";
|
||||
function defaultOptions() {
|
||||
return {
|
||||
optimistic: false,
|
||||
directive: false,
|
||||
nodejsScope: false,
|
||||
impliedStrict: false,
|
||||
sourceType: "script", // one of ['script', 'module', 'commonjs']
|
||||
@@ -2276,7 +2177,7 @@ function updateDeeply(target, override) {
|
||||
}
|
||||
|
||||
for (const key in override) {
|
||||
if (Object.hasOwn(override, key)) {
|
||||
if (Object.prototype.hasOwnProperty.call(override, key)) {
|
||||
const val = override[key];
|
||||
|
||||
if (isHashObject(val)) {
|
||||
@@ -2300,6 +2201,7 @@ function updateDeeply(target, override) {
|
||||
* @param {espree.Tree} tree Abstract Syntax Tree
|
||||
* @param {Object} providedOptions Options that tailor the scope analysis
|
||||
* @param {boolean} [providedOptions.optimistic=false] the optimistic flag
|
||||
* @param {boolean} [providedOptions.directive=false] the directive flag
|
||||
* @param {boolean} [providedOptions.ignoreEval=false] whether to check 'eval()' calls
|
||||
* @param {boolean} [providedOptions.nodejsScope=false] whether the whole
|
||||
* script is executed under node.js environment. When enabled, escope adds
|
||||
@@ -2308,7 +2210,6 @@ function updateDeeply(target, override) {
|
||||
* (if ecmaVersion >= 5).
|
||||
* @param {string} [providedOptions.sourceType='script'] the source type of the script. one of 'script', 'module', and 'commonjs'
|
||||
* @param {number} [providedOptions.ecmaVersion=5] which ECMAScript version is considered
|
||||
* @param {boolean} [providedOptions.jsx=false] support JSX references
|
||||
* @param {Object} [providedOptions.childVisitorKeys=null] Additional known visitor keys. See [esrecurse](https://github.com/estools/esrecurse)'s the `childVisitorKeys` option.
|
||||
* @param {string} [providedOptions.fallback='iteration'] A kind of the fallback in order to encounter with unknown node. See [esrecurse](https://github.com/estools/esrecurse)'s the `fallback` option.
|
||||
* @returns {ScopeManager} ScopeManager
|
||||
@@ -2320,7 +2221,7 @@ function analyze(tree, providedOptions) {
|
||||
|
||||
referencer.visit(tree);
|
||||
|
||||
assert(scopeManager.__currentScope === null, "currentScope should be null.");
|
||||
assert__default["default"](scopeManager.__currentScope === null, "currentScope should be null.");
|
||||
|
||||
return scopeManager;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user