bazelbuild / rules_nodejs

NodeJS toolchain for Bazel.

Home Page:https://bazelbuild.github.io/rules_nodejs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Migrating a create-react-app to use Bazel fails due to conflicting eslint configs

orblix opened this issue · comments

commented

What happened?

I created a react app using the create-react-app script in a package in my repo.

The package is a sub directory (i.e. there's no WORKSPACE file there).

I'm trying to make it work but I'm getting the following error when running with yarn start:

Failed to compile.

[eslint] Plugin "react" was conflicted between "package.json » eslint-config-react-app » /home/enzer/.cache/bazel/_bazel_enzer/055b3f42459170ac9ed7445962c97212/execroot/__main__/bazel-out/k8-fastbuild/bin/package/start.sh.runfiles/__main__/package/node_modules/eslint-config-react-app/base.js" and "BaseConfig » /home/enzer/.cache/bazel/_bazel_enzer/055b3f42459170ac9ed7445962c97212/execroot/__main__/bazel-out/k8-fastbuild/bin/package/start.sh.runfiles/__main__/node_modules/eslint-config-react-app/base.js".
ERROR in [eslint] Plugin "react" was conflicted between "package.json » eslint-config-react-app » /home/enzer/.cache/bazel/_bazel_enzer/055b3f42459170ac9ed7445962c97212/execroot/__main__/bazel-out/k8-fastbuild/bin/package/start.sh.runfiles/__main__/package/node_modules/eslint-config-react-app/base.js" and "BaseConfig » /home/enzer/.cache/bazel/_bazel_enzer/055b3f42459170ac9ed7445962c97212/execroot/__main__/bazel-out/k8-fastbuild/bin/package/start.sh.runfiles/__main__/node_modules/eslint-config-react-app/base.js".

webpack compiled with 1 error
No issues found.

If I delete the eslintConfig section from my package.json, it seems everything is working properly.

How can I make it work with the eslintConfig?

🔬 Minimal Reproduction

  • Create react app using: npx create-react-app package --template typescript
  • Add the following to the WORKSPACE file:
http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "dcc55f810142b6cf46a44d0180a5a7fb923c04a5061e2e8d8eb05ccccc60864b",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.0/rules_nodejs-5.8.0.tar.gz"],
)

load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")

build_bazel_rules_nodejs_dependencies()

load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")

yarn_install(
    # Name this npm so that Bazel Label references look like @npm//package
    name = "npm",
    exports_directories_only = True,
    frozen_lockfile = False,
    package_json = "//package:package.json",
    yarn_lock = "//package:yarn.lock",
)
  • Copy BUILD file from example to the package
  • Add web-vitals as a runtime dependency in the BUILD file
  • Add ./ to all targets' args so they are in the form "--node_options=--require=./$(rootpath chdir.js)"
  • Run generated app using yarn start

Version

Development (host) and target OS/architectures:
Linux or-workstation 5.10.0-20-cloud-amd64 #1 SMP Debian 5.10.158-2 (2022-12-13) x86_64 GNU/Linux

Output of bazel --version:
bazel 6.0.0-pre.20221020.1

Version of rules_nodejs, or other relevant rules from your
WORKSPACE or MODULE.bazel file:
5.8.0

Language(s) and/or frameworks involved:
react

How to reproduce

No response

Any other information?

No response

This issue has been automatically marked as stale because it has not had any activity for 6 months. It will be closed if no further activity occurs in 30 days. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

This issue was automatically closed because it went 30 days without any activity since it was labeled "Can Close?"