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 fails when replacing .mts file with another one #27124

Closed
1 task
demurgos opened this issue Feb 17, 2024 · 1 comment · Fixed by #27125
Closed
1 task

Schema validation fails when replacing .mts file with another one #27124

demurgos opened this issue Feb 17, 2024 · 1 comment · Fixed by #27125

Comments

@demurgos
Copy link
Contributor

Command

build, serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

I have an Angular 17 project using .mts files. It's working perfectly, both with ng build and ng serve. It uses the @angular-devkit/build-angular:application builder. To support a new feature, I needed to swap a file when running the live-reload mode with ng serve. Following the documentation for fileReplacements, I added:

            "serve": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.mts",
                  "with": "src/environments/environment.serve.mts"
                }
              ],
              "ssr": false
            },

I now get the following error when running ng serve:

Error: Schema validation failed with the following errors:
  Data path "/fileReplacements/0/replace" must match pattern "\.(([cm]?j|t)sx?|json)$".

The regex pattern does not match what builds without replacement are actually using. Regular builds support "\.(([cm]?[jt])sx?|json)$". However, the pattern itself is questionable: why even limit the file extensions here? I don't need it right now, but what if I wanted to swap a .wasm file or any other kind of file? If a regular build works, adding a file replacement rule should never restrict it more.

Minimal Reproduction

Add a file replacement rule targeting an mts file. Example:

              "fileReplacements": [
                {
                  "replace": "src/environments/environment.mts",
                  "with": "src/environments/environment.serve.mts"
                }
              ],

Run the corresponding command (ng build, ng serve)

Exception or Error

Error: Schema validation failed with the following errors:
  Data path "/fileReplacements/0/replace" must match pattern "\.(([cm]?j|t)sx?|json)$".


### Your Environment

```text
$ ng version
Node.js version v21.6.1 detected.
Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https://nodejs.org/en/about/previous-releases/.

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

Angular CLI: 17.1.3
Node: 21.6.1 (Unsupported)
Package Manager: yarn 4.1.0
OS: linux x64

Angular: 17.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1701.3
@angular-devkit/build-angular   17.1.3
@angular-devkit/core            17.1.3
@angular-devkit/schematics      17.1.3
@schematics/angular             17.1.3
rxjs                            7.8.1
typescript                      5.3.3
zone.js                         0.14.3
    
Warning: The current version of Node (21.6.1) is not supported by Angular.


### Anything else relevant?

_No response_
demurgos added a commit to demurgos/angular-cli that referenced this issue Feb 17, 2024
This commit updates the `fileReplacement` pattern to allow `.mts` and `.cts` files.

Closes angular#27124
demurgos added a commit to demurgos/angular-cli that referenced this issue Feb 17, 2024
…ement

Updates the `fileReplacement` pattern to allow `.mts` and `.cts` files.
This enables support for TypeScript files with explicit ESM support.

Closes angular#27124
dgp1130 pushed a commit to demurgos/angular-cli that referenced this issue Feb 21, 2024
…ement

Updates the `fileReplacement` pattern to allow `.mts` and `.cts` files.
This enables support for TypeScript files with explicit ESM support.

Closes angular#27124
dgp1130 pushed a commit that referenced this issue Feb 21, 2024
…ement

Updates the `fileReplacement` pattern to allow `.mts` and `.cts` files.
This enables support for TypeScript files with explicit ESM support.

Closes #27124
dgp1130 pushed a commit that referenced this issue Feb 21, 2024
…ement

Updates the `fileReplacement` pattern to allow `.mts` and `.cts` files.
This enables support for TypeScript files with explicit ESM support.

Closes #27124

(cherry picked from commit fa146b8)
@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 23, 2024
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