Skip to content

Commit e9c595e

Browse files
committed
chore: update the test suite name
1 parent e3907d4 commit e9c595e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1089
-19
lines changed

.prettierignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ doc_build
77
**/*.js
88
**/*.ts
99
**/*.jsx
10-
**/*.tsx
10+
**/*.tsx
11+
12+
# ignore pnpm-lock
13+
pnpm-lock.yaml

biome.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
"enabled": false
3535
}
3636
},
37+
"css": {
38+
"formatter": {
39+
"enabled": false
40+
}
41+
},
3742
"linter": {
3843
"enabled": true,
3944
"ignore": ["./tests/integration/**/*/src/*"],
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@import 'https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css';
2+
@import url('https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css');
3+
@import url('lib1.css');
4+
@import 'lib2.css';
5+
6+
.import {
7+
background-image: url('https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css');
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.lib1 {
2+
color: red;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.lib2 {
2+
color: green;
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "@rslib/tsconfig/base",
3+
"compilerOptions": {
4+
"baseUrl": "./"
5+
},
6+
"include": ["src"]
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "css-bundle-false-test",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module"
6+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper';
2+
import { defineConfig } from '@rslib/core';
3+
4+
export default defineConfig({
5+
lib: [
6+
generateBundleEsmConfig({ bundle: false }),
7+
generateBundleCjsConfig({ bundle: false }),
8+
],
9+
source: {
10+
entry: {
11+
index: ['../__fixtures__/src/**/*.css'],
12+
},
13+
},
14+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "css-bundle-test",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module"
6+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper';
2+
import { defineConfig } from '@rslib/core';
3+
4+
export default defineConfig({
5+
lib: [generateBundleEsmConfig(), generateBundleCjsConfig()],
6+
source: {
7+
entry: {
8+
index: '../__fixtures__/src/import.css',
9+
},
10+
},
11+
});

