Debian Codegraph @

packages/babel-plugin-transform-strict-mode/src/index.ts

raw
1 import { declare } from "@babel/helper-plugin-utils";
2 import { types as t } from "@babel/core";
3
4 export default declare(api => {
5 api.assertVersion(7);
6
7 return {
8 name: "transform-strict-mode",
9
10 visitor: {
11 Program(path) {
12 const { node } = path;
13
14 for (const directive of node.directives) {
15 if (directive.value.value === "use strict") return;
16 }
17
18 path.unshiftContainer(
19 "directives",
20 t.directive(t.directiveLiteral("use strict")),
21 );
22 },
23 },
24 };
25 });