Repository navigation
fix(@schematics/angular): avoid adding web worker snippet to server configuration files - #34501
Conversation
…onfiguration files In an application with SSR enabled, `ng g web-worker app` appends the worker creation snippet to `app.config.server.ts` instead of the component file. The sibling file exclusion pattern is end-anchored, so `app.config.server.ts` and `app.routes.server.ts` end in `server.ts` rather than `config.ts`/`routes.ts` and are not excluded, and the alphabetical sort places `app.config.server.ts` before `app.ts`. Exclude `.server.ts` variants and require a dot-separated type suffix so that component files such as `observer.ts` remain eligible. A new spec with a server application fails without this change.
There was a problem hiding this comment.
Code Review
This pull request updates the Angular web-worker schematic to prevent adding web worker snippets to server configuration files (such as app.config.server.ts) by refining the sibling file filtering regex. It also adds corresponding unit tests to verify this behavior. The review feedback suggests further refining the file filtering regex to exclude declaration files (.d.ts) and fixing a potential matching issue in fileRegExp due to a missing end anchor. Additionally, it is recommended to avoid reassigning the suite-level appTree variable in tests to prevent state leakage.
…erver configuration files
…erver configuration files
3ffbb15 to
c5331a9
Compare
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
In an application with SSR enabled,
ng g web-worker appappends the worker creation snippet toapp.config.server.tsinstead of the component file. The sibling file exclusion pattern is end-anchored, soapp.config.server.tsandapp.routes.server.tsend inserver.tsrather thanconfig.ts/routes.tsand are not excluded, and the alphabetical sort placesapp.config.server.tsbeforeapp.ts. Exclude.server.tsvariants and require a dot-separated type suffix so that component files such asobserver.tsremain eligible. A new spec with a server application fails without this change.