Skip to content

Commit

Permalink
Fix eagerEsModules flag in babel-plugin-relay (#3724)
Browse files Browse the repository at this point in the history
Summary:
The flag was renamed along with new compiler implementation,
fixed in docs but forgotten in babel plugin.

Using old flag makes compiler to panic and the only workaround now is
overriding flag in babel config.

Pull Request resolved: #3724

Reviewed By: tyao1

Differential Revision: D33476761

Pulled By: alunyov

fbshipit-source-id: ef57621ba343ec43e5f996d1aadf1a23e4ac7da8
  • Loading branch information
TrySound authored and facebook-github-bot committed Jan 7, 2022
1 parent 1357c25 commit b5add1e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/babel-plugin-relay/BabelPluginRelay.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type RelayPluginOptions = {
isDevVariableName?: string,

// enable generating eager es modules for modern runtime
eagerESModules?: boolean,
eagerEsModules?: boolean,

// Directory as specified by artifactDirectory when running relay-compiler
artifactDirectory?: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('`development` option', () => {
it('tests the hash when `development` is set', () => {
expect(
transformerWithOptions(
{eagerESModules: true},
{eagerEsModules: true},
'development',
)('graphql`fragment TestFrag on Node { id }`'),
).toMatchSnapshot();
Expand All @@ -25,7 +25,7 @@ describe('`development` option', () => {
it('tests the hash when `isDevVariable` is set', () => {
expect(
transformerWithOptions({
eagerESModules: true,
eagerEsModules: true,
isDevVariableName: 'IS_DEV',
})('graphql`fragment TestFrag on Node { id }`'),
).toMatchSnapshot();
Expand All @@ -36,7 +36,7 @@ describe('`development` option', () => {
transformerWithOptions(
{
buildCommand: 'relay-compiler',
eagerESModules: true,
eagerEsModules: true,
},
'development',
)('graphql`fragment TestFrag on Node { id }`'),
Expand All @@ -46,7 +46,7 @@ describe('`development` option', () => {
it('does not test the hash when `development` is not set', () => {
expect(
transformerWithOptions(
{eagerESModules: true},
{eagerEsModules: true},
'production',
)('graphql`fragment TestFrag on Node { id }`'),
).toMatchSnapshot();
Expand Down
8 changes: 4 additions & 4 deletions packages/babel-plugin-relay/compileGraphQLTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function compileGraphQLTag(
);
}

const eagerESModules = state.opts?.eagerESModules ?? false;
const eagerEsModules = state.opts?.eagerEsModules ?? false;
const isHasteMode = state.opts?.jsModuleFormat === 'haste';
const isDevVariable = state.opts?.isDevVariableName;
const artifactDirectory = state.opts?.artifactDirectory;
Expand All @@ -67,7 +67,7 @@ function compileGraphQLTag(

return createNode(t, state, path, definition, {
artifactDirectory,
eagerESModules,
eagerEsModules,
buildCommand,
isDevelopment,
isHasteMode,
Expand All @@ -90,7 +90,7 @@ function createNode(
// If an output directory is specified when running relay-compiler this should point to that directory
artifactDirectory: ?string,
// Generate eager es modules instead of lazy require
eagerESModules: boolean,
eagerEsModules: boolean,
// The command to run to compile Relay files, used for error messages.
buildCommand: string,
// Generate extra validation, defaults to true.
Expand Down Expand Up @@ -136,7 +136,7 @@ function createNode(
),
);

if (options.eagerESModules) {
if (options.eagerEsModules) {
const importDeclaration = t.ImportDeclaration(
[t.ImportDefaultSpecifier(id)],
t.StringLiteral(requiredPath),
Expand Down

0 comments on commit b5add1e

Please sign in to comment.