Skip to content

tomfuhrer/babel-plugin-relay-eagerEsModules-bug

Repository files navigation

README

Summary of the bug

When "eagerEsModules": true is set in a multi-project Relay config, babel-plugin-relay transforms graphql tagged templates into require calls, like this:

var _MeQuery;
var MeQuery =
  _MeQuery !== void 0
    ? _MeQuery
    : ((_MeQuery = require("./__generated__/MeQuery.graphql")),
      _MeQuery.hash &&
        _MeQuery.hash !== "bce9f1cc4614c3f306814d78c53b009b" &&
        console.error(
          "The definition of 'MeQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."
        ),
      _MeQuery);

Expected behavior

Just like it does with a single-project Relay config, babel-plugin-relay should transform graphql tagged templates into import declarations when "eagerEsModules": true is set, like this:

import _MeQuery from "../__generated__/MeQuery.graphql";
var MeQuery =
  (_MeQuery.hash &&
    _MeQuery.hash !== "bce9f1cc4614c3f306814d78c53b009b" &&
    console.error(
      "The definition of 'MeQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."
    ),
  _MeQuery);

Reproducing the bug

I included the dist files in this repo, but if you want to reproduce the bug yourself, here are the steps:

  1. Clone the repo.

  2. Run these commands:

    npm install
    npm run build:single
    npm run build:multi

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published