shlomiassaf / ngc-webpack

Angular compiler-cli with webpack's loader chain.
MIT License
84 stars 15 forks source link

Support metadata refactor #14

Closed shlomiassaf closed 7 years ago

shlomiassaf commented 7 years ago

This PR adds the ability to alter source files, metadata.json and all other files that the angular compiler treat as source files for the compilation (as opposed to resource files, which are templates, styles etc...)

The compiler loads source files synchronously so altering them is limited.
If, for example, you would like to alter styles of component in a metadata.json you will face an issue. In most cases these files require a pass through the webpack loader chain (or in other words webpack compilation). This is an async process so its not possible.

To workaround this issue a beforeRun hook was added, which is async. The hook accepts a compilation instance which you can use to perform the change (beforeRun is async)

This means that you will have to know the files you want to change before hand.

If the files are unknown (dynamic) then you will have no choice but to split the compilation into phases, i.e. run twice.