Move entrypoint into its own directory
Lauren Tan committed
Jun 2, 2023 at 13:06 UTC
479ef4045b6080c155b2050802eab877a1a5b82a
8 files changed
+25
-26
compiler/forget/src/Babel/BabelPlugin.ts
+1
-2
@@ -9,8 +9,7 @@
9
10
import jsx from "@babel/plugin-syntax-jsx";
11
import type * as BabelCore from "@babel/core";
12
-import { compileProgram } from "../CompilerEntrypoint";
13
-import { parsePluginOptions } from "../CompilerOptions";
12
+import { compileProgram, parsePluginOptions } from "../Entrypoint";
13
14
/**
15
* The React Forget Babel Plugin
compiler/forget/src/Babel/RunReactForgetBabelPlugin.ts
+1
-1
@@ -11,7 +11,7 @@ import * as parser from "@babel/parser";
11
import invariant from "invariant";
12
import prettier from "prettier";
13
import ReactForgetBabelPlugin from "./BabelPlugin";
14
-import type { PluginOptions } from "../CompilerOptions";
14
+import type { PluginOptions } from "../Entrypoint";
15
16
type ReactForgetBabelPluginResult = {
17
ast: BabelCore.BabelFileResult["ast"];
compiler/forget/src/Entrypoint/Instrumentation.ts
renamed
compiler/forget/src/Entrypoint/Options.ts
renamed
+1
-1
@@ -5,7 +5,7 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-import { EnvironmentConfig } from "./HIR/Environment";
8
+import { EnvironmentConfig } from "../HIR/Environment";
9
10
export type ExternalFunction = {
11
/**
compiler/forget/src/Entrypoint/Pipeline.ts
renamed
+11
-11
@@ -18,17 +18,17 @@ import {
18
validateNoRefAccessInRender,
19
validateTerminalSuccessors,
20
validateUnconditionalHooks,
21
-} from "./HIR";
22
-import { Environment, EnvironmentConfig } from "./HIR/Environment";
23
-import { findContextIdentifiers } from "./HIR/FindContextIdentifiers";
21
+} from "../HIR";
22
+import { Environment, EnvironmentConfig } from "../HIR/Environment";
23
+import { findContextIdentifiers } from "../HIR/FindContextIdentifiers";
24
import {
25
analyseFunctions,
26
dropMemoCalls,
27
inferMutableRanges,
28
inferReferenceEffects,
29
inlineUseMemo,
30
-} from "./Inference";
31
-import { constantPropagation, deadCodeElimination } from "./Optimization";
30
+} from "../Inference";
31
+import { constantPropagation, deadCodeElimination } from "../Optimization";
32
import {
33
alignReactiveScopesToBlockScopes,
34
buildReactiveBlocks,
@@ -49,11 +49,11 @@ import {
49
pruneUnusedLValues,
50
pruneUnusedScopes,
51
renameVariables,
52
-} from "./ReactiveScopes";
53
-import { eliminateRedundantPhi, enterSSA, leaveSSA } from "./SSA";
54
-import { inferTypes } from "./TypeInference";
55
-import { logHIRFunction, logReactiveFunction } from "./Utils/logger";
56
-import { assertExhaustive } from "./Utils/utils";
52
+} from "../ReactiveScopes";
53
+import { eliminateRedundantPhi, enterSSA, leaveSSA } from "../SSA";
54
+import { inferTypes } from "../TypeInference";
55
+import { logHIRFunction, logReactiveFunction } from "../Utils/logger";
56
+import { assertExhaustive } from "../Utils/utils";
57
58
export type CompilerPipelineValue =
59
| { kind: "ast"; name: string; value: t.FunctionDeclaration }
@@ -263,7 +263,7 @@ export function* run(
263
return ast;
264
}
265
266
-export function compile(
266
+export function compileFn(
267
func: NodePath<t.FunctionDeclaration>,
268
options?: Partial<EnvironmentConfig> | null
269
): t.FunctionDeclaration {
compiler/forget/src/Entrypoint/Program.ts
renamed
+6
-10
@@ -11,15 +11,11 @@ import {
11
CompilerError,
12
CompilerErrorDetail,
13
ErrorSeverity,
14
-} from "./CompilerError";
15
-import { compile } from "./CompilerPipeline";
16
-import { GeneratedSource } from "./HIR";
17
-import { addInstrumentForget } from "./CompilerInstrumentation";
18
-import {
19
- ExternalFunction,
20
- PluginOptions,
21
- parsePluginOptions,
22
-} from "./CompilerOptions";
14
+} from "../CompilerError";
15
+import { compileFn } from "./Pipeline";
16
+import { GeneratedSource } from "../HIR";
17
+import { addInstrumentForget } from "./Instrumentation";
18
+import { ExternalFunction, PluginOptions, parsePluginOptions } from "./Options";
19
20
export type CompilerPass = {
21
opts: PluginOptions;
@@ -51,7 +47,7 @@ export function compileProgram(
47
pass: CompilerPass
48
): void {
49
try {
54
- const compiled = compile(fn, pass.opts.environment);
50
+ const compiled = compileFn(fn, pass.opts.environment);
51
if (fn.node.id == null) {
52
CompilerError.invariant(
53
"FunctionDeclaration must have a name",
compiler/forget/src/Entrypoint/index.ts
new
+4
@@ -0,0 +1,4 @@
1
+export * from "./Program";
2
+export * from "./Instrumentation";
3
+export * from "./Options";
4
+export * from "./Pipeline";
compiler/forget/src/index.ts
+1
-1
@@ -11,7 +11,7 @@ export {
11
CompilerErrorDetail,
12
ErrorSeverity,
13
} from "./CompilerError";
14
-export { CompilerPipelineValue, compile, run } from "./CompilerPipeline";
14
+export { CompilerPipelineValue, compileFn as compile, run } from "./Entrypoint";
15
export { Effect, Hook, ValueKind, printHIR } from "./HIR";
16
export { printReactiveFunction } from "./ReactiveScopes";
17