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

No way to access compilation output files #27386

Open
wszydlak opened this issue Mar 29, 2024 · 6 comments
Open

No way to access compilation output files #27386

wszydlak opened this issue Mar 29, 2024 · 6 comments
Labels
angular/build:application area: angular/build freq1: low Only reported by a handful of users who observe it rarely

Comments

@wszydlak
Copy link

Command

build, serve

Description

I have an esbuild plugin that is resposible to collect outputFiles after compilation (using onEnd hook with result.outputFiles).

When using application builder (esbuild) with custom plugins there is no way to access full list of outputFiles, only those emitted by main entrypoint compilation. There is no way to access additional files emited by angular builder, such as polyfills, assets, styles etc.

Previously, with using webpack plugin, i was able to get full list of outputFiles by using processAssets compilation hook.

I need to list emited files, as this is only way to get full names with filenames hash.

MY point is to build something like manifest of compilation result output files.

Describe the solution you'd like

I would like to be able to access all compilation files by esbuild plugin.

Describe alternatives you've considered

An alternative could be to access output files as an result of builder output, currently build command only returns {success: true} without information about output files.

@alan-agius4
Copy link
Collaborator

This behavior is expected. Unlike with the webpack builder, the application builder uses multiple instances of esbuild to compile various parts of your application.

To obtain the complete list of files, utilize the outputFiles option of the application builder outside of the esbuild context.

for await (const { outputFiles } of buildApplication(...)) {
}

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 1, 2024
@wszydlak
Copy link
Author

wszydlak commented Apr 2, 2024

This behavior is expected. Unlike with the webpack builder, the application builder uses multiple instances of esbuild to compile various parts of your application.

To obtain the complete list of files, utilize the outputFiles option of the application builder outside of the esbuild context.

for await (const { outputFiles } of buildApplication(...)) {
}

@alan-agius4
Please reopen this issue, cause as described in issue:

currently build command only returns {success: true} without information about output files.

When using buildApplication without watch mode im not able to obtain list of output files.

@alan-agius4
Copy link
Collaborator

{success: true} is returned when buildApplication is executed in write mode. I am curious, what is your use case of adding additional files?

@wszydlak
Copy link
Author

wszydlak commented Apr 3, 2024

How can i execute it without write mode? As i see this is only possible using buildApplicationInternal function, is it guaranteed that it always will be public?

My use case:

  1. My angular application defines list of custom elements - by using angular elements, that can be used in external application
  2. External application need to know what files it should load to make it all work (eg. load polyfills file to have zone.js, load some styles that define fonts (which has to be done outside shadow dom, etc).
  3. External application is in old technology (not using any bundler), just plain javascript files, which have mechanism to fetch main JSON file (that contains information about files generated by angular with hashes).

So to achieve this during compilation time I emmit additional file (we can call it entry.json) that is deployed together with all files generated by angular. External application fetches only entry.json and get information what additional files should it load.

Ideally would be to do this only by using esbuild plugin, so i could be able to use community builders such as @nx/angular:application that allow to pass list of esbuild plugins, but if this is not possible i need any (but secure) way to do this.

@wszydlak
Copy link
Author

wszydlak commented Apr 5, 2024

@alan-agius4 any update on this?

@wszydlak
Copy link
Author

@alan-agius4 can you please reopen this issue? Problem still exists and there is no final info how to get list of compiled files properly.

@alan-agius4 alan-agius4 reopened this Apr 10, 2024
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Apr 10, 2024
…s when using the application builder

This allows access to file when using the `buildApplication` API

Closes: angular#27386
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Apr 10, 2024
…s when using the application builder

This allows access to file when using the `buildApplication` API

Closes: angular#27386
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Apr 10, 2024
…s when using the application builder

This allows access to file when using the `buildApplication` API

Closes: angular#27386
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Apr 10, 2024
…s when using the application builder

This allows access to file when using the `buildApplication` API

Closes: angular#27386
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Apr 10, 2024
…s when using the application builder

This allows access to file when using the `buildApplication` API

Closes: angular#27386
@alan-agius4 alan-agius4 added freq1: low Only reported by a handful of users who observe it rarely area: devkit/build-angular angular/build:application labels Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
angular/build:application area: angular/build freq1: low Only reported by a handful of users who observe it rarely
Projects
None yet
2 participants