Skip to content

Commit

Permalink
[rcr] Remove runtimeModule compiler option
Browse files Browse the repository at this point in the history
Now that the compiler always injects `react-compiler-runtime`, this
option is unnecessary.

ghstack-source-id: d0c9cc9233636360357388b46d225534df7926e3
Pull Request resolved: #31055
  • Loading branch information
poteto committed Sep 27, 2024
1 parent 29bf920 commit 7504b22
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 135 deletions.
9 changes: 1 addition & 8 deletions compiler/apps/playground/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ module.exports = function (api) {
api.cache(true);
return {
presets: ['next/babel'],
plugins: [
[
'babel-plugin-react-compiler',
{
runtimeModule: 'react-compiler-runtime',
},
],
],
plugins: [['babel-plugin-react-compiler']],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,6 @@ export type PluginOptions = {
*/
compilationMode: CompilationMode;

/*
* If enabled, Forget will import `useMemoCache` from the given module
* instead of `react/compiler-runtime`.
*
* ```
* // If set to "react-compiler-runtime"
* import {c as useMemoCache} from 'react-compiler-runtime';
* ```
*/
runtimeModule?: string | null | undefined;

/**
* By default React Compiler will skip compilation of code that suppresses the default
* React ESLint rules, since this is a strong indication that the code may be breaking React rules
Expand Down Expand Up @@ -202,7 +191,6 @@ export const defaultOptions: PluginOptions = {
logger: null,
gating: null,
noEmit: false,
runtimeModule: null,
eslintSuppressionRules: null,
flowSuppressions: true,
ignoreUseNoForget: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ export function compileProgram(
return;
}
const useMemoCacheIdentifier = program.scope.generateUidIdentifier('c');
const moduleName = pass.opts.runtimeModule ?? 'react-compiler-runtime';

/*
* Record lint errors and critical errors as depending on Forget's config,
Expand Down Expand Up @@ -605,7 +604,7 @@ export function compileProgram(
if (needsMemoCacheFunctionImport) {
updateMemoCacheFunctionImport(
program,
moduleName,
'react-compiler-runtime',
useMemoCacheIdentifier.name,
);
}
Expand Down Expand Up @@ -638,8 +637,7 @@ function shouldSkipCompilation(
}
}

const moduleName = pass.opts.runtimeModule ?? 'react-compiler-runtime';
if (hasMemoCacheFunctionImport(program, moduleName)) {
if (hasMemoCacheFunctionImport(program, 'react-compiler-runtime')) {
return true;
}
return false;
Expand Down

This file was deleted.

This file was deleted.

7 changes: 1 addition & 6 deletions compiler/packages/snap/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ function makePluginOptions(
let enableEmitFreeze = null;
let enableEmitHookGuards = null;
let compilationMode: CompilationMode = 'all';
let runtimeModule = null;
let panicThreshold: PanicThresholdOptions = 'all_errors';
let hookPattern: string | null = null;
// TODO(@mofeiZ) rewrite snap fixtures to @validatePreserveExistingMemo:false
Expand Down Expand Up @@ -103,10 +102,7 @@ function makePluginOptions(
importSpecifierName: '$dispatcherGuard',
};
}
const runtimeModuleMatch = /@runtimeModule="([^"]+)"/.exec(firstLine);
if (runtimeModuleMatch) {
runtimeModule = runtimeModuleMatch[1];
}

if (firstLine.includes('@panicThreshold(none)')) {
panicThreshold = 'none';
}
Expand Down Expand Up @@ -243,7 +239,6 @@ function makePluginOptions(
gating,
panicThreshold,
noEmit: false,
runtimeModule,
eslintSuppressionRules,
flowSuppressions,
ignoreUseNoForget,
Expand Down
2 changes: 1 addition & 1 deletion compiler/packages/snap/src/sprout/evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export function doEval(source: string): EvaluatorResult {
} else {
return {
kind: "exception",
value: e.stack,
value: e.message,
};
}
}
Expand Down

0 comments on commit 7504b22

Please sign in to comment.