create-rslib 0.12.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/index.js +117 -20
  2. package/package.json +2 -2
  3. package/template-[node-dual]-[rstest]-js/package.json +24 -0
  4. package/template-[node-dual]-[rstest]-js/rslib.config.mjs +14 -0
  5. package/template-[node-dual]-[rstest]-js/rstest.config.js +3 -0
  6. package/template-[node-dual]-[rstest]-js/src/index.js +1 -0
  7. package/template-[node-dual]-[rstest]-js/tests/index.test.js +7 -0
  8. package/template-[node-dual]-[rstest]-ts/package.json +28 -0
  9. package/template-[node-dual]-[rstest]-ts/rslib.config.ts +15 -0
  10. package/template-[node-dual]-[rstest]-ts/rstest.config.ts +3 -0
  11. package/template-[node-dual]-[rstest]-ts/src/index.ts +1 -0
  12. package/template-[node-dual]-[rstest]-ts/tests/index.test.ts +7 -0
  13. package/template-[node-dual]-[rstest]-ts/tsconfig.json +15 -0
  14. package/template-[node-esm]-[rstest]-js/package.json +22 -0
  15. package/template-[node-esm]-[rstest]-js/rslib.config.mjs +10 -0
  16. package/template-[node-esm]-[rstest]-js/rstest.config.js +3 -0
  17. package/template-[node-esm]-[rstest]-js/src/index.js +1 -0
  18. package/template-[node-esm]-[rstest]-js/tests/index.test.js +7 -0
  19. package/template-[node-esm]-[rstest]-ts/package.json +26 -0
  20. package/template-[node-esm]-[rstest]-ts/rslib.config.ts +11 -0
  21. package/template-[node-esm]-[rstest]-ts/rstest.config.ts +3 -0
  22. package/template-[node-esm]-[rstest]-ts/src/index.ts +1 -0
  23. package/template-[node-esm]-[rstest]-ts/tests/index.test.ts +7 -0
  24. package/template-[node-esm]-[rstest]-ts/tsconfig.json +15 -0
  25. package/template-[react]-[rstest,storybook]-js/.storybook/main.js +36 -0
  26. package/template-[react]-[rstest,storybook]-js/.storybook/preview.js +12 -0
  27. package/template-[react]-[rstest,storybook]-js/package.json +45 -0
  28. package/template-[react]-[rstest,storybook]-js/rslib.config.mjs +20 -0
  29. package/template-[react]-[rstest,storybook]-js/rstest.config.js +8 -0
  30. package/template-[react]-[rstest,storybook]-js/rstest.setup.js +4 -0
  31. package/template-[react]-[rstest,storybook]-js/src/Button.jsx +21 -0
  32. package/template-[react]-[rstest,storybook]-js/src/button.css +34 -0
  33. package/template-[react]-[rstest,storybook]-js/src/index.jsx +1 -0
  34. package/template-[react]-[rstest,storybook]-js/stories/Button.stories.jsx +50 -0
  35. package/template-[react]-[rstest,storybook]-js/tests/index.test.jsx +11 -0
  36. package/template-[react]-[rstest,storybook]-ts/.storybook/main.ts +37 -0
  37. package/template-[react]-[rstest,storybook]-ts/.storybook/preview.ts +14 -0
  38. package/template-[react]-[rstest,storybook]-ts/package.json +49 -0
  39. package/template-[react]-[rstest,storybook]-ts/rslib.config.ts +21 -0
  40. package/template-[react]-[rstest,storybook]-ts/rstest.config.ts +8 -0
  41. package/template-[react]-[rstest,storybook]-ts/rstest.setup.ts +4 -0
  42. package/template-[react]-[rstest,storybook]-ts/src/Button.tsx +29 -0
  43. package/template-[react]-[rstest,storybook]-ts/src/button.css +34 -0
  44. package/template-[react]-[rstest,storybook]-ts/src/index.tsx +1 -0
  45. package/template-[react]-[rstest,storybook]-ts/stories/Button.stories.ts +52 -0
  46. package/template-[react]-[rstest,storybook]-ts/tests/index.test.tsx +11 -0
  47. package/template-[react]-[rstest,storybook]-ts/tests/test.d.ts +1 -0
  48. package/template-[react]-[rstest,storybook]-ts/tests/tsconfig.json +4 -0
  49. package/template-[react]-[rstest,storybook]-ts/tsconfig.json +14 -0
  50. package/template-[react]-[rstest]-js/package.json +31 -0
  51. package/template-[react]-[rstest]-js/rslib.config.mjs +20 -0
  52. package/template-[react]-[rstest]-js/rstest.config.js +8 -0
  53. package/template-[react]-[rstest]-js/rstest.setup.js +4 -0
  54. package/template-[react]-[rstest]-js/src/Button.jsx +21 -0
  55. package/template-[react]-[rstest]-js/src/button.css +34 -0
  56. package/template-[react]-[rstest]-js/src/index.jsx +1 -0
  57. package/template-[react]-[rstest]-js/tests/index.test.jsx +11 -0
  58. package/template-[react]-[rstest]-ts/package.json +35 -0
  59. package/template-[react]-[rstest]-ts/rslib.config.ts +21 -0
  60. package/template-[react]-[rstest]-ts/rstest.config.ts +8 -0
  61. package/template-[react]-[rstest]-ts/rstest.setup.ts +4 -0
  62. package/template-[react]-[rstest]-ts/src/Button.tsx +29 -0
  63. package/template-[react]-[rstest]-ts/src/button.css +34 -0
  64. package/template-[react]-[rstest]-ts/src/index.tsx +1 -0
  65. package/template-[react]-[rstest]-ts/tests/index.test.tsx +11 -0
  66. package/template-[react]-[rstest]-ts/tests/test.d.ts +1 -0
  67. package/template-[react]-[rstest]-ts/tests/tsconfig.json +4 -0
  68. package/template-[react]-[rstest]-ts/tsconfig.json +14 -0
  69. package/template-[react]-[storybook,vitest]-js/package.json +1 -1
  70. package/template-[react]-[storybook,vitest]-ts/package.json +1 -1
  71. package/template-[react]-[storybook]-js/package.json +1 -1
  72. package/template-[react]-[storybook]-ts/package.json +1 -1
  73. package/template-[vue]-[rstest,storybook]-js/.storybook/main.js +35 -0
  74. package/template-[vue]-[rstest,storybook]-js/.storybook/preview.js +12 -0
  75. package/template-[vue]-[rstest,storybook]-js/package.json +47 -0
  76. package/template-[vue]-[rstest,storybook]-js/rslib.config.ts +15 -0
  77. package/template-[vue]-[rstest,storybook]-js/rstest.config.js +8 -0
  78. package/template-[vue]-[rstest,storybook]-js/rstest.setup.js +4 -0
  79. package/template-[vue]-[rstest,storybook]-js/src/Button.vue +43 -0
  80. package/template-[vue]-[rstest,storybook]-js/src/index.js +1 -0
  81. package/template-[vue]-[rstest,storybook]-js/src/style.css +34 -0
  82. package/template-[vue]-[rstest,storybook]-js/stories/Button.stories.js +50 -0
  83. package/template-[vue]-[rstest,storybook]-js/tests/index.test.js +16 -0
  84. package/template-[vue]-[rstest,storybook]-ts/.storybook/main.ts +36 -0
  85. package/template-[vue]-[rstest,storybook]-ts/.storybook/preview.ts +12 -0
  86. package/template-[vue]-[rstest,storybook]-ts/package.json +49 -0
  87. package/template-[vue]-[rstest,storybook]-ts/rslib.config.ts +15 -0
  88. package/template-[vue]-[rstest,storybook]-ts/rstest.config.ts +8 -0
  89. package/template-[vue]-[rstest,storybook]-ts/rstest.setup.ts +4 -0
  90. package/template-[vue]-[rstest,storybook]-ts/src/Button.vue +35 -0
  91. package/template-[vue]-[rstest,storybook]-ts/src/index.ts +1 -0
  92. package/template-[vue]-[rstest,storybook]-ts/src/style.css +34 -0
  93. package/template-[vue]-[rstest,storybook]-ts/stories/Button.stories.js +50 -0
  94. package/template-[vue]-[rstest,storybook]-ts/tests/index.test.ts +16 -0
  95. package/template-[vue]-[rstest,storybook]-ts/tests/test.d.ts +1 -0
  96. package/template-[vue]-[rstest,storybook]-ts/tests/tsconfig.json +4 -0
  97. package/template-[vue]-[rstest,storybook]-ts/tsconfig.json +24 -0
  98. package/template-[vue]-[rstest]-js/package.json +33 -0
  99. package/template-[vue]-[rstest]-js/rslib.config.ts +15 -0
  100. package/template-[vue]-[rstest]-js/rstest.config.js +8 -0
  101. package/template-[vue]-[rstest]-js/rstest.setup.js +4 -0
  102. package/template-[vue]-[rstest]-js/src/Button.vue +43 -0
  103. package/template-[vue]-[rstest]-js/src/index.js +1 -0
  104. package/template-[vue]-[rstest]-js/src/style.css +34 -0
  105. package/template-[vue]-[rstest]-js/tests/index.test.js +16 -0
  106. package/template-[vue]-[rstest]-ts/package.json +35 -0
  107. package/template-[vue]-[rstest]-ts/rslib.config.ts +15 -0
  108. package/template-[vue]-[rstest]-ts/rstest.config.ts +8 -0
  109. package/template-[vue]-[rstest]-ts/rstest.setup.ts +4 -0
  110. package/template-[vue]-[rstest]-ts/src/Button.vue +35 -0
  111. package/template-[vue]-[rstest]-ts/src/index.ts +1 -0
  112. package/template-[vue]-[rstest]-ts/src/style.css +34 -0
  113. package/template-[vue]-[rstest]-ts/tests/index.test.ts +16 -0
  114. package/template-[vue]-[rstest]-ts/tests/test.d.ts +1 -0
  115. package/template-[vue]-[rstest]-ts/tests/tsconfig.json +4 -0
  116. package/template-[vue]-[rstest]-ts/tsconfig.json +24 -0
  117. package/template-[vue]-[storybook,vitest]-js/package.json +1 -1
  118. package/template-[vue]-[storybook,vitest]-ts/package.json +1 -1
  119. package/template-[vue]-[storybook]-js/package.json +1 -1
  120. package/template-[vue]-[storybook]-ts/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import "node:fs";
