René's URL Explorer Experiment


Title: `ng serve` serves broken JS (HTTP 500 / "Failed to fetch dynamically imported module") when a chunk contains a `//# sourceMappingURL=` line inside a template literal · Issue #33544 · angular/angular-cli · GitHub

Open Graph Title: `ng serve` serves broken JS (HTTP 500 / "Failed to fetch dynamically imported module") when a chunk contains a `//# sourceMappingURL=` line inside a template literal · Issue #33544 · angular/angular-cli

X Title: `ng serve` serves broken JS (HTTP 500 / "Failed to fetch dynamically imported module") when a chunk contains a `//# sourceMappingURL=` line inside a template literal · Issue #33544 · angular/angular-cli

Description: Command 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 When serving with sourcemaps enabled, createAngularMemoryPlugi...

Open Graph Description: Command 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 When serving with sour...

X Description: Command 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 When serving with sour...

Opengraph URL: https://github.com/angular/angular-cli/issues/33544

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`ng serve` serves broken JS (HTTP 500 / \"Failed to fetch dynamically imported module\") when a chunk contains a `//# sourceMappingURL=` line inside a template literal","articleBody":"### Command\n\nserve\n\n### Is this a regression?\n\n- [x] Yes, this behavior used to work in the previous version\n\n### The previous version in which this bug was not present was\n\n_No response_\n\n### Description\n\nWhen serving with sourcemaps enabled, `createAngularMemoryPlugin`'s `load` hook removes sourcemap URL comments from the served chunk before handing it to Vite:\n\nhttps://github.com/angular/angular-cli/blob/main/packages/angular/build/src/tools/vite/plugins/angular-memory-plugin.ts#L107\n\n```ts\ncode: mapContents ? code.replace(/^\\/\\/# sourceMappingURL=[^\\r\\n]*/gm, '') : code,\n```\n\nI believe this is done to strip the chunk's own trailing comment, but the g and m flags make the regex match EVERY line in the file that starts with `//# sourceMappingURL=` , including lines that are content inside a template literal, not real comments.\n\nThe consequence is: any library that embeds bundled code as a string (the classic `worker-loader` inline-worker pattern, where a webpack-built worker bundle is embedded as a string and instantiated via `new Blob(...)`). The embedded bundle text ends with its own `//# sourceMappingURL=xxx.worker.js.map` line.  The emitted chunk then looks like:\n\n```js\ncreateInlineWorker(`/******/ (() => { // webpackBootstrap\n...thousands of lines of worker code...\n//# sourceMappingURL=abc123.worker.js.map`, null);\n```\n\nNote the template literal's **closing backtick is on the same line** as the embedded comment. The `replace` deletes that entire line — closing backtick and `, null);` included — producing an unterminated template literal. Vite's import-analysis then fails to parse the chunk and the dev server responds 500 with:\n\n```\nFailed to parse source for import analysis because the content contains invalid JS syntax.\n```\n\nIn the browser, if the chunk is lazy, this surfaces as:\n\n```\nTypeError: Failed to fetch dynamically imported module: https://.../my-component.entry-XXXXXXXX.js\n```\n\nImportant to note is that `ng build` is unaffected because the plugin only runs in the dev server.\n\n\n### Minimal Reproduction\n\n1. `ng new repro --defaults && cd repro`\n2. Add to `src/main.ts` (this simulates what a bundled inline-worker dependency looks like after esbuild re-emits it — a string with mixed quotes and `\\n` escapes is printed as a multiline template literal):\n\n```ts\nexport const workerSource =\n  'console.log(\"double\") + console.log(\\'single\\');\\n' +\n  'console.log(\"double\") + console.log(\\'single\\');\\n' +\n  '//# sourceMappingURL=inline-worker.js.map';\nconsole.log(workerSource.length);\n```\n\n3. `ng serve` (development configuration, `sourceMap` enabled — the default)\n4. Open the app. The served `main.js` contains an unterminated template literal and fails to parse; Vite returns 500 with `Failed to parse source for import analysis`.\n\nYou can observe the mechanism standalone: `esbuild` emits the string above as\n\n```js\nvar workerSource = `console.log(\"double\") + console.log('single');\nconsole.log(\"double\") + console.log('single');\n//# sourceMappingURL=inline-worker.js.map`;\n```\n\nand applying `code.replace(/^\\/\\/# sourceMappingURL=[^\\r\\n]*/gm, '')` to it removes the last line including the closing backtick — invalid JS.\n\n### Exception or Error\n\n```text\n[vite] Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.\n  Plugin: vite:import-analysis\n  File: .angular/vite-root/\u003cproject>/chunk-XXXXXXXX.js\n\n\nBrowser (when the broken chunk is a dependency of a lazy chunk):\n\n\nTypeError: Failed to fetch dynamically imported module: https://localhost:4200/.../component.entry-XXXXXXXX.js\n```\n\n### Your Environment\n\n```text\n- Angular CLI / `@angular/build`: 22.0.0 (regex verified still present in 22.0.5 and on `main`)\n- Vite: 7.3.2\n- Node: 24.x\n- OS: Linux\n```\n\n### Anything else relevant?\n\nSuggested fix — only strip the chunk's own trailing comment by anchoring the match to the end of the file instead of using `g`/`m`:\n\n```ts\ncode: mapContents ? code.replace(/(^|\\n)\\/\\/# sourceMappingURL=[^\\r\\n]*\\s*$/, '$1') : code,\n```\n\nAs a workaround we've been running this as a `patch-package` patch and it fixes the issue. Mid-file occurrences (which are always string content, since esbuild already consumes real sourcemap comments during bundling) are preserved, and Vite still appends its own inline map when serving.\n\nThe same greedy pattern also appears in `javascript-transformer-worker.ts` (`data.replace(/^\\/\\/# sourceMappingURL=[^\\r\\n]*/gm, '')`) and may deserve the same anchoring, although we have not observed a failure through that path.","author":{"url":"https://github.com/roman-garcia","@type":"Person","name":"roman-garcia"},"datePublished":"2026-07-10T12:54:22Z","url":"https://github.com/angular/angular-cli/issues/33544"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:04f8dfb4-4982-d132-fe90-2ed75e7bcb22
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA2CE:21AC3F:16B6A4F:1CD1942:6B011EB6
html-safe-nonceb64c0834cb251785a48ebf298fbce4d46a349420079fe7dd3bf8c68d3590fcea
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMkNFOjIxQUMzRjoxNkI2QTRGOjFDRDE5NDI6NkIwMTFFQjYiLCJ2aXNpdG9yX2lkIjoiMjM5MTQ3ODIxNjQ0MDIyNTQ2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac73b625d3bbb058b80e49ddbac718ffd22f5a064c8fc6cf75998a798d4fcc4835
hovercard-subject-tagissue:4855173195
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/33544/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5e8458ae54598aa9011414e0982e73db3fa2fcad74c5744624f5f1dec001c8ff/angular/angular-cli/issues/33544
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5e8458ae54598aa9011414e0982e73db3fa2fcad74c5744624f5f1dec001c8ff/angular/angular-cli/issues/33544
og:image:altCommand 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 When serving with sour...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameroman-garcia
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/angular/angular-cli git https://github.com/angular/angular-cli.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id36891867
octolytics-dimension-repository_nwoangular/angular-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id36891867
octolytics-dimension-repository_network_root_nwoangular/angular-cli
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular-cli/issues/33544#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F33544
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F33544
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular-cli
Reloadhttps://github.com/angular/angular-cli/issues/33544
Reloadhttps://github.com/angular/angular-cli/issues/33544
Reloadhttps://github.com/angular/angular-cli/issues/33544
angularhttps://github.com/angular
angular-clihttps://github.com/angular/angular-cli
Codehttps://github.com/angular/angular-cli
Issues198 (198)https://github.com/angular/angular-cli/issues
Pull requests23 (23)https://github.com/angular/angular-cli/pulls
Actionshttps://github.com/angular/angular-cli/actions
Security and quality8 (8)https://github.com/angular/angular-cli/security
Insightshttps://github.com/angular/angular-cli/insights
https://github.com/angular/angular-cli
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/33544
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/33544
#33545https://github.com/angular/angular-cli/pull/33545
ng serve serves broken JS (HTTP 500 / "Failed to fetch dynamically imported module") when a chunk contains a //# sourceMappingURL= line inside a template literalhttps://github.com/angular/angular-cli/issues/33544#top
#33545https://github.com/angular/angular-cli/pull/33545
area: @angular/buildhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fbuild%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
needsTriagehttps://github.com/angular/angular-cli/milestone/11
https://github.com/roman-garcia
roman-garciahttps://github.com/roman-garcia
on Jul 10, 2026https://github.com/angular/angular-cli/issues/33544#issue-4855173195
https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/tools/vite/plugins/angular-memory-plugin.ts#L107https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/tools/vite/plugins/angular-memory-plugin.ts#L107
angular-robothttps://github.com/apps/angular-robot
area: @angular/buildhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fbuild%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
on Jul 10, 2026https://github.com/angular/angular-cli/issues/33544#event-27814249313
angular-robothttps://github.com/apps/angular-robot
needsTriagehttps://github.com/angular/angular-cli/milestone/11
on Jul 10, 2026https://github.com/angular/angular-cli/issues/33544#event-27814250576
clydinhttps://github.com/clydin
fix(@angular/build): prevent stripping nested sourceMappingURL comments #33545https://github.com/angular/angular-cli/pull/33545
on Jul 10, 2026https://github.com/angular/angular-cli/issues/33544#event-27819355503
clydinhttps://github.com/clydin
completedhttps://github.com/angular/angular-cli/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#33545https://github.com/angular/angular-cli/pull/33545
on Jul 13, 2026https://github.com/angular/angular-cli/issues/33544#event-27909819430
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Aug 13, 2026https://github.com/angular/angular-cli/issues/33544#issuecomment-5274324434
automatic conversation locking policyhttps://github.com/angular/angular/blob/f0fbced1c55bc8b8ed9df01cea99df42f3e7eae3/contributing-docs/auto-issue-locking.md
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Aug 13, 2026https://github.com/angular/angular-cli/issues/33544#event-29372496724
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular-cli/issues/33544
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/33544
area: @angular/buildhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fbuild%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
needsTriageNo due datehttps://github.com/angular/angular-cli/milestone/11
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.