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

Not possible to do fileReplacements on components style or template file #20147

Closed
2 of 15 tasks
Dalesjo opened this issue Feb 26, 2021 · 3 comments
Closed
2 of 15 tasks

Comments

@Dalesjo
Copy link

Dalesjo commented Feb 26, 2021

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 10.2.4

Description

Previously you could replace .html and .css for components during build. After updating to Angular 11.2.3 it is no longer possible to run ng serve or ng build without it failing because of schema validation.

🔬 Minimal Reproduction

Minimal example is available in repository https://github.com/Dalesjo/file-replacement-issue

  • Example is done in angular 10.2.4 ng serve and ng build will work and replace files specified in angular.json.
  • Run ng update @angular/core @angular/cli
  • ng serve and ng build will no longer work and throw an error..

🔥 Exception or Error

Schema validation failed with the following errors:
  Data path ".fileReplacements[0]" should NOT have additional properties(replace).
  Data path ".fileReplacements[0].replace" should match pattern "\.(([cm]?j\|t)sx?\|json)$".
  Data path ".fileReplacements[0]" should match exactly one schema in oneOf.

🌍 Your Environment




     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 11.2.2
Node: 12.16.0
OS: win32 x64

Angular: 11.2.3
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.2
@angular-devkit/build-angular   0.1102.2
@angular-devkit/core            11.2.2
@angular-devkit/schematics      11.2.2
@angular/cli                    11.2.2
@schematics/angular             11.2.2
@schematics/update              0.1102.2
rxjs                            6.6.6



Anything else relevant?

The change was done in commit 424af28 to prevent replacing files not part of the bundle.

#19390 was closed because of inactivity a month ago. I see prevously threads mentions that fileReplacements are not meant for assets, but i believe style and templates for the components are not assets but part of the bundle and should be supported?

@alan-agius4
Copy link
Collaborator

Hi @Dalesjo,

I am sorry that you are facing this issue, but this is the expected behaviour.

fileReplacements is meant to work on source files which are part of the TypeScript program. While in previous version It did work one some other files this was a bug which did cause several issues including increasing build times.

In version 11, we did add a validation so enforce users to use fileReplacements to stay on the supported path and only replace file types which are part of the TypeScript program.

@Dalesjo
Copy link
Author

Dalesjo commented Feb 28, 2021

Hi @alan-agius4

Could you please address "fileReplacements is meant to work on source files which are part of the TypeScript program"

Both templates and styles are compiled into main.js. They are not typescript, but should they not be considered to be part of the program?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants