mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Move entrypoint into its own directory
This commit is contained in:
@@ -9,8 +9,7 @@
|
||||
|
||||
import jsx from "@babel/plugin-syntax-jsx";
|
||||
import type * as BabelCore from "@babel/core";
|
||||
import { compileProgram } from "../CompilerEntrypoint";
|
||||
import { parsePluginOptions } from "../CompilerOptions";
|
||||
import { compileProgram, parsePluginOptions } from "../Entrypoint";
|
||||
|
||||
/**
|
||||
* The React Forget Babel Plugin
|
||||
|
||||
@@ -11,7 +11,7 @@ import * as parser from "@babel/parser";
|
||||
import invariant from "invariant";
|
||||
import prettier from "prettier";
|
||||
import ReactForgetBabelPlugin from "./BabelPlugin";
|
||||
import type { PluginOptions } from "../CompilerOptions";
|
||||
import type { PluginOptions } from "../Entrypoint";
|
||||
|
||||
type ReactForgetBabelPluginResult = {
|
||||
ast: BabelCore.BabelFileResult["ast"];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import { EnvironmentConfig } from "./HIR/Environment";
|
||||
import { EnvironmentConfig } from "../HIR/Environment";
|
||||
|
||||
export type ExternalFunction = {
|
||||
/**
|
||||
+11
-11
@@ -18,17 +18,17 @@ import {
|
||||
validateNoRefAccessInRender,
|
||||
validateTerminalSuccessors,
|
||||
validateUnconditionalHooks,
|
||||
} from "./HIR";
|
||||
import { Environment, EnvironmentConfig } from "./HIR/Environment";
|
||||
import { findContextIdentifiers } from "./HIR/FindContextIdentifiers";
|
||||
} from "../HIR";
|
||||
import { Environment, EnvironmentConfig } from "../HIR/Environment";
|
||||
import { findContextIdentifiers } from "../HIR/FindContextIdentifiers";
|
||||
import {
|
||||
analyseFunctions,
|
||||
dropMemoCalls,
|
||||
inferMutableRanges,
|
||||
inferReferenceEffects,
|
||||
inlineUseMemo,
|
||||
} from "./Inference";
|
||||
import { constantPropagation, deadCodeElimination } from "./Optimization";
|
||||
} from "../Inference";
|
||||
import { constantPropagation, deadCodeElimination } from "../Optimization";
|
||||
import {
|
||||
alignReactiveScopesToBlockScopes,
|
||||
buildReactiveBlocks,
|
||||
@@ -49,11 +49,11 @@ import {
|
||||
pruneUnusedLValues,
|
||||
pruneUnusedScopes,
|
||||
renameVariables,
|
||||
} from "./ReactiveScopes";
|
||||
import { eliminateRedundantPhi, enterSSA, leaveSSA } from "./SSA";
|
||||
import { inferTypes } from "./TypeInference";
|
||||
import { logHIRFunction, logReactiveFunction } from "./Utils/logger";
|
||||
import { assertExhaustive } from "./Utils/utils";
|
||||
} from "../ReactiveScopes";
|
||||
import { eliminateRedundantPhi, enterSSA, leaveSSA } from "../SSA";
|
||||
import { inferTypes } from "../TypeInference";
|
||||
import { logHIRFunction, logReactiveFunction } from "../Utils/logger";
|
||||
import { assertExhaustive } from "../Utils/utils";
|
||||
|
||||
export type CompilerPipelineValue =
|
||||
| { kind: "ast"; name: string; value: t.FunctionDeclaration }
|
||||
@@ -263,7 +263,7 @@ export function* run(
|
||||
return ast;
|
||||
}
|
||||
|
||||
export function compile(
|
||||
export function compileFn(
|
||||
func: NodePath<t.FunctionDeclaration>,
|
||||
options?: Partial<EnvironmentConfig> | null
|
||||
): t.FunctionDeclaration {
|
||||
+6
-10
@@ -11,15 +11,11 @@ import {
|
||||
CompilerError,
|
||||
CompilerErrorDetail,
|
||||
ErrorSeverity,
|
||||
} from "./CompilerError";
|
||||
import { compile } from "./CompilerPipeline";
|
||||
import { GeneratedSource } from "./HIR";
|
||||
import { addInstrumentForget } from "./CompilerInstrumentation";
|
||||
import {
|
||||
ExternalFunction,
|
||||
PluginOptions,
|
||||
parsePluginOptions,
|
||||
} from "./CompilerOptions";
|
||||
} from "../CompilerError";
|
||||
import { compileFn } from "./Pipeline";
|
||||
import { GeneratedSource } from "../HIR";
|
||||
import { addInstrumentForget } from "./Instrumentation";
|
||||
import { ExternalFunction, PluginOptions, parsePluginOptions } from "./Options";
|
||||
|
||||
export type CompilerPass = {
|
||||
opts: PluginOptions;
|
||||
@@ -51,7 +47,7 @@ export function compileProgram(
|
||||
pass: CompilerPass
|
||||
): void {
|
||||
try {
|
||||
const compiled = compile(fn, pass.opts.environment);
|
||||
const compiled = compileFn(fn, pass.opts.environment);
|
||||
if (fn.node.id == null) {
|
||||
CompilerError.invariant(
|
||||
"FunctionDeclaration must have a name",
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from "./Program";
|
||||
export * from "./Instrumentation";
|
||||
export * from "./Options";
|
||||
export * from "./Pipeline";
|
||||
@@ -11,7 +11,7 @@ export {
|
||||
CompilerErrorDetail,
|
||||
ErrorSeverity,
|
||||
} from "./CompilerError";
|
||||
export { CompilerPipelineValue, compile, run } from "./CompilerPipeline";
|
||||
export { CompilerPipelineValue, compileFn as compile, run } from "./Entrypoint";
|
||||
export { Effect, Hook, ValueKind, printHIR } from "./HIR";
|
||||
export { printReactiveFunction } from "./ReactiveScopes";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user