Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions napi/angular-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@playwright/test": "^1.58.0",
"@types/node": "catalog:",
"oxfmt": "catalog:",
"sass": "^1.93.2",
"typescript": "catalog:",
"vite": "catalog:",
"vitest": "catalog:"
Expand Down
17 changes: 11 additions & 6 deletions napi/angular-compiler/test/hmr-hot-update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
* Tests for handleHotUpdate behavior (Issue #185).
*
* The plugin's handleHotUpdate hook must distinguish between:
* 1. Component resource files (templates/styles) → handled by custom fs.watch, return []
* 1. Component resource files (templates/styles) → dispatch component HMR and
* keep Vite's modules flowing (a resource can also be imported by a global
* stylesheet, which must still hot-update)
* 2. Non-component files (global CSS, etc.) → let Vite handle normally
*
* Previously, the plugin returned [] for ALL .css/.html files, which swallowed
Expand Down Expand Up @@ -591,8 +593,9 @@ describe('handleHotUpdate - Issue #185', () => {

const result = await callHandleHotUpdate(plugin, ctx)

// Component resources MUST be swallowed (return []) and dispatch HMR.
expect(result).toEqual([])
// Component HMR is dispatched, and Vite's modules are preserved for the
// default pipeline (e.g. a global stylesheet importing the same file).
expect(result).toEqual(mockModules)
expect(mockServer._wsMessages).toContainEqual(
expect.objectContaining({ type: 'custom', event: 'angular:component-update' }),
)
Expand All @@ -605,12 +608,14 @@ describe('handleHotUpdate - Issue #185', () => {

// The component's HTML template IS in resourceToComponent
const componentHtmlFile = normalizePath(templatePath)
const ctx = createMockHmrContext(componentHtmlFile, [{ id: componentHtmlFile }], mockServer)
const mockModules = [{ id: componentHtmlFile }]
const ctx = createMockHmrContext(componentHtmlFile, mockModules, mockServer)

const result = await callHandleHotUpdate(plugin, ctx)

// Component templates MUST be swallowed (return []) and dispatch HMR.
expect(result).toEqual([])
// Component HMR is dispatched, and Vite's modules are preserved for the
// default pipeline.
expect(result).toEqual(mockModules)
expect(mockServer._wsMessages).toContainEqual(
expect.objectContaining({ type: 'custom', event: 'angular:component-update' }),
)
Expand Down
Loading
Loading