-
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vite-plugin-angular): fix Angular v18/v19 support for ɵPendingTas…
…ks (#1497)
- Loading branch information
1 parent
bdd03ae
commit 3215ab4
Showing
8 changed files
with
910 additions
and
713 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import { | ||
Injectable, | ||
inject, | ||
ɵPendingTasks as PendingTasks, | ||
} from '@angular/core'; | ||
import { Injectable, inject } from '@angular/core'; | ||
import { ɵPendingTasksInternal as ɵPendingTasks } from '@angular/core'; | ||
|
||
@Injectable() | ||
export class RenderTaskService { | ||
#pendingTasks = inject(PendingTasks); | ||
#pendingTasks = inject(ɵPendingTasks); | ||
|
||
addRenderTask() { | ||
return this.#pendingTasks.add(); | ||
} | ||
|
||
clearRenderTask(id: number) { | ||
this.#pendingTasks.remove(id); | ||
clearRenderTask(clear: number | Function) { | ||
if (typeof clear === 'function') { | ||
clear(); | ||
} else if (typeof (this.#pendingTasks as any).remove === 'function') { | ||
(this.#pendingTasks as any).remove(clear); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/vite-plugin-angular/src/lib/angular-pending-tasks.plugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Plugin } from 'vite'; | ||
|
||
import { angularMajor, angularPatch } from './utils/devkit.js'; | ||
|
||
/** | ||
* This plugin is a workaround for the ɵPendingTasks symbol being renamed | ||
* to ɵPendingTasksInternal in Angular v19.0.4. The symbol is renamed to support previous versions of | ||
* Angular with Analog that used the ɵPendingTasks symbol. | ||
* | ||
* Commmit: https://github.com/angular/angular/commit/24e317cb157bf1ef159ed8554f1b79cb3443edf4 | ||
*/ | ||
export function pendingTasksPlugin(): Plugin { | ||
return { | ||
name: 'analogjs-pending-tasks-plugin', | ||
transform(code, id) { | ||
if ( | ||
Number(`${angularMajor}.${angularPatch}`) < 19.4 && | ||
id.includes('analogjs-content.mjs') | ||
) { | ||
return { | ||
code: code.replace('ɵPendingTasksInternal', 'ɵPendingTasks'), | ||
}; | ||
} | ||
return; | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.