Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rcr] Remove runtimeModule compiler option #31055

Draft
wants to merge 11 commits into
base: gh/poteto/14/base
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading