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

Support indexFileTransformer in @nx/angular:browser-esbuild executor #20477

Closed
4 tasks
ArielGueta opened this issue Nov 29, 2023 · 14 comments
Closed
4 tasks

Support indexFileTransformer in @nx/angular:browser-esbuild executor #20477

ArielGueta opened this issue Nov 29, 2023 · 14 comments
Assignees
Labels

Comments

@ArielGueta
Copy link

Current Behavior

After updating to beta version and started using the @nx/angular:browser-esbuild I have the following issues:

  1. Schema error when using "executor": "@nx/angular:browser-esbuild":

Data path "" must NOT have additional properties(indexFileTransformer).

  1. Running nx build production:

Error: NX 'indexFileTransformer' is not found in schema

  1. Warnings:

Project 'ui' contains extension with invalid name ($schema).
Project 'ui' contains extension with invalid name (tags).
__

Expected Behavior

It should work without errors

GitHub Repo

No response

Steps to Reproduce

Update to latest beta version and use the @nx/angular:browser-esbuild executor with indexFileTransformer

Nx Report

none

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@ArielGueta ArielGueta changed the title Issues with the new @nx/angular:browser-esbuild support Issues with the new @nx/angular:browser-esbuild executor Nov 29, 2023
@leosvelperez leosvelperez added the scope: angular Issues related to Angular support in Nx label Nov 30, 2023
@leosvelperez leosvelperez self-assigned this Nov 30, 2023
@leosvelperez
Copy link
Member

Thanks for reporting this!

The indexFileTransformer is not supported by the @nx/angular:browser-esbuild. The error you're getting is a legit error telling you that option is not part of the executor schema. Note it's not supported by the @angular-devkit/build-angular:browser-esbuild schema either. It's only supported when using the builder programmatically.

That said, we can add support for it similar to how we added it to the @nx/angular:webpack-browser. I changed this to a feature request.

@leosvelperez
Copy link
Member

  1. Warnings:

Project 'ui' contains extension with invalid name ($schema).
Project 'ui' contains extension with invalid name (tags).

I haven't been able to reproduce this. Could you provide a repo so I can reproduce it and troubleshoot it?

@leosvelperez
Copy link
Member

It's only supported when using the builder programmatically.

That said, we can add support for it similar to how we added it to the @nx/angular:webpack-browser.

I correct myself. The @angular-devkit/build-angular:browser-esbuild builder doesn't support providing an index.html transformer function at all. Not even when using the programmatic API. It's only supported by the @angular-devkit/build-angular:dev-server builder. This is different than the @angular-devkit/build-angular:browser builder which does accept providing the transformer when using it programmatically.

This blocks us from adding support for it to the @nx/angular:browser-esbuild executor. I'll ping the Angular team on this to see if we can unblock this.

@ArielGueta
Copy link
Author

ArielGueta commented Nov 30, 2023

I see that you removed the comments where you said that it will be supported. The weird thing is that when I comment the Angular schema protection it does work. I put a log in the transformer file and I see it.

@leosvelperez
Copy link
Member

I see that you removed the comments where you said that it will be supported.

Sorry, I'm unsure what you refer to. I didn't remove any comments. I only corrected myself saying we can't support it if the underlying Angular CLI builder doesn't allow to provide it.

The weird thing is that when I comment the Angular schema protection it does work. I put a log in the transformer file and I see it.

Are you referring the serve target works? That's expected because the dev-server uses the build target indexFileTransformer and process it. What I was referring above is that, while serving your application would transform the index.html correctly, building the application won't, because the builders use for building the application don't support providing such transformer.

@ArielGueta
Copy link
Author

Sorry, my bad!

See here #20311 (comment)

@ArielGueta
Copy link
Author

ArielGueta commented Nov 30, 2023

So you're saying that only the dev-server supports it? If we can't use it also for the build it's pretty redundant for the dev server.

@leosvelperez
Copy link
Member

leosvelperez commented Nov 30, 2023

Oh, that comment. I wrongly didn't check that the browser-esbuild builder didn't support it when you asked in that other issue. I only focused on the fact the dev-server supports it. My bad. I didn't remove it though 😅

Anyways, answering the question more accurately, the dev-server does support build targets specifying the indexFileTransformer option, but the Angular CLI browser-esbuild builder doesn't allow providing it. Therefore, it can't be supported until the Angular CLI builder supports it.

I already pinged the Angular team on this. I'm unsure whether the idea is to use esbuild plugins for that or if they'll continue supporting a specific index.html tranformer function. I'm working on adding support for esbuild plugins, and that should allow you to transform your index.html contents if the transformer is not available.

@leosvelperez
Copy link
Member

BTW, I was able to reproduce the warnings you mentioned. That'll be fixed by #20499.

@r-LaForge
Copy link

r-LaForge commented Nov 30, 2023

To make this issue easier to find, and it appears to be specifically about the indexFileTransformer option, would the title be more appropriately worded as "@nx/angular:browser-esbuild executor does not support indexFileTransformer" or something similar?

This is something I'm watching for my own team's use-case as well.

@leosvelperez leosvelperez changed the title Issues with the new @nx/angular:browser-esbuild executor Support indexFileTransformer in @nx/angular:browser-esbuild executor Dec 1, 2023
@leosvelperez
Copy link
Member

leosvelperez commented Dec 1, 2023

Quick update:

Support for ESBuild plugins is being added in #20504. In the absence of a specific indexFileTransformer option, a simple plugin can be written to perform the transformations you need.

I'm still waiting on feedback from the Angular team on this matter. If it takes too long or it doesn't move forward, we could look into supporting it ourselves by passing it along to the underlying Angular CLI builder as a plugin we create on the fly that executes the developer-provided transformation function.

@leosvelperez
Copy link
Member

leosvelperez commented Dec 18, 2023

FYI: this is coming in Angular 17.1.0: angular/angular-cli@66edac4. Once it's released and we release the support for that Angular version (we're already working on it), you'll be able to use it.

@leosvelperez
Copy link
Member

This was added in #21026 and released in Nx 17.3.0.

Copy link

github-actions bot commented Mar 2, 2024

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants