-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests of dts: false and dts.distPath
- Loading branch information
1 parent
140f955
commit e32c05a
Showing
8 changed files
with
149 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper'; | ||
import { defineConfig } from '@rslib/core'; | ||
|
||
export default defineConfig({ | ||
lib: [ | ||
generateBundleEsmConfig(__dirname, { | ||
bundle: false, | ||
dts: { | ||
bundle: false, | ||
distPath: './dist/custom', | ||
}, | ||
}), | ||
generateBundleCjsConfig(__dirname, { | ||
bundle: false, | ||
}), | ||
], | ||
source: { | ||
entry: { | ||
main: ['./src/**'], | ||
}, | ||
}, | ||
}); |
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,19 @@ | ||
import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper'; | ||
import { defineConfig } from '@rslib/core'; | ||
|
||
export default defineConfig({ | ||
lib: [ | ||
generateBundleEsmConfig(__dirname, { | ||
bundle: false, | ||
dts: false, | ||
}), | ||
generateBundleCjsConfig(__dirname, { | ||
bundle: false, | ||
}), | ||
], | ||
source: { | ||
entry: { | ||
main: ['./src/**'], | ||
}, | ||
}, | ||
}); |
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,19 @@ | ||
import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper'; | ||
import { defineConfig } from '@rslib/core'; | ||
|
||
export default defineConfig({ | ||
lib: [ | ||
generateBundleEsmConfig(__dirname, { | ||
dts: { | ||
bundle: true, | ||
distPath: './dist/custom', | ||
}, | ||
}), | ||
generateBundleCjsConfig(__dirname), | ||
], | ||
source: { | ||
entry: { | ||
main: './src/index.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,16 @@ | ||
import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper'; | ||
import { defineConfig } from '@rslib/core'; | ||
|
||
export default defineConfig({ | ||
lib: [ | ||
generateBundleEsmConfig(__dirname, { | ||
dts: false, | ||
}), | ||
generateBundleCjsConfig(__dirname), | ||
], | ||
source: { | ||
entry: { | ||
main: './src/index.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 |
---|---|---|
@@ -1,20 +1,76 @@ | ||
import { join } from 'node:path'; | ||
import { buildAndGetResults } from '@e2e/helper'; | ||
import { expect, test } from 'vitest'; | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
test('dts when bundle: false', async () => { | ||
const fixturePath = join(__dirname, 'bundle-false'); | ||
const { files, contents } = await buildAndGetResults(fixturePath, 'dts'); | ||
describe('dts when bundle: false', () => { | ||
test('basic - bundleless dts', async () => { | ||
const fixturePath = join(__dirname, 'bundle-false'); | ||
const { files, contents } = await buildAndGetResults( | ||
fixturePath, | ||
'rslib.config.ts', | ||
'dts', | ||
); | ||
|
||
expect(files.esm?.length).toBe(4); | ||
expect(files.esm?.[0]!.endsWith('.d.ts')).toEqual(true); | ||
expect(contents.esm).toMatchSnapshot(); | ||
expect(files.esm?.length).toBe(4); | ||
expect(files.esm?.[0]!.endsWith('.d.ts')).toEqual(true); | ||
expect(contents.esm).toMatchSnapshot(); | ||
}); | ||
|
||
test('dts false - bundleless dts', async () => { | ||
const fixturePath = join(__dirname, 'bundle-false'); | ||
const { files } = await buildAndGetResults( | ||
fixturePath, | ||
'rslib.false.config.ts', | ||
'dts', | ||
); | ||
|
||
expect(files.esm).toBe(undefined); | ||
}); | ||
|
||
test('distPath - bundleless dts', async () => { | ||
const fixturePath = join(__dirname, 'bundle-false'); | ||
const { files } = await buildAndGetResults( | ||
fixturePath, | ||
'rslib.distpath.config.ts', | ||
'dts', | ||
); | ||
expect(files.esm?.length).toBe(4); | ||
expect(files.esm?.[0]!.startsWith('./dist/custom')).toEqual(true); | ||
}); | ||
}); | ||
|
||
test('dts when bundle: true', async () => { | ||
const fixturePath = join(__dirname, 'bundle'); | ||
const { entryFiles, entries } = await buildAndGetResults(fixturePath, 'dts'); | ||
describe('dts when bundle: true', () => { | ||
test('basic - bundle dts', async () => { | ||
const fixturePath = join(__dirname, 'bundle'); | ||
const { entryFiles, entries } = await buildAndGetResults( | ||
fixturePath, | ||
'rslib.config.ts', | ||
'dts', | ||
); | ||
|
||
expect(entryFiles.esm!.endsWith('index.d.ts')).toEqual(true); | ||
expect(entries).toMatchSnapshot(); | ||
}); | ||
|
||
test('dts false - bundle dts', async () => { | ||
const fixturePath = join(__dirname, 'bundle'); | ||
const { entryFiles } = await buildAndGetResults( | ||
fixturePath, | ||
'rslib.false.config.ts', | ||
'dts', | ||
); | ||
|
||
expect(entryFiles.esm).toEqual(undefined); | ||
}); | ||
|
||
test('distPath - bundle dts', async () => { | ||
const fixturePath = join(__dirname, 'bundle'); | ||
const { entryFiles } = await buildAndGetResults( | ||
fixturePath, | ||
'rslib.distpath.config.ts', | ||
'dts', | ||
); | ||
|
||
expect(entryFiles.esm!.endsWith('index.d.ts')).toEqual(true); | ||
expect(entries).toMatchSnapshot(); | ||
expect(entryFiles.esm!.startsWith('./dist/custom')).toEqual(true); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -22,6 +22,7 @@ craco | |
crossorigin | ||
datauri | ||
deepmerge | ||
distpath | ||
docgen | ||
dogfooding | ||
envinfo | ||
|