e2e/cases/style/css/index.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { join } from 'node:path';
2+
import { buildAndGetResults } from '@e2e/helper';
3+
import { expect, test } from 'vitest';
4+
5+
test('should run build successfully when set bundle: true', async () => {
6+
const fixturePath = join(__dirname, 'bundle');
7+
const { contents } = await buildAndGetResults(fixturePath, 'css');
8+
const esmFiles = Object.keys(contents.esm);
9+
10+
expect(esmFiles).toMatchInlineSnapshot(`
11+
[
12+
"<ROOT>/e2e/cases/style/css/bundle/dist/esm/static/css/index.css",
13+
]
14+
`);
15+
16+
const cjsFiles = Object.keys(contents.cjs);
17+
expect(cjsFiles).toMatchInlineSnapshot(`
18+
[
19+
"<ROOT>/e2e/cases/style/css/bundle/dist/cjs/static/css/index.css",
20+
]
21+
`);
22+
});
23+
24+
test('should run build successfully when set bundle: false', async () => {
25+
const fixturePath = join(__dirname, 'bundle-false');
26+
const { contents } = await buildAndGetResults(fixturePath, 'css');
27+
const esmFiles = Object.keys(contents.esm);
28+
29+
expect(esmFiles).toMatchInlineSnapshot(`
30+
[
31+
"<ROOT>/e2e/cases/style/css/bundle-false/dist/esm/import.css",
32+
"<ROOT>/e2e/cases/style/css/bundle-false/dist/esm/lib1.css",
33+
"<ROOT>/e2e/cases/style/css/bundle-false/dist/esm/lib2.css",
34+
]
35+
`);
36+
37+
const cjsFiles = Object.keys(contents.cjs);
38+
expect(cjsFiles).toMatchInlineSnapshot(`
39+
[
40+
"<ROOT>/e2e/cases/style/css/bundle-false/dist/cjs/import.css",
41+
"<ROOT>/e2e/cases/style/css/bundle-false/dist/cjs/lib1.css",
42+
"<ROOT>/e2e/cases/style/css/bundle-false/dist/cjs/lib2.css",
43+
]
44+
`);
45+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!node_modules
2+
node_modules/.*

e2e/cases/style/sass/__fixtures__/node_modules/lib1/index.css

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/cases/style/sass/__fixtures__/node_modules/lib1/package.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
code {
2+
padding: 0.25em;
3+
line-height: 0;
4+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ul,
2+
ol {
3+
text-align: left;
4+
5+
& & {
6+
padding: {
7+
bottom: 0;
8+
left: 0;
9+
}
10+
}
11+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
// background: url(./logo.svg);
3+
}
Lines changed: 7 additions & 0 deletions
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@import 'foundation/code', 'foundation/lists';
2+
// TODO: Error: Sass variables aren't allowed in plain CSS.
3+
// @import '~lib1/index.css';
4+
@import './foundation/index.scss';
5+
6+
// TODO: asset support
7+
// $url: './foundation/logo.svg';
8+
$border-dark: rgba($base-color, 0.88);
9+
10+
// .url-variable {
11+
// background: url($url);
12+
// }
13+
14+
.alert {
15+
border: 1px solid $border-dark;
16+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "sass-bundle-false-test",
3+
"version": "1.0.0",
4+
"private": true
5+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper';
2+
import { pluginSass } from '@rsbuild/plugin-sass';
3+
import { defineConfig } from '@rslib/core';
4+
5+
export default defineConfig({
6+
lib: [
7+
generateBundleEsmConfig({ bundle: false }),
8+
generateBundleCjsConfig({ bundle: false }),
9+
],
10+
tools: {},
11+
source: {
12+
entry: {
13+
index: [
14+
'../__fixtures__/src/**/*.scss',
15+
// TODO: assets support
16+
// '../__fixtures__/foundation/logo.svg'
17+
],
18+
},
19+
},
20+
plugins: [
21+
pluginSass({
22+
sassLoaderOptions: {
23+
additionalData: '$base-color: #c6538c;',
24+
},
25+
}),
26+
],
27+
// output: {
28+
// dataUriLimit: {
29+
// svg: 0
30+
// }
31+
// }
32+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "sass-bundle-test",
3+
"version": "1.0.0",
4+
"private": true
5+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper';
2+
import { pluginSass } from '@rsbuild/plugin-sass';
3+
import { defineConfig } from '@rslib/core';
4+
5+
export default defineConfig({
6+
lib: [generateBundleEsmConfig(), generateBundleCjsConfig()],
7+
source: {
8+
entry: {
9+
index: ['../__fixtures__/src/index.scss'],
10+
},
11+
},
12+
plugins: [
13+
pluginSass({
14+
sassLoaderOptions: {
15+
additionalData: '$base-color: #c6538c;',
16+
},
17+
}),
18+
],
19+
// output: {
20+
// dataUriLimit: {
21+
// svg: 0
22+
// }
23+
// }
24+
});

e2e/cases/style/sass/index.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { join } from 'node:path';
2+
import { buildAndGetResults } from '@e2e/helper';
3+
import { expect, test } from 'vitest';
4+
5+
test('should extract css with pluginSass when set bundle: true', async () => {
6+
const fixturePath = join(__dirname, 'bundle');
7+
const { contents } = await buildAndGetResults(fixturePath, 'css');
8+
const esmFiles = Object.keys(contents.esm);
9+
expect(esmFiles).toMatchInlineSnapshot(`
10+
[
11+
"<ROOT>/e2e/cases/style/sass/bundle/dist/esm/static/css/index.css",
12+
]
13+
`);
14+
15+
const cjsFiles = Object.keys(contents.cjs);
16+
expect(cjsFiles).toMatchInlineSnapshot(`
17+
[
18+
"<ROOT>/e2e/cases/style/sass/bundle/dist/cjs/static/css/index.css",
19+
]
20+
`);
21+
});
22+
23+
test('should extract css with pluginSass when set bundle: false', async () => {
24+
const fixturePath = join(__dirname, 'bundle-false');
25+
const { contents } = await buildAndGetResults(fixturePath, 'css');
26+
const esmFiles = Object.keys(contents.esm);
27+
28+
expect(esmFiles).toMatchInlineSnapshot(`
29+
[
30+
"<ROOT>/e2e/cases/style/sass/bundle-false/dist/esm/foundation/_code.css",
31+
"<ROOT>/e2e/cases/style/sass/bundle-false/dist/esm/foundation/_lists.css",
32+
"<ROOT>/e2e/cases/style/sass/bundle-false/dist/esm/index.css",
33+
]
34+
`);
35+
36+
const cjsFiles = Object.keys(contents.cjs);
37+
expect(cjsFiles).toMatchInlineSnapshot(`
38+
[
39+
"<ROOT>/e2e/cases/style/sass/bundle-false/dist/cjs/foundation/_code.css",
40+
"<ROOT>/e2e/cases/style/sass/bundle-false/dist/cjs/foundation/_lists.css",
41+
"<ROOT>/e2e/cases/style/sass/bundle-false/dist/cjs/index.css",
42+
]
43+
`);
44+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@examples/react-component-bundle-false",
3+
"private": true,
4+
"scripts": {
5+
"build": "rslib build"
6+
},
7+
"devDependencies": {
8+
"@rsbuild/plugin-react": "^1.0.2",
9+
"@rsbuild/plugin-sass": "^1.0.1",
10+
"@rslib/core": "workspace:*",
11+
"@types/react": "^18.3.5",
12+
"react": "^18.3.1"
13+
},
14+
"peerDependencies": {
15+
"react": "*"
16+
}
17+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { pluginReact } from '@rsbuild/plugin-react';
2+
import { pluginSass } from '@rsbuild/plugin-sass';
3+
import { type LibConfig, defineConfig } from '@rslib/core';
4+
5+
const shared: LibConfig = {
6+
bundle: false,
7+
// TODO: open dts
8+
// dts: {
9+
// bundle: false,
10+
// },
11+
};
12+
13+
export default defineConfig({
14+
source: {
15+
entry: {
16+
index: ['./src/**', '!./src/env.d.ts'],
17+
},
18+
},
19+
lib: [
20+
{
21+
...shared,
22+
format: 'esm',
23+
output: {
24+
distPath: {
25+
root: './dist/esm',
26+
},
27+
},
28+
},
29+
{
30+
...shared,
31+
format: 'cjs',
32+
output: {
33+
distPath: {
34+
root: './dist/cjs',
35+
},
36+
},
37+
},
38+
],
39+
plugins: [pluginReact(), pluginSass()],
40+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.button {
2+
background: blue;
3+
}

examples/react-component/src/CounterButton.tsx renamed to examples/react-component-bundle-false/src/CounterButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import styles from './CounterButton.module.scss';
12
interface CounterButtonProps {
23
onClick: () => void;
34
label: string;
@@ -7,7 +8,7 @@ export const CounterButton: React.FC<CounterButtonProps> = ({
78
onClick,
89
label,
910
}) => (
10-
<button type="button" onClick={onClick}>
11+
<button type="button" className={styles.button} onClick={onClick}>
1112
{label}
1213
</button>
1314
);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
declare module '*.module.css' {
2+
const classes: { [key: string]: string };
3+
export default classes;
4+
}
5+
6+
declare module '*.module.scss' {
7+
const classes: { [key: string]: string };
8+
export default classes;
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.body {
2+
background: red;
3+
}

0 commit comments

Comments
 (0)