Skip to content

Commit aed344b

Browse files
committed
feat: add raw-false tests
1 parent e052b2e commit aed344b

File tree

13 files changed

+138
-3
lines changed

13 files changed

+138
-3
lines changed

tests/integration/banner-footer/index.test.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import path from 'node:path';
12
import { buildAndGetResults } from 'test-helper';
23
import { expect, test } from 'vitest';
34

@@ -10,8 +11,7 @@ enum BannerFooter {
1011
DTS_FOOTER = '/*! hello footer dts */',
1112
}
1213

13-
test('banner and footer should work in js, css and dts', async () => {
14-
const fixturePath = __dirname;
14+
const testBannerAndFooter = async (fixturePath: string) => {
1515
const { js, css, dts } = await buildAndGetResults({
1616
fixturePath,
1717
type: 'all',
@@ -57,4 +57,16 @@ test('banner and footer should work in js, css and dts', async () => {
5757
checkBannerAndFooter(jsContents, 'js');
5858
checkBannerAndFooter(cssContents, 'css');
5959
checkBannerAndFooter(dtsContents, 'dts');
60+
};
61+
62+
test('banner and footer should work in js, css and dts', async () => {
63+
const fixturePath = path.join(__dirname, 'raw');
64+
65+
testBannerAndFooter(fixturePath);
66+
});
67+
68+
test('banner and footer should work in js, css, and dts with raw option set to false', async () => {
69+
const fixturePath = path.join(__dirname, 'raw-false');
70+
71+
testBannerAndFooter(fixturePath);
6072
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "banner-footer-raw-false-test",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module"
6+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import { type LibConfig, defineConfig } from '@rslib/core';
2+
import { generateBundleCjsConfig, generateBundleEsmConfig } from 'test-helper';
3+
4+
const bannerFooterConfig: LibConfig = {
5+
banner: {
6+
js: 'hello banner js',
7+
css: 'hello banner css',
8+
dts: 'hello banner dts',
9+
raw: false,
10+
},
11+
footer: {
12+
js: 'hello footer js',
13+
css: 'hello footer css',
14+
dts: 'hello footer dts',
15+
raw: false,
16+
},
17+
};
18+
19+
export default defineConfig({
20+
lib: [
21+
// bundle esm
22+
generateBundleEsmConfig({
23+
output: {
24+
distPath: {
25+
root: './dist/esm/bundle',
26+
},
27+
},
28+
dts: {
29+
bundle: true,
30+
},
31+
...bannerFooterConfig,
32+
}),
33+
// bundle cjs
34+
generateBundleCjsConfig({
35+
output: {
36+
distPath: {
37+
root: './dist/cjs/bundle',
38+
},
39+
},
40+
dts: {
41+
bundle: true,
42+
},
43+
...bannerFooterConfig,
44+
}),
45+
// bundleless esm
46+
generateBundleEsmConfig({
47+
output: {
48+
distPath: {
49+
root: './dist/esm/bundleless',
50+
},
51+
},
52+
bundle: false,
53+
dts: {
54+
bundle: false,
55+
},
56+
// TODO: bundleless css
57+
source: {
58+
entry: {
59+
index: ['./src/**/*.ts'],
60+
},
61+
},
62+
...bannerFooterConfig,
63+
}),
64+
// bundleless cjs
65+
generateBundleCjsConfig({
66+
output: {
67+
distPath: {
68+
root: './dist/cjs/bundleless',
69+
},
70+
},
71+
bundle: false,
72+
dts: {
73+
bundle: false,
74+
},
75+
// TODO: bundleless css
76+
source: {
77+
entry: {
78+
index: ['./src/**/*.ts'],
79+
},
80+
},
81+
...bannerFooterConfig,
82+
}),
83+
// bundle esm with minify enabled
84+
generateBundleEsmConfig({
85+
output: {
86+
distPath: {
87+
root: './dist/esm/bundle-minify',
88+
},
89+
minify: true,
90+
},
91+
dts: {
92+
bundle: true,
93+
},
94+
...bannerFooterConfig,
95+
}),
96+
],
97+
source: {
98+
entry: {
99+
index: './src/index.ts',
100+
},
101+
},
102+
});

tests/integration/banner-footer/package.json renamed to tests/integration/banner-footer/raw/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "banner-footer-test",
2+
"name": "banner-footer-raw-test",
33
"version": "1.0.0",
44
"private": true,
55
"type": "module"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const foo = 'foo';

0 commit comments

Comments
 (0)