77 */
88
99import type { Plugin } from 'esbuild' ;
10- import { dirname , resolve } from 'node:path' ;
1110import { toPosixPath } from '../../utils/path' ;
1211
1312/**
@@ -33,21 +32,32 @@ export function createPlatformServerDominoExposePlugin(): Plugin {
3332 build . onResolve ( { filter : BUNDLED_DOMINO_FILTER } , ( args ) =>
3433 args . namespace !== 'angular:domino-expose' && args . kind === 'import-statement'
3534 ? {
36- path : resolve ( args . resolveDir , args . path ) ,
35+ path : 'angular:platform-server-domino' ,
3736 namespace : 'angular:domino-expose' ,
37+ pluginData : {
38+ importPath : args . path ,
39+ resolveDir : args . resolveDir ,
40+ } ,
3841 }
3942 : null ,
4043 ) ;
4144
42- build . onLoad ( { filter : / ./ , namespace : 'angular:domino-expose' } , ( args ) => ( {
43- contents : [
44- `import domino from ${ JSON . stringify ( toPosixPath ( args . path ) ) } ;` ,
45- `globalThis['${ DOMINO_GLOBAL_PROPERTY } '] = domino;` ,
46- `export default domino;` ,
47- ] . join ( '\n' ) ,
48- loader : 'js' ,
49- resolveDir : dirname ( args . path ) ,
50- } ) ) ;
45+ build . onLoad ( { filter : / ./ , namespace : 'angular:domino-expose' } , ( args ) => {
46+ const { importPath, resolveDir } = args . pluginData as {
47+ importPath : string ;
48+ resolveDir : string ;
49+ } ;
50+
51+ return {
52+ contents : [
53+ `import domino from ${ JSON . stringify ( toPosixPath ( importPath ) ) } ;` ,
54+ `globalThis['${ DOMINO_GLOBAL_PROPERTY } '] = domino;` ,
55+ `export default domino;` ,
56+ ] . join ( '\n' ) ,
57+ loader : 'js' ,
58+ resolveDir,
59+ } ;
60+ } ) ;
5161 } ,
5262 } ;
5363}
@@ -58,9 +68,9 @@ export function createPlatformServerDominoExposePlugin(): Plugin {
5868 *
5969 * @returns An esbuild plugin.
6070 */
61- export function createPlatformServerDominoPlugin ( ) : Plugin {
71+ export function createPlatformServerDominoRedirectPlugin ( ) : Plugin {
6272 return {
63- name : 'angular-platform-server-domino-consume ' ,
73+ name : 'angular-platform-server-domino-redirect ' ,
6474 setup ( build ) {
6575 build . onResolve ( { filter : BUNDLED_DOMINO_FILTER } , ( args ) =>
6676 args . kind === 'import-statement'
0 commit comments