diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts index 5f26d0e6a9..468a81b1d8 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts @@ -2044,6 +2044,21 @@ function lowerExpression( } props.push({ kind: "JsxAttribute", name: propName, place: value }); } + if (tag.kind === "BuiltinTag" && tag.name === "fbt") { + const openingIdentifier = opening.get("name"); + const tagIdentifier = openingIdentifier.isJSXIdentifier() + ? builder.resolveIdentifier(openingIdentifier) + : null; + if (tagIdentifier != null) { + CompilerError.throwTodo({ + reason: `Support tags where 'fbt' is a local variable instead of a global`, + loc: openingIdentifier.node.loc ?? GeneratedSource, + description: null, + suggestions: null, + }); + } + } + let children: Array; if (tag.kind === "BuiltinTag" && tag.name === "fbt") { children = expr diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt/error.todo-locally-require-fbt.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt/error.todo-locally-require-fbt.expect.md new file mode 100644 index 0000000000..94058afc59 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt/error.todo-locally-require-fbt.expect.md @@ -0,0 +1,25 @@ + +## Input + +```javascript +function Component(props) { + const fbt = require("fbt"); + + return {"Text"}; +} + +``` + + +## Error + +``` + 2 | const fbt = require("fbt"); + 3 | +> 4 | return {"Text"}; + | ^^^ [ReactForget] Todo: Support tags where 'fbt' is a local variable instead of a global (4:4) + 5 | } + 6 | +``` + + \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt/error.todo-locally-require-fbt.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt/error.todo-locally-require-fbt.js new file mode 100644 index 0000000000..626693eb11 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt/error.todo-locally-require-fbt.js @@ -0,0 +1,5 @@ +function Component(props) { + const fbt = require("fbt"); + + return {"Text"}; +}