angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Cannot use esbuild builder after 17.0.X with Bazel

Open maximemg opened this issue 1 year ago • 4 comments

Which @angular/* package(s) are the source of the bug?

bazel, compiler-cli, compiler

Is this a regression?

Yes

Description

Hi, not sure if this is the right place for this.

Basically calling the architect bin with bazel. It was working fine when updating to 17.0 But since I updated to to 17.1+ there are issues with esbuild

First was main.ts not bein available in the ts compilation (fixed with "preserveSymslinks" :true)

Second is @angular/material cannot be resolved with its path

Repro with 17.0.1

Repro with 17.3.4

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

Architect dist/angular failed: (Exit 1): app__js_binary.sh failed: error executing Architect command (from target //:app) bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/app__js_binary.sh angular:build

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
- Building...

angular:build: ✘ [ERROR] Error: The "path" argument must be of type string. Received undefined
  ╷
1 │ @use '@angular/material' as mat;
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  src/styles.scss 1:1  root stylesheet [plugin angular-sass]

    angular:styles/global:styles:1:8:
      1 │ @import 'src/styles.scss';
        ╵         ~~~~~~~~~~~~~~~~~


cFAILURE
Result: {
    "success": false,
    "target": {
        "project": "angular",
        "target": "build"
    }
}

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.3.4
Node: 18.18.2
Package manager: pnpm 8.4
OS: Ubuntu 22.04

Anything else?

It still compiles correctly with the regular "browser" builder.

maximemg avatar Apr 29 '24 03:04 maximemg

The last version this works was 17.0.3. From 17.0.4 onward this happens, specifically from https://github.com/angular/angular-cli/commit/0634a4e40f1b2e4c0a076814f3e1b242ccf1a588 onward.

From what I can tell, this is caused the build escaping the sandbox. I believe this has to do with the way aspect_rules_js patches fs. There's an issue around the realPathSync call (https://github.com/aspect-build/rules_js/issues/362).

Edit: Disregard the patch I added here earlier, I believe that only makes it worse.

sessfeld avatar May 08 '24 14:05 sessfeld

Would it be possible to try the latest v18 release candidate to see if this resolves the problem (currently v18.0.0-rc.2)?

clydin avatar May 08 '24 16:05 clydin

I gave it a quick try and it doesn't resolve the problem.

sessfeld avatar May 08 '24 16:05 sessfeld

Would it be possible to try the latest v18 release candidate to see if this resolves the problem (currently v18.0.0-rc.2)?

Branch with 18.0.0-rc

I used the 'browser-esbuild' since the 'application' doesn't seem to exist anymore. Anyway it doesn't seems to be better with or without 'preserveSymlinks'.

maximemg avatar May 09 '24 08:05 maximemg