6
6
  const helpers_filename = fileURLToPath(import.meta.url);
7
7
  const helpers_dirname = node_path.dirname(helpers_filename);
8
8
  node_path.resolve(helpers_dirname, '../fragments');
9
- const composeTemplateName = ({ template, tools, lang })=>`[${template}]-[${(tools ? Object.keys(tools) : []).sort()}]-${lang}`;
9
+ const composeTemplateName = ({ template, tools, lang })=>`[${template}]-[${(tools ? tools.sort() : []).join(',')}]-${lang}`;
10
10
  const TEMPLATES = [
11
11
  {
12
12
  template: 'node-dual',
@@ -30,6 +30,20 @@ const TEMPLATES = [
30
30
  vitest: 'vitest-node-ts'
31
31
  }
32
32
  },
33
+ {
34
+ template: 'node-dual',
35
+ lang: 'js',
36
+ tools: {
37
+ rstest: 'rstest-node-js'
38
+ }
39
+ },
40
+ {
41
+ template: 'node-dual',
42
+ lang: 'ts',
43
+ tools: {
44
+ rstest: 'rstest-node-ts'
45
+ }
46
+ },
33
47
  {
34
48
  template: 'node-esm',
35
49
  lang: 'js'
@@ -52,6 +66,20 @@ const TEMPLATES = [
52
66
  vitest: 'vitest-node-ts'
53
67
  }
54
68
  },
69
+ {
70
+ template: 'node-esm',
71
+ lang: 'js',
72
+ tools: {
73
+ rstest: 'rstest-node-js'
74
+ }
75
+ },
76
+ {
77
+ template: 'node-esm',
78
+ lang: 'ts',
79
+ tools: {
80
+ rstest: 'rstest-node-ts'
81
+ }
82
+ },
55
83
  {
56
84
  template: 'react',
57
85
  lang: 'js'
@@ -70,6 +98,13 @@ const TEMPLATES = [
70
98
  vitest: 'vitest-react-js'
71
99
  }
72
100
  },
101
+ {
102
+ template: 'react',
103
+ lang: 'js',
104
+ tools: {
105
+ rstest: 'rstest-react-js'
106
+ }
107
+ },
73
108
  {
74
109
  template: 'react',
75
110
  lang: 'js',
@@ -78,6 +113,14 @@ const TEMPLATES = [
78
113
  vitest: 'vitest-react-js'
79
114
  }
80
115
  },
116
+ {
117
+ template: 'react',
118
+ lang: 'js',
119
+ tools: {
120
+ storybook: 'storybook-react-js',
121
+ rstest: 'rstest-react-js'
122
+ }
123
+ },
81
124
  {
82
125
  template: 'react',
83
126
  lang: 'ts'
@@ -96,6 +139,13 @@ const TEMPLATES = [
96
139
  vitest: 'vitest-react-ts'
97
140
  }
98
141
  },
142
+ {
143
+ template: 'react',
144
+ lang: 'ts',
145
+ tools: {
146
+ rstest: 'rstest-react-ts'
147
+ }
148
+ },
99
149
  {
100
150
  template: 'react',
101
151
  lang: 'ts',
@@ -104,6 +154,14 @@ const TEMPLATES = [
104
154
  vitest: 'vitest-react-ts'
105
155
  }
106
156
  },
157
+ {
158
+ template: 'react',
159
+ lang: 'ts',
160
+ tools: {
161
+ storybook: 'storybook-react-ts',
162
+ rstest: 'rstest-react-ts'
163
+ }
164
+ },
107
165
  {
108
166
  template: 'vue',
109
167
  lang: 'js'
@@ -122,6 +180,13 @@ const TEMPLATES = [
122
180
  vitest: 'vitest-vue-js'
123
181
  }
124
182
  },
183
+ {
184
+ template: 'vue',
185
+ lang: 'js',
186
+ tools: {
187
+ rstest: 'rstest-vue-js'
188
+ }
189
+ },
125
190
  {
126
191
  template: 'vue',
127
192
  lang: 'js',
@@ -130,6 +195,14 @@ const TEMPLATES = [
130
195
  vitest: 'vitest-vue-js'
131
196
  }
132
197
  },
198
+ {
199
+ template: 'vue',
200
+ lang: 'js',
201
+ tools: {
202
+ storybook: 'storybook-vue-js',
203
+ rstest: 'rstest-vue-js'
204
+ }
205
+ },
133
206
  {
134
207
  template: 'vue',
135
208
  lang: 'ts'
@@ -148,6 +221,13 @@ const TEMPLATES = [
148
221
  vitest: 'vitest-vue-ts'
149
222
  }
150
223
  },
224
+ {
225
+ template: 'vue',
226
+ lang: 'ts',
227
+ tools: {
228
+ rstest: 'rstest-vue-ts'
229
+ }
230
+ },
151
231
  {
152
232
  template: 'vue',
153
233
  lang: 'ts',
@@ -155,6 +235,14 @@ const TEMPLATES = [
155
235
  storybook: 'storybook-vue-ts',
156
236
  vitest: 'vitest-vue-ts'
157
237
  }
238
+ },
239
+ {
240
+ template: 'vue',
241
+ lang: 'ts',
242
+ tools: {
243
+ storybook: 'storybook-vue-ts',
244
+ rstest: 'rstest-vue-ts'
245
+ }
158
246
  }
159
247
  ];
