@@ -127,6 +127,47 @@ describe('bundleEntryPoints', () => {
127127 ) ;
128128 } ) ;
129129
130+ it ( 'should preserve declare global and module augmentations in side-effect .d.ts imports' , async ( ) => {
131+ const primaryEntry : NormalizedEntryPoint = {
132+ subpath : '.' ,
133+ name : 'my-lib' ,
134+ displayName : 'my-lib' ,
135+ bundleName : 'my-lib' ,
136+ entryFilePath : `${ workspaceRoot } /src/public-api.ts` ,
137+ isPrimary : true ,
138+ } ;
139+ const entryPoints = new Map < string , NormalizedEntryPoint > ( [ [ 'my-lib' , primaryEntry ] ] ) ;
140+
141+ const esmFiles = new Map < string , string > ( [
142+ [ `${ workspaceRoot } /src/public-api.js` , 'export const a = 1;' ] ,
143+ ] ) ;
144+ const dtsFiles = new Map < string , string > ( [
145+ [
146+ `${ workspaceRoot } /src/globals.d.ts` ,
147+ 'export {};\ndeclare global {\n interface Window {\n myCustomGlobal: boolean;\n }\n}\n' ,
148+ ] ,
149+ [
150+ `${ workspaceRoot } /src/augment.d.ts` ,
151+ "declare module '@angular/core' {\n interface Component {\n augmentedProp?: string;\n }\n}\nexport {};\n" ,
152+ ] ,
153+ [
154+ `${ workspaceRoot } /src/public-api.d.ts` ,
155+ 'import "./globals.js";\nexport * from "./augment.js";\nexport declare const a = 1;\n' ,
156+ ] ,
157+ ] ) ;
158+
159+ const output = await bundleEntryPoints (
160+ [ { entryPoint : primaryEntry , hasEsmChanges : true , hasDtsChanges : true } ] ,
161+ esmFiles ,
162+ dtsFiles ,
163+ createOptions ( entryPoints ) ,
164+ ) ;
165+
166+ const dtsFile = output . filesToEmit . find ( ( f ) => f . path === 'types/my-lib.d.ts' ) ;
167+ expect ( dtsFile ?. contents ) . toContain ( 'myCustomGlobal' ) ;
168+ expect ( dtsFile ?. contents ) . toContain ( 'augmentedProp' ) ;
169+ } ) ;
170+
130171 it ( 'should preserve legal comments in emitted FESM2022 .mjs bundles' , async ( ) => {
131172 const primaryEntry : NormalizedEntryPoint = {
132173 subpath : '.' ,
0 commit comments