Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): add validation to fileReplacement…
Browse files Browse the repository at this point in the history
… values

fileReplacement is meant to replace compilation source files (JavaScript or TypeScript) with other compilation source files in the build. With this change we add validation to fail the build when the files have unsupported extensions.

Closes #11451

(cherry picked from commit 424af28)
  • Loading branch information
alan-agius4 committed Nov 6, 2020
1 parent 8a49506 commit 52a320e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
24 changes: 16 additions & 8 deletions packages/angular/cli/lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1043,10 +1043,12 @@
"type": "object",
"properties": {
"src": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
},
"replaceWith": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
}
},
"additionalProperties": false,
Expand All @@ -1059,10 +1061,12 @@
"type": "object",
"properties": {
"replace": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
},
"with": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -1931,10 +1935,12 @@
"type": "object",
"properties": {
"src": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
},
"replaceWith": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
}
},
"additionalProperties": false,
Expand All @@ -1947,10 +1953,12 @@
"type": "object",
"properties": {
"replace": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
},
"with": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
}
},
"additionalProperties": false,
Expand Down
12 changes: 8 additions & 4 deletions packages/angular_devkit/build_angular/src/browser/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,12 @@
"type": "object",
"properties": {
"src": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
},
"replaceWith": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
}
},
"additionalProperties": false,
Expand All @@ -444,10 +446,12 @@
"type": "object",
"properties": {
"replace": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
},
"with": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
}
},
"additionalProperties": false,
Expand Down
12 changes: 8 additions & 4 deletions packages/angular_devkit/build_angular/src/server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,12 @@
"type": "object",
"properties": {
"src": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
},
"replaceWith": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
}
},
"additionalProperties": false,
Expand All @@ -275,10 +277,12 @@
"type": "object",
"properties": {
"replace": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
},
"with": {
"type": "string"
"type": "string",
"pattern": "\\.([cm]?j|t)sx?$"
}
},
"additionalProperties": false,
Expand Down

2 comments on commit 52a320e

@HEBOS
Copy link

@HEBOS HEBOS commented on 52a320e Feb 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain, why scss is not included in regex for allowed fileReplacements types?

@alan-agius4
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is not a supported use-case. File replacements only works for files which are part of the TypeScript program.

Please sign in to comment.