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

esbuild plugin writing files to the incorrect location in Nx monorepo #1426

Open
getabetterpic opened this issue Jan 22, 2025 · 1 comment
Open
Assignees
Labels
esbuild @honeybadger-io/esbuild-plugin

Comments

@getabetterpic
Copy link
Contributor

getabetterpic commented Jan 22, 2025

We're working on migrating to esbuild, but one problem we've run into is the HB esbuild plugin takes over the file writing to disk, but does so without respecting the output path that has been defined. This could be an Angular-specific thing potentially. The end result is the bundle files and sourcemaps are written to the workspace root directory instead of the dist folder where they belong.

We're running an Nx monorepo with several Angular applications in it. The relevant project.json looks like this:

"build": {
  "executor": "@nx/angular:application",
  "outputs": ["{workspaceRoot}/dist/{projectRoot}"],
  "options": {
  "outputPath": {
    "base": "{workspaceRoot}/dist/{projectRoot}",
    "browser": ""
  }
}

With Angular, the outputPath can be either a string or an object with base and browser keys. I think this may be where the problem lies. The HB sourcemap upload plugin is writing the files, but only using the file's path property, not looking at anything else, which to me means somewhere in the writing process the outputPath should be considered.

Edit: here's a reproducible repo https://github.com/getabetterpic/hb-esbuild. Running npx nx build app outputs all built files to the root workspace directory instead of in the dist folder.

@subzero10
Copy link
Member

Hey @getabetterpic, thank you for submitting an issue, and going as far as creating a reproducible repo!

I'm not sure how to tackle this yet, because:

  • when looking at the esbuild API, there's no mention of the outputPath option, though there are other output options which we should consider.
  • the outputPath option seems to be a string for the esbuild executor, and only the angular executor accepts an object

I will do some more reading, before diving into a solution.

@subzero10 subzero10 self-assigned this Jan 23, 2025
@subzero10 subzero10 added the esbuild @honeybadger-io/esbuild-plugin label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
esbuild @honeybadger-io/esbuild-plugin
Projects
None yet
Development

No branches or pull requests

2 participants