@@ -120,8 +120,7 @@ describe('module builder', () => {
120120
121121 it ( 'should generate typed plugin' , async ( ) => {
122122 const pluginDts = await readFile ( join ( distDir , 'runtime/plugins/plugin.d.ts' ) , 'utf-8' )
123- // aliases flip between `nuxt/app` and `#app` in repo vs ecosystem-ci
124- const appAlias = `import\\("(?:nuxt/app|#app)"\\)`
123+ const appAlias = `import\\("nuxt/app"\\)`
125124 expect ( pluginDts ) . toMatch ( / ^ e x p o r t t y p e S h a r e d T y p e F r o m R u n t i m e = ' s h a r e d - t y p e ' ; $ / m)
126125 expect ( pluginDts ) . toMatch (
127126 new RegExp (
@@ -131,6 +130,16 @@ describe('module builder', () => {
131130 expect ( pluginDts ) . toMatch ( / ^ e x p o r t d e f a u l t _ d e f a u l t ; $ / m)
132131 } )
133132
133+ it ( 'should not leak build-only virtual aliases into emitted runtime declarations' , async ( ) => {
134+ const files = await readdir ( runtimeDir , { recursive : true } )
135+ const declarations = files . filter ( file => / \. d \. [ ^ / ] * t s $ / . test ( file ) )
136+ expect ( declarations . length ) . toBeGreaterThan ( 0 )
137+ for ( const file of declarations ) {
138+ const contents = await readFile ( join ( runtimeDir , file ) , 'utf-8' )
139+ expect ( contents , file ) . not . toMatch ( / ( [ " ' ] ) # a p p (?: \/ [ ^ " ' ] * ) ? \1/ )
140+ }
141+ } )
142+
134143 it ( 'should correctly add extensions to imports from runtime/ directory' , async ( ) => {
135144 const moduleDts = await readFile ( join ( distDir , 'module.d.mts' ) , 'utf-8' )
136145 const runtimeImport = findStaticImports ( moduleDts ) . find ( i => i . specifier . includes ( 'runtime' ) )
@@ -158,16 +167,15 @@ describe('module builder', () => {
158167
159168 it ( 'should generate wrapped composables' , async ( ) => {
160169 const componentFile = await readFile ( join ( distDir , 'runtime/composables/useWrappedFetch.d.ts' ) , 'utf-8' )
161- // aliases flip between `nuxt/app` and `#app` in repo vs ecosystem-ci
162170 // `null` vs `undefined` error-type difference between Nuxt 3 and 4+ is intentional.
163171 // Nuxt 4+ moved the default error from `FetchError` to `NuxtError<unknown>` (nuxt/nuxt#35346); accept both until it lands in a release.
164172 const expectedErrorType = satisfies ( nuxtVersion , '^3' ) ? 'null' : 'undefined'
165173 const errorType = satisfies ( nuxtVersion , '^3' )
166174 ? 'import\\("ofetch"\\)\\.FetchError<any>'
167- : '(?:import\\("ofetch"\\)\\.FetchError<any>|import\\("(?: nuxt/app|#app) "\\)\\.NuxtError<unknown>)'
175+ : '(?:import\\("ofetch"\\)\\.FetchError<any>|import\\("nuxt/app"\\)\\.NuxtError<unknown>)'
168176 expect ( componentFile ) . toMatch (
169177 new RegExp (
170- `^export declare const useWrappedFetch: \\(\\) => import\\("(?: nuxt/app|#app) "\\)\\.AsyncData<unknown, ${ errorType } \\| ${ expectedErrorType } >;\\s*$` ,
178+ `^export declare const useWrappedFetch: \\(\\) => import\\("nuxt/app"\\)\\.AsyncData<unknown, ${ errorType } \\| ${ expectedErrorType } >;\\s*$` ,
171179 ) ,
172180 )
173181 } )
0 commit comments