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:
+45
-66
@@ -22,12 +22,15 @@
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
/* eslint-disable no-undefined */
|
||||
|
||||
import estraverse from "estraverse";
|
||||
|
||||
import Reference from "./reference.js";
|
||||
import Variable from "./variable.js";
|
||||
import { Definition } from "./definition.js";
|
||||
import { assert } from "./assert.js";
|
||||
import assert from "assert";
|
||||
|
||||
const { Syntax } = estraverse;
|
||||
|
||||
@@ -36,9 +39,10 @@ const { Syntax } = estraverse;
|
||||
* @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.
|
||||
@@ -78,29 +82,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.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.ExpressionStatement) {
|
||||
break;
|
||||
}
|
||||
const expr = stmt.expression;
|
||||
|
||||
if (expr.type !== Syntax.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;
|
||||
}
|
||||
|
||||
@@ -157,8 +173,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();
|
||||
|
||||
/**
|
||||
@@ -249,7 +264,7 @@ class Scope {
|
||||
* @member {boolean} Scope#isStrict
|
||||
*/
|
||||
this.isStrict = scopeManager.isStrictModeSupported()
|
||||
? isStrictScope(this, block, isMethodDefinition)
|
||||
? isStrictScope(this, block, isMethodDefinition, scopeManager.__useDirective())
|
||||
: false;
|
||||
|
||||
/**
|
||||
@@ -337,7 +352,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;
|
||||
}
|
||||
|
||||
@@ -371,17 +386,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);
|
||||
}
|
||||
}
|
||||
@@ -421,7 +436,7 @@ class Scope {
|
||||
__referencing(node, assign, writeExpr, maybeImplicitGlobal, partial, init) {
|
||||
|
||||
// because Array element may be null
|
||||
if (!node || (node.type !== Syntax.Identifier && node.type !== "JSXIdentifier")) {
|
||||
if (!node || node.type !== Syntax.Identifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -488,7 +503,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;
|
||||
}
|
||||
|
||||
@@ -497,7 +512,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;
|
||||
}
|
||||
|
||||
@@ -514,9 +529,6 @@ class Scope {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Global scope.
|
||||
*/
|
||||
class GlobalScope extends Scope {
|
||||
constructor(scopeManager, block) {
|
||||
super(scopeManager, "global", null, block, false);
|
||||
@@ -578,18 +590,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);
|
||||
@@ -606,18 +612,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);
|
||||
@@ -640,27 +640,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);
|
||||
@@ -738,36 +729,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);
|
||||
|
||||
Reference in New Issue
Block a user