Angular-cli: Schema validation rejects *.json files in fileReplacements (Regression in 11.0.0 & 11.0.1)

Created on 13 Nov 2020  路  3Comments  路  Source: angular/angular-cli

馃悶 Bug report

Command (mark with an x)

  • [x] build
  • [x] serve

Is this a regression?

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

Description

There are new changes in files .\node_modules\@angular-devkit\build-angular\src\browser\schema.json and .\node_modules\@angular-devkit\build-angular\src\server\schema.json that restrict using *.json files in fileReplacements operations that were always available in previous versions.

These *.json files are normally used as configuration settings in the same way as *.ts files for different environments with the advantage that they are more easily parsable as standard JSON in the different platforms than TS.

There are no reasons why the new restriction should exist, and it's also unclear why it was changed at all.

New changes are:

"properties": {
    "src": {
        "type": "string",
        "pattern": "\\.([cm]?j|t)sx?$"
    },
    "replaceWith": {
        "type": "string",
        "pattern": "\\.([cm]?j|t)sx?$"
    }
}

and previous functional version:

"properties": {
    "src": {
        "type": "string"
    },
    "replaceWith": {
        "type": "string"
    }
}

馃敟 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?$".
  Data path ".fileReplacements[0]" should match exactly one schema in oneOf.

馃實 Your Environment


Angular CLI: 11.0.1
Node: 12.13.1
OS: win32 x64

Angular: 11.0.0
... animations, cdk, common, compiler, compiler-cli, core
... elements, forms, language-service, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: 

Package                          Version
----------------------------------------------------------
@angular-devkit/architect 0.1001.7
@angular-devkit/architect-cli 0.1100.1
@angular-devkit/build-angular 0.1100.1
@angular-devkit/core 10.1.7
@angular-devkit/schematics 10.1.7
@angular-devkit/schematics-cli 0.1100.1
@angular/cli 11.0.1
@schematics/angular 10.1.7
@schematics/update 0.1100.1
rxjs 6.6.3
typescript 4.0.5
devkibuild-angular browser low regression bufix

Most helpful comment

@alan-agius4 Thanks for your quick reaction. 馃嵃

All 3 comments

Hi @mlc-mlapis,

I am assuming you are using resolveJsonModule and importing the JSON file in a .ts file correct?

@alan-agius4 Exactly.

@alan-agius4 Thanks for your quick reaction. 馃嵃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JanStureNielsen picture JanStureNielsen  路  3Comments

hartjo picture hartjo  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments

purushottamjha picture purushottamjha  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments