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

Schema validation rejects *.json files in fileReplacements (Regression in 11.0.0 & 11.0.1) #19378

Closed
2 tasks done
mlc-mlapis opened this issue Nov 13, 2020 · 4 comments · Fixed by #19379
Closed
2 tasks done

Comments

@mlc-mlapis
Copy link

🐞 Bug report

Command (mark with an x)

  • build
  • 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
@alan-agius4
Copy link
Collaborator

Hi @mlc-mlapis,

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

@mlc-mlapis
Copy link
Author

@alan-agius4 Exactly.

@mlc-mlapis
Copy link
Author

@alan-agius4 Thanks for your quick reaction. 🍰

clydin pushed a commit that referenced this issue Nov 13, 2020
JSON files a can also be valid fileReplacement when using the `resolveJsonModule` TypeScript feature. This causes JSON files to be resolved as JS modules and hence be part of the TypeScript program.

Closes #19378
clydin pushed a commit that referenced this issue Nov 13, 2020
JSON files a can also be valid fileReplacement when using the `resolveJsonModule` TypeScript feature. This causes JSON files to be resolved as JS modules and hence be part of the TypeScript program.

Closes #19378

(cherry picked from commit 715a7a5)
@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 Dec 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants