|  | 
| 1 | 1 | import path from 'node:path'; | 
| 2 |  | -import { beforeAll, expect, test } from '@rstest/core'; | 
|  | 2 | +import { beforeAll, describe, expect, test } from '@rstest/core'; | 
| 3 | 3 | import { buildAndGetResults } from 'test-helper'; | 
| 4 | 4 | 
 | 
| 5 |  | -let contents: Awaited<ReturnType<typeof buildAndGetResults>>['contents']; | 
|  | 5 | +describe.skipIf(process.version.startsWith('v18'))( | 
|  | 6 | +  'dts redirect with tsgo', | 
|  | 7 | +  () => { | 
|  | 8 | +    let contents: Awaited<ReturnType<typeof buildAndGetResults>>['contents']; | 
| 6 | 9 | 
 | 
| 7 |  | -beforeAll(async () => { | 
| 8 |  | -  const fixturePath = path.resolve(__dirname, './dts-tsgo'); | 
| 9 |  | -  contents = (await buildAndGetResults({ fixturePath, type: 'dts' })).contents; | 
| 10 |  | -}, 20000); | 
|  | 10 | +    beforeAll(async () => { | 
|  | 11 | +      const fixturePath = path.resolve(__dirname, './dts-tsgo'); | 
|  | 12 | +      contents = (await buildAndGetResults({ fixturePath, type: 'dts' })) | 
|  | 13 | +        .contents; | 
|  | 14 | +    }, 20000); | 
| 11 | 15 | 
 | 
| 12 |  | -test('redirect.dts.path: true with redirect.dts.extension: false - default', async () => { | 
| 13 |  | -  expect(contents.esm0).toMatchInlineSnapshot(` | 
| 14 |  | -    { | 
| 15 |  | -      "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/.hidden-folder/index.d.ts": "export declare const hiddenFolder = "This is a hidden folder"; | 
| 16 |  | -    ", | 
| 17 |  | -      "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/.hidden.d.ts": "export declare const hidden = "This is a hidden file"; | 
| 18 |  | -    ", | 
| 19 |  | -      "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/a.b/index.d.ts": "export declare const ab = "a.b"; | 
| 20 |  | -    ", | 
| 21 |  | -      "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/bar.baz.d.ts": "export declare const bar = "bar-baz"; | 
| 22 |  | -    ", | 
| 23 |  | -      "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/foo/foo.d.ts": "import { logRequest } from '../logger'; | 
| 24 |  | -    import { logger } from '../../../../compile/prebundle-pkg'; | 
| 25 |  | -    import { logRequest as logRequest2 } from '../logger'; | 
| 26 |  | -    export { logRequest, logRequest2, logger }; | 
| 27 |  | -    ", | 
| 28 |  | -      "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/foo/index.d.ts": "export type Barrel = string; | 
| 29 |  | -    ", | 
| 30 |  | -      "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/index.d.ts": "import { logRequest } from './logger'; | 
| 31 |  | -    import { logger } from '../../../compile/prebundle-pkg'; | 
| 32 |  | -    import type { Baz } from './'; | 
| 33 |  | -    import type { LoggerOptions } from './types'; | 
| 34 |  | -    import { defaultOptions } from './types.js'; | 
| 35 |  | -    import sources = require('./logger'); | 
| 36 |  | -    export { sources, type Baz as self, logRequest, logger, type LoggerOptions, defaultOptions, }; | 
| 37 |  | -    export * from './foo'; | 
| 38 |  | -    export * from './logger'; | 
| 39 |  | -    export type { Foo } from './types'; | 
| 40 |  | -    // export { Router } from 'express'; | 
| 41 |  | -    export * from '../../../compile/prebundle-pkg'; | 
| 42 |  | -    export type { Bar } from './types'; | 
| 43 |  | -    export * from './.hidden'; | 
| 44 |  | -    export * from './.hidden-folder'; | 
| 45 |  | -    export * from './a.b'; | 
| 46 |  | -    export * from './bar.baz'; | 
| 47 |  | -    export * from './foo'; | 
| 48 |  | -    export * from './types'; | 
| 49 |  | -    ", | 
| 50 |  | -      "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/logger.d.ts": "// import type { Request } from 'express'; | 
| 51 |  | -    import type { LoggerOptions } from './types'; | 
| 52 |  | -    export declare function logRequest(req: Request, options: LoggerOptions): void; | 
| 53 |  | -    ", | 
| 54 |  | -      "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/types.d.ts": "export interface LoggerOptions { | 
| 55 |  | -        logLevel: 'info' | 'debug' | 'warn' | 'error'; | 
| 56 |  | -        logBody: boolean; | 
| 57 |  | -    } | 
| 58 |  | -    export declare const defaultOptions: LoggerOptions; | 
| 59 |  | -    export interface Foo { | 
| 60 |  | -        foo: string; | 
| 61 |  | -    } | 
| 62 |  | -    export interface Bar { | 
| 63 |  | -        bar: string; | 
| 64 |  | -    } | 
| 65 |  | -    export interface Baz { | 
| 66 |  | -        baz: string; | 
| 67 |  | -    } | 
| 68 |  | -    ", | 
| 69 |  | -    } | 
| 70 |  | -  `); | 
| 71 |  | -}); | 
|  | 16 | +    test('redirect.dts.path: true with redirect.dts.extension: false - default', async () => { | 
|  | 17 | +      expect(contents.esm0).toMatchInlineSnapshot(` | 
|  | 18 | +        { | 
|  | 19 | +          "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/.hidden-folder/index.d.ts": "export declare const hiddenFolder = "This is a hidden folder"; | 
|  | 20 | +        ", | 
|  | 21 | +          "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/.hidden.d.ts": "export declare const hidden = "This is a hidden file"; | 
|  | 22 | +        ", | 
|  | 23 | +          "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/a.b/index.d.ts": "export declare const ab = "a.b"; | 
|  | 24 | +        ", | 
|  | 25 | +          "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/bar.baz.d.ts": "export declare const bar = "bar-baz"; | 
|  | 26 | +        ", | 
|  | 27 | +          "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/foo/foo.d.ts": "import { logRequest } from '../logger'; | 
|  | 28 | +        import { logger } from '../../../../compile/prebundle-pkg'; | 
|  | 29 | +        import { logRequest as logRequest2 } from '../logger'; | 
|  | 30 | +        export { logRequest, logRequest2, logger }; | 
|  | 31 | +        ", | 
|  | 32 | +          "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/foo/index.d.ts": "export type Barrel = string; | 
|  | 33 | +        ", | 
|  | 34 | +          "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/index.d.ts": "import { logRequest } from './logger'; | 
|  | 35 | +        import { logger } from '../../../compile/prebundle-pkg'; | 
|  | 36 | +        import type { Baz } from './'; | 
|  | 37 | +        import type { LoggerOptions } from './types'; | 
|  | 38 | +        import { defaultOptions } from './types.js'; | 
|  | 39 | +        import sources = require('./logger'); | 
|  | 40 | +        export { sources, type Baz as self, logRequest, logger, type LoggerOptions, defaultOptions, }; | 
|  | 41 | +        export * from './foo'; | 
|  | 42 | +        export * from './logger'; | 
|  | 43 | +        export type { Foo } from './types'; | 
|  | 44 | +        // export { Router } from 'express'; | 
|  | 45 | +        export * from '../../../compile/prebundle-pkg'; | 
|  | 46 | +        export type { Bar } from './types'; | 
|  | 47 | +        export * from './.hidden'; | 
|  | 48 | +        export * from './.hidden-folder'; | 
|  | 49 | +        export * from './a.b'; | 
|  | 50 | +        export * from './bar.baz'; | 
|  | 51 | +        export * from './foo'; | 
|  | 52 | +        export * from './types'; | 
|  | 53 | +        ", | 
|  | 54 | +          "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/logger.d.ts": "// import type { Request } from 'express'; | 
|  | 55 | +        import type { LoggerOptions } from './types'; | 
|  | 56 | +        export declare function logRequest(req: Request, options: LoggerOptions): void; | 
|  | 57 | +        ", | 
|  | 58 | +          "<ROOT>/tests/integration/redirect/dts-tsgo/dist/default/esm/types.d.ts": "export interface LoggerOptions { | 
|  | 59 | +            logLevel: 'info' | 'debug' | 'warn' | 'error'; | 
|  | 60 | +            logBody: boolean; | 
|  | 61 | +        } | 
|  | 62 | +        export declare const defaultOptions: LoggerOptions; | 
|  | 63 | +        export interface Foo { | 
|  | 64 | +            foo: string; | 
|  | 65 | +        } | 
|  | 66 | +        export interface Bar { | 
|  | 67 | +            bar: string; | 
|  | 68 | +        } | 
|  | 69 | +        export interface Baz { | 
|  | 70 | +            baz: string; | 
|  | 71 | +        } | 
|  | 72 | +        ", | 
|  | 73 | +        } | 
|  | 74 | +      `); | 
|  | 75 | +    }); | 
| 72 | 76 | 
 | 
| 73 |  | -test('redirect.dts.path: false with redirect.dts.extension: false', async () => { | 
| 74 |  | -  expect(contents.esm1).toMatchInlineSnapshot(` | 
|  | 77 | +    test('redirect.dts.path: false with redirect.dts.extension: false', async () => { | 
|  | 78 | +      expect(contents.esm1).toMatchInlineSnapshot(` | 
| 75 | 79 |     { | 
| 76 | 80 |       "<ROOT>/tests/integration/redirect/dts-tsgo/dist/path-false/esm/.hidden-folder/index.d.ts": "export declare const hiddenFolder = "This is a hidden folder"; | 
| 77 | 81 |     ", | 
| @@ -129,10 +133,10 @@ test('redirect.dts.path: false with redirect.dts.extension: false', async () => | 
| 129 | 133 |     ", | 
| 130 | 134 |     } | 
| 131 | 135 |   `); | 
| 132 |  | -}); | 
|  | 136 | +    }); | 
| 133 | 137 | 
 | 
| 134 |  | -test('redirect.dts.path: true with redirect.dts.extension: true', async () => { | 
| 135 |  | -  expect(contents.esm2).toMatchInlineSnapshot(` | 
|  | 138 | +    test('redirect.dts.path: true with redirect.dts.extension: true', async () => { | 
|  | 139 | +      expect(contents.esm2).toMatchInlineSnapshot(` | 
| 136 | 140 |     { | 
| 137 | 141 |       "<ROOT>/tests/integration/redirect/dts-tsgo/dist/extension-true/esm/.hidden-folder/index.d.ts": "export declare const hiddenFolder = "This is a hidden folder"; | 
| 138 | 142 |     ", | 
| @@ -190,10 +194,10 @@ test('redirect.dts.path: true with redirect.dts.extension: true', async () => { | 
| 190 | 194 |     ", | 
| 191 | 195 |     } | 
| 192 | 196 |   `); | 
| 193 |  | -}); | 
|  | 197 | +    }); | 
| 194 | 198 | 
 | 
| 195 |  | -test('redirect.dts.path: false with dts.redirect.extension: true', async () => { | 
| 196 |  | -  expect(contents.esm3).toMatchInlineSnapshot(` | 
|  | 199 | +    test('redirect.dts.path: false with dts.redirect.extension: true', async () => { | 
|  | 200 | +      expect(contents.esm3).toMatchInlineSnapshot(` | 
| 197 | 201 |     { | 
| 198 | 202 |       "<ROOT>/tests/integration/redirect/dts-tsgo/dist/path-false-extension-true/esm/.hidden-folder/index.d.ts": "export declare const hiddenFolder = "This is a hidden folder"; | 
| 199 | 203 |     ", | 
| @@ -251,10 +255,10 @@ test('redirect.dts.path: false with dts.redirect.extension: true', async () => { | 
| 251 | 255 |     ", | 
| 252 | 256 |     } | 
| 253 | 257 |   `); | 
| 254 |  | -}); | 
|  | 258 | +    }); | 
| 255 | 259 | 
 | 
| 256 |  | -test('redirect.dts.extension: true with dts.autoExtension: true', async () => { | 
| 257 |  | -  expect(contents.esm4).toMatchInlineSnapshot(` | 
|  | 260 | +    test('redirect.dts.extension: true with dts.autoExtension: true', async () => { | 
|  | 261 | +      expect(contents.esm4).toMatchInlineSnapshot(` | 
| 258 | 262 |     { | 
| 259 | 263 |       "<ROOT>/tests/integration/redirect/dts-tsgo/dist/auto-extension-true/esm/.hidden-folder/index.d.mts": "export declare const hiddenFolder = "This is a hidden folder"; | 
| 260 | 264 |     ", | 
| @@ -312,7 +316,7 @@ test('redirect.dts.extension: true with dts.autoExtension: true', async () => { | 
| 312 | 316 |     ", | 
| 313 | 317 |     } | 
| 314 | 318 |   `); | 
| 315 |  | -  expect(contents.cjs).toMatchInlineSnapshot(` | 
|  | 319 | +      expect(contents.cjs).toMatchInlineSnapshot(` | 
| 316 | 320 |     { | 
| 317 | 321 |       "<ROOT>/tests/integration/redirect/dts-tsgo/dist/auto-extension-true/cjs/.hidden-folder/index.d.ts": "export declare const hiddenFolder = "This is a hidden folder"; | 
| 318 | 322 |     ", | 
| @@ -370,4 +374,6 @@ test('redirect.dts.extension: true with dts.autoExtension: true', async () => { | 
| 370 | 374 |     ", | 
| 371 | 375 |     } | 
| 372 | 376 |   `); | 
| 373 |  | -}); | 
|  | 377 | +    }); | 
|  | 378 | +  }, | 
|  | 379 | +); | 
0 commit comments