160
248
  const src_dirname = node_path.dirname(fileURLToPath(import.meta.url));
@@ -206,27 +294,36 @@ async function getTemplateName({ template }) {
206
294
  'react',
207
295
  'vue'
208
296
  ].includes(templateName);
209
- const tools = checkCancel(await multiselect({
210
- message: 'Select development tools (Use <space> to select, <enter> to continue)',
211
- required: false,
212
- options: [
213
- supportStorybook && {
214
- value: 'storybook',
215
- label: 'Storybook'
216
- },
217
- {
218
- value: 'vitest',
219
- label: 'Vitest'
220
- }
221
- ].filter(Boolean)
222
- }));
297
+ async function selectTools() {
298
+ const tools = checkCancel(await multiselect({
299
+ message: 'Select development tools (Use <space> to select, <enter> to continue)',
300
+ required: false,
301
+ options: [
302
+ supportStorybook && {
303
+ value: 'storybook',
304
+ label: 'Storybook'
305
+ },
306
+ {
307
+ value: 'rstest',
308
+ label: 'Rstest'
309
+ },
310
+ {
311
+ value: 'vitest',
312
+ label: 'Vitest'
313
+ }
314
+ ].filter(Boolean)
315
+ }));
316
+ if (tools.includes('rstest') && tools.includes('vitest')) {
317
+ console.error('You selected both Rstest and Vitest for testing, you should only select one of them.');
318
+ return selectTools();
319
+ }
320
+ return tools;
321
+ }
322
+ const tools = await selectTools();
223
323
  return composeTemplateName({
224
324
  template: templateName,
225
325
  lang: language,
226
- tools: Object.fromEntries(tools.map((tool)=>[
227
- tool,
228
- `vitest-${tool}-${language}`
229
- ]))
326
+ tools
230
327
  });
