diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:10:59 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:41:44 +0800 |
| commit | fc87c009806dcc98867f6b58efe29b042aa01dee (patch) | |
| tree | 8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/babel-plugin-minify-dead-code-elimination/lib/remove-use-strict.js | |
| parent | 3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff) | |
node: updatemain
Diffstat (limited to 'node_modules/babel-plugin-minify-dead-code-elimination/lib/remove-use-strict.js')
| -rw-r--r-- | node_modules/babel-plugin-minify-dead-code-elimination/lib/remove-use-strict.js | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/node_modules/babel-plugin-minify-dead-code-elimination/lib/remove-use-strict.js b/node_modules/babel-plugin-minify-dead-code-elimination/lib/remove-use-strict.js deleted file mode 100644 index eb4cbe3a..00000000 --- a/node_modules/babel-plugin-minify-dead-code-elimination/lib/remove-use-strict.js +++ /dev/null @@ -1,48 +0,0 @@ -"use strict"; - -module.exports = removeUseStrict; -const newIssueUrl = "https://github.com/babel/minify/issues/new"; -const useStrict = "use strict"; -/** - * Remove redundant use strict - * If the parent has a "use strict" directive, it is not required in - * the children - * - * @param {NodePath} block BlockStatement - */ - -function removeUseStrict(block) { - if (!block.isBlockStatement()) { - throw new Error(`Received ${block.type}. Expected BlockStatement. ` + `Please report at ${newIssueUrl}`); - } - - const useStricts = getUseStrictDirectives(block); // early exit - - if (useStricts.length < 1) return; // only keep the first use strict - - if (useStricts.length > 1) { - for (let i = 1; i < useStricts.length; i++) { - useStricts[i].remove(); - } - } // check if parent has an use strict - - - if (hasStrictParent(block)) { - useStricts[0].remove(); - } -} - -function hasStrictParent(path) { - return path.findParent(parent => parent.isBlockStatement() && isStrict(parent)); -} - -function isStrict(block) { - return getUseStrictDirectives(block).length > 0; -} - -function getUseStrictDirectives(block) { - var dir = block.get("directives"); - return Array.isArray(dir) ? dir.filter(function (directive) { - return directive.node.value.value === useStrict; - }) : []; -}
\ No newline at end of file |
