Skip to content

Commit 32fc223

Browse files
committed
move _START, _TIMEOUT -> _ST, _TO code from transform() to minify()
1 parent d7fa2cd commit 32fc223

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/processScript/minify.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ export async function minify(file: File, autocomplete?: string, {
4141
}
4242
})
4343

44+
if (program.scope.hasGlobal(`_START`)) {
45+
for (const referencePath of getReferencePathsToGlobal(`_START`, program))
46+
referencePath.replaceWith(t.identifier(`_ST`))
47+
}
48+
49+
if (program.scope.hasGlobal(`_TIMEOUT`)) {
50+
for (const referencePath of getReferencePathsToGlobal(`_TIMEOUT`, program))
51+
referencePath.replaceWith(t.identifier(`_TO`))
52+
}
53+
4454
// typescript does not like NodePath#get() and becomes slow so I have to dance around it
4555
const mainFunctionPath = program.get(`body.0` as string) as NodePath<FunctionDeclaration>
4656

src/processScript/transform.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,6 @@ export function transform(file: File, sourceCode: string, {
6161
}
6262
})
6363

64-
if (program.scope.hasGlobal(`_START`)) {
65-
for (const referencePath of getReferencePathsToGlobal(`_START`, program))
66-
referencePath.replaceWith(t.identifier(`_ST`))
67-
}
68-
69-
if (program.scope.hasGlobal(`_TIMEOUT`)) {
70-
for (const referencePath of getReferencePathsToGlobal(`_TIMEOUT`, program))
71-
referencePath.replaceWith(t.identifier(`_TO`))
72-
}
73-
7464
if (program.scope.hasGlobal(`_SOURCE`)) {
7565
for (const referencePath of getReferencePathsToGlobal(`_SOURCE`, program))
7666
referencePath.replaceWith(t.stringLiteral(sourceCode))

0 commit comments

Comments
 (0)