231
328
  }
232
329
  function mapESLintTemplate(templateName) {
@@ -239,7 +336,7 @@ create({
239
336
  templates: TEMPLATES.map(({ template, tools, lang })=>composeTemplateName({
240
337
  template,
241
338
  lang,
242
- tools
339
+ tools: Object.keys(tools || {})
243
340
  })),
244
341
  getTemplateName,
245
342
  mapESLintTemplate
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-rslib",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Create a new Rslib project",
5
5
  "homepage": "https://rslib.rs",
6
6
  "repository": {
@@ -29,7 +29,7 @@
29
29
  "@types/node": "^22.17.1",
30
30
  "fs-extra": "^11.3.1",
31
31
  "rsbuild-plugin-publint": "^0.3.3",
32
- "rslib": "npm:@rslib/core@0.11.2",
32
+ "rslib": "npm:@rslib/core@0.12.0",
33
33
  "tsx": "^4.20.3",
34
34
  "typescript": "^5.9.2",
35
35
  "@rslib/tsconfig": "0.0.1"
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "rslib-node-dual-js",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "import": "./dist/index.js",
8
+ "require": "./dist/index.cjs"
9
+ }
10
+ },
11
+ "main": "./dist/index.cjs",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "scripts": {
16
+ "build": "rslib build",
17
+ "dev": "rslib build --watch",
18
+ "test": "rstest"
19
+ },
20
+ "devDependencies": {
21
+ "@rslib/core": "workspace:*",
22
+ "@rstest/core": "^0.1.3"
23
+ }
24
+ }
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from '@rslib/core';
2
+
3
+ export default defineConfig({
4
+ lib: [
5
+ {
6
+ format: 'esm',
7
+ syntax: ['node 18'],
8
+ },
9
+ {
10
+ format: 'cjs',
11
+ syntax: ['node 18'],
12
+ },
13
+ ],
14
+ });
@@ -0,0 +1,3 @@
1
+ import { defineConfig } from '@rstest/core';
2
+
3
+ export default defineConfig({});
@@ -0,0 +1 @@
1
+ export const squared = (n) => n * n;
@@ -0,0 +1,7 @@
1
+ import { expect, test } from '@rstest/core';
2
+ import { squared } from '../src/index.js';
3
+
4
+ test('squared', () => {
5
+ expect(squared(2)).toBe(4);
6
+ expect(squared(12)).toBe(144);
7
+ });
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "rslib-node-dual-ts",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.js",
9
+ "require": "./dist/index.cjs"
10
+ }
11
+ },
12
+ "main": "./dist/index.cjs",
13
+ "types": "./dist/index.d.ts",
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "rslib build",
19
+ "dev": "rslib build --watch",
20
+ "test": "rstest"
21
+ },
22
+ "devDependencies": {
23
+ "@rslib/core": "workspace:*",
24
+ "@rstest/core": "^0.1.3",
25
+ "@types/node": "^22.17.1",
26
+ "typescript": "^5.9.2"
27
+ }
28
+ }
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from '@rslib/core';
2
+
3
+ export default defineConfig({
4
+ lib: [
5
+ {
6
+ format: 'esm',
7
+ syntax: ['node 18'],
8
+ dts: true,
9
+ },
10
+ {
11
+ format: 'cjs',
12
+ syntax: ['node 18'],
13
+ },
14
+ ],
15
+ });
@@ -0,0 +1,3 @@
1
+ import { defineConfig } from '@rstest/core';
2
+
3
+ export default defineConfig({});
@@ -0,0 +1 @@
1
+ export const squared = (n: number): number => n * n;
@@ -0,0 +1,7 @@
1
+ import { expect, test } from '@rstest/core';
2
+ import { squared } from '../src/index';
3
+
4
+ test('squared', () => {
5
+ expect(squared(2)).toBe(4);
6
+ expect(squared(12)).toBe(144);
7
+ });
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ES2022"],
4
+ "module": "ESNext",
5
+ "noEmit": true,
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "isolatedModules": true,
9
+ "resolveJsonModule": true,
10
+ "moduleResolution": "bundler",
11
+ "useDefineForClassFields": true,
12
+ "allowImportingTsExtensions": true
13
+ },
14
+ "include": ["src"]
15
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "rslib-node-esm-js",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "import": "./dist/index.js"
8
+ }
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "rslib build",
15
+ "dev": "rslib build --watch",
16
+ "test": "rstest"
17
+ },
18
+ "devDependencies": {
19
+ "@rslib/core": "workspace:*",
20
+ "@rstest/core": "^0.1.3"
21
+ }
22
+ }
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from '@rslib/core';
2
+
3
+ export default defineConfig({
4
+ lib: [
5
+ {
6
+ format: 'esm',
7
+ syntax: ['node 18'],
8
+ },
9
+ ],
10
+ });
@@ -0,0 +1,3 @@
1
+ import { defineConfig } from '@rstest/core';
2
+
3
+ export default defineConfig({});
@@ -0,0 +1 @@
1
+ export const squared = (n) => n * n;
@@ -0,0 +1,7 @@
1
+ import { expect, test } from '@rstest/core';
2
+ import { squared } from '../src/index.js';
3
+
4
+ test('squared', () => {
5
+ expect(squared(2)).toBe(4);
6
+ expect(squared(12)).toBe(144);
7
+ });
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "rslib-node-esm-ts",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.js"
9
+ }
10
+ },
11
+ "types": "./dist/index.d.ts",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "scripts": {
16
+ "build": "rslib build",
17
+ "dev": "rslib build --watch",
18
+ "test": "rstest"
19
+ },
20
+ "devDependencies": {
21
+ "@rslib/core": "workspace:*",
22
+ "@rstest/core": "^0.1.3",
23
+ "@types/node": "^22.17.1",
24
+ "typescript": "^5.9.2"
25
+ }
26
+ }
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from '@rslib/core';
2
+
3
+ export default defineConfig({
4
+ lib: [
5
+ {
6
+ format: 'esm',
7
+ syntax: ['node 18'],
8
+ dts: true,
9
+ },
10
+ ],
11
+ });
@@ -0,0 +1,3 @@
1
+ import { defineConfig } from '@rstest/core';
2
+
3
+ export default defineConfig({});
@@ -0,0 +1 @@
1
+ export const squared = (n: number): number => n * n;
@@ -0,0 +1,7 @@
1
+ import { expect, test } from '@rstest/core';
2
+ import { squared } from '../src/index';
3
+
4
+ test('squared', () => {
5
+ expect(squared(2)).toBe(4);
6
+ expect(squared(12)).toBe(144);
7
+ });
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ES2022"],
4
+ "module": "ESNext",
5
+ "noEmit": true,
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "isolatedModules": true,
9
+ "resolveJsonModule": true,
10
+ "moduleResolution": "bundler",
11
+ "useDefineForClassFields": true,
12
+ "allowImportingTsExtensions": true
13
+ },
14
+ "include": ["src"]
15
+ }
@@ -0,0 +1,36 @@
1
+ import { dirname, join } from 'node:path';
2
+
3
+ /**
4
+ * This function is used to resolve the absolute path of a package.
5
+ * It is needed in projects that use Yarn PnP or are set up within a monorepo.
6
+ */
7
+ function getAbsolutePath(value) {
8
+ return dirname(require.resolve(join(value, 'package.json')));
9
+ }
10
+
11
+ const config = {
12
+ stories: [
13
+ '../stories/**/*.mdx',
14
+ '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
15
+ ],
16
+ addons: [
17
+ '@storybook/addon-docs',
18
+ '@storybook/addon-onboarding',
19
+ '@storybook/addon-links',
20
+ '@storybook/addon-essentials',
21
+ '@storybook/addon-interactions',
22
+ {
23
+ name: getAbsolutePath('storybook-addon-rslib'),
24
+ },
25
+ ],
26
+ framework: {
27
+ name: getAbsolutePath('storybook-react-rsbuild'),
28
+ options: {},
29
+ },
30
+ typescript: {
31
+ reactDocgen: 'react-docgen-typescript',
32
+ check: true,
33
+ },
34
+ };
35
+
36
+ export default config;
@@ -0,0 +1,12 @@
1
+ const preview = {
2
+ parameters: {
3
+ controls: {
4
+ matchers: {
5
+ color: /(background|color)$/i,
6
+ date: /Date$/i,
7
+ },
8
+ },
9
+ },
10
+ };
11
+
12
+ export default preview;
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "rslib-react-js",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "import": "./dist/index.js"
8
+ }
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "rslib build",
15
+ "build:storybook": "storybook build",
16
+ "dev": "rslib build --watch",
17
+ "storybook": "storybook dev",
18
+ "test": "rstest"
19
+ },
20
+ "devDependencies": {
21
+ "@rsbuild/core": "1.5.0-beta.3",
22
+ "@rsbuild/plugin-react": "^1.3.5",
23
+ "@rslib/core": "workspace:*",
24
+ "@rstest/core": "^0.1.3",
25
+ "@storybook/addon-docs": "^9.1.1",
26
+ "@storybook/addon-essentials": "^9.0.0-alpha.12",
27
+ "@storybook/addon-interactions": "^9.0.0-alpha.10",
28
+ "@storybook/addon-links": "^9.1.1",
29
+ "@storybook/addon-onboarding": "^9.1.1",
30
+ "@storybook/blocks": "^9.0.0-alpha.17",
31
+ "@storybook/react": "^9.1.1",
32
+ "@storybook/test": "^9.0.0-alpha.2",
33
+ "@testing-library/jest-dom": "^6.6.4",
34
+ "@testing-library/react": "^16.3.0",
35
+ "jsdom": "^26.1.0",
36
+ "react": "^19.1.1",
37
+ "storybook": "^9.1.1",
38
+ "storybook-addon-rslib": "^2.0.3",
39
+ "storybook-react-rsbuild": "^2.0.3"
40
+ },
41
+ "peerDependencies": {
42
+ "react": ">=16.9.0",
43
+ "react-dom": ">=16.9.0"
44
+ }
45
+ }
@@ -0,0 +1,20 @@
1
+ import { pluginReact } from '@rsbuild/plugin-react';
2
+ import { defineConfig } from '@rslib/core';
3
+
4
+ export default defineConfig({
5
+ source: {
6
+ entry: {
7
+ index: ['./src/**'],
8
+ },
9
+ },
10
+ lib: [
11
+ {
12
+ bundle: false,
13
+ format: 'esm',
14
+ },
15
+ ],
16
+ output: {
17
+ target: 'web',
18
+ },
19
+ plugins: [pluginReact()],
20
+ });
@@ -0,0 +1,8 @@
1
+ import { pluginReact } from '@rsbuild/plugin-react';
2
+ import { defineConfig } from '@rstest/core';
3
+
4
+ export default defineConfig({
5
+ testEnvironment: 'jsdom',
6
+ setupFiles: ['./rstest.setup.js'],
7
+ plugins: [pluginReact()],
8
+ });
@@ -0,0 +1,4 @@
1
+ import { expect } from '@rstest/core';
2
+ import * as jestDomMatchers from '@testing-library/jest-dom/matchers';
3
+
4
+ expect.extend(jestDomMatchers);
@@ -0,0 +1,21 @@
1
+ import './button.css';
2
+
3
+ export const Button = ({
4
+ primary = false,
5
+ size = 'medium',
6
+ backgroundColor,
7
+ label,
8
+ ...props
9
+ }) => {
10
+ const mode = primary ? 'demo-button--primary' : 'demo-button--secondary';
11
+ return (
12
+ <button
13
+ type="button"
14
+ className={['demo-button', `demo-button--${size}`, mode].join(' ')}
15
+ style={{ backgroundColor }}
16
+ {...props}
17
+ >
18
+ {label}
19
+ </button>
20
+ );
21
+ };