MCPcopy
hub / github.com/webpack/webpack / detectMode

Method detectMode

lib/javascript/JavascriptParser.js:4702–4717  ·  view source on GitHub ↗

* Processes the provided statement. * @param {(Directive | Statement | ModuleDeclaration)[]} statements statements

(statements)

Source from the content-addressed store, hash-verified

4700 * @param {(Directive | Statement | ModuleDeclaration)[]} statements statements
4701 */
4702 detectMode(statements) {
4703 const statement = statements.length >= 1 ? statements[0] : undefined;
4704 if (
4705 statement === undefined ||
4706 statement.type !== "ExpressionStatement" ||
4707 statement.expression.type !== "Literal"
4708 ) {
4709 return;
4710 }
4711 const value = /** @type {Literal} */ (statement.expression).value;
4712 if (value === "use strict") {
4713 this.scope.isStrict = true;
4714 } else if (value === "use asm") {
4715 this.scope.isAsmJs = true;
4716 }
4717 }
4718
4719 /**
4720 * Processes the provided pattern.

Callers 7

_walkIIFEMethod · 0.95
parseMethod · 0.95
processCallDefineMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected