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

"Invalid build flag" error when running esbuild with define argument #2473

Closed
shosti opened this issue Feb 17, 2021 · 3 comments
Closed

"Invalid build flag" error when running esbuild with define argument #2473

shosti opened this issue Feb 17, 2021 · 3 comments

Comments

@shosti
Copy link

shosti commented Feb 17, 2021

🐞 bug report

Affected Rule

The issue is caused by the rule:

esbuild

Is this a regression?

No

Description

When using the define option in the esbuild rule, builds fail with errors similar to:

 > error: Invalid build flag: "--define=process.env.NODE_ENV=\"production\""

From the esbuild docs, it looks like generated CLI argument should be --define:process.env.NODE_ENV=\"production\" instead of --define=process.env.NODE_ENV=\"production\".

🔬 Minimal Reproduction

This occurs with an esbuild rule that looks like this:

esbuild(
    name = "dashboard",
    entry_point = "src/index.tsx",
    deps = [
        ":lib",
    ],
    tool = select({
        "@bazel_tools//src/conditions:darwin": "@esbuild_darwin//:bin/esbuild",
        "@bazel_tools//src/conditions:windows": "@esbuild_windows//:esbuild.exe",
        "@bazel_tools//src/conditions:linux_x86_64": "@esbuild_linux//:bin/esbuild",
    }),
    define = [
        "process.env.NODE_ENV=\"production\"",
    ],
)

I tried with esbuild 0.8.34 and 0.8.46.

🔥 Exception or Error

 > error: Invalid build flag: "--define=process.env.NODE_ENV=\"production\""

🌍 Your Environment

Operating System:

  
Linux
  

Output of bazel version:

  
Build label: 3.5.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Sep 2 20:11:46 2020 (1599077506)
Build timestamp: 1599077506
Build timestamp as int: 1599077506
  

Rules_nodejs version:

(Please check that you have matching versions between WORKSPACE file and @bazel/* npm packages.)

  
3.2.0
  

Anything else relevant?

@shosti
Copy link
Author

shosti commented Feb 17, 2021

I have a fix locally, I can make a PR really quick.

@mattem
Copy link
Collaborator

mattem commented Feb 17, 2021

Thanks for the report, this was fixed at HEAD earlier today by #2469

@shosti
Copy link
Author

shosti commented Feb 17, 2021

Oh awesome, thanks!

@shosti shosti closed this as completed Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants