Skip to content

fix(@schematics/angular): avoid adding web worker snippet to server configuration files - #34501

Open
MeAkib wants to merge 2 commits into
angular:mainfrom
MeAkib:fix/web-worker-snippet-server-config
Open

MeAkib wants to merge 2 commits into
angular:mainfrom
MeAkib:fix/web-worker-snippet-server-config

Conversation

@MeAkib

@MeAkib MeAkib commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

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.

…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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread packages/schematics/angular/web-worker/index.ts Outdated
Comment thread packages/schematics/angular/web-worker/index_spec.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant