create-rslib 0.0.0-20250124083417

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 (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/dist/index.js +187 -0
  4. package/package.json +52 -0
  5. package/template-[node-dual]-[]-js/package.json +23 -0
  6. package/template-[node-dual]-[]-js/rslib.config.mjs +14 -0
  7. package/template-[node-dual]-[]-js/src/index.js +1 -0
  8. package/template-[node-dual]-[]-ts/package.json +27 -0
  9. package/template-[node-dual]-[]-ts/rslib.config.ts +15 -0
  10. package/template-[node-dual]-[]-ts/src/index.ts +1 -0
  11. package/template-[node-dual]-[]-ts/tsconfig.json +15 -0
  12. package/template-[node-dual]-[vitest]-js/package.json +25 -0
  13. package/template-[node-dual]-[vitest]-js/rslib.config.mjs +14 -0
  14. package/template-[node-dual]-[vitest]-js/src/index.js +1 -0
  15. package/template-[node-dual]-[vitest]-js/tests/index.test.js +7 -0
  16. package/template-[node-dual]-[vitest]-js/vitest.config.js +8 -0
  17. package/template-[node-dual]-[vitest]-ts/package.json +29 -0
  18. package/template-[node-dual]-[vitest]-ts/rslib.config.ts +15 -0
  19. package/template-[node-dual]-[vitest]-ts/src/index.ts +1 -0
  20. package/template-[node-dual]-[vitest]-ts/tests/index.test.ts +7 -0
  21. package/template-[node-dual]-[vitest]-ts/tests/tsconfig.json +4 -0
  22. package/template-[node-dual]-[vitest]-ts/tsconfig.json +15 -0
  23. package/template-[node-dual]-[vitest]-ts/vitest.config.ts +6 -0
  24. package/template-[node-esm]-[]-js/package.json +21 -0
  25. package/template-[node-esm]-[]-js/rslib.config.mjs +10 -0
  26. package/template-[node-esm]-[]-js/src/index.js +1 -0
  27. package/template-[node-esm]-[]-ts/package.json +25 -0
  28. package/template-[node-esm]-[]-ts/rslib.config.ts +11 -0
  29. package/template-[node-esm]-[]-ts/src/index.ts +1 -0
  30. package/template-[node-esm]-[]-ts/tsconfig.json +15 -0
  31. package/template-[node-esm]-[vitest]-js/package.json +23 -0
  32. package/template-[node-esm]-[vitest]-js/rslib.config.mjs +10 -0
  33. package/template-[node-esm]-[vitest]-js/src/index.js +1 -0
  34. package/template-[node-esm]-[vitest]-js/tests/index.test.js +7 -0
  35. package/template-[node-esm]-[vitest]-js/vitest.config.js +8 -0
  36. package/template-[node-esm]-[vitest]-ts/package.json +27 -0
  37. package/template-[node-esm]-[vitest]-ts/rslib.config.ts +11 -0
  38. package/template-[node-esm]-[vitest]-ts/src/index.ts +1 -0
  39. package/template-[node-esm]-[vitest]-ts/tests/index.test.ts +7 -0
  40. package/template-[node-esm]-[vitest]-ts/tests/tsconfig.json +4 -0
  41. package/template-[node-esm]-[vitest]-ts/tsconfig.json +15 -0
  42. package/template-[node-esm]-[vitest]-ts/vitest.config.ts +6 -0
  43. package/template-[react]-[]-js/package.json +27 -0
  44. package/template-[react]-[]-js/rslib.config.mjs +20 -0
  45. package/template-[react]-[]-js/src/Button.jsx +21 -0
  46. package/template-[react]-[]-js/src/button.css +34 -0
  47. package/template-[react]-[]-js/src/index.jsx +1 -0
  48. package/template-[react]-[]-ts/package.json +31 -0
  49. package/template-[react]-[]-ts/rslib.config.ts +21 -0
  50. package/template-[react]-[]-ts/src/Button.tsx +29 -0
  51. package/template-[react]-[]-ts/src/button.css +34 -0
  52. package/template-[react]-[]-ts/src/index.tsx +1 -0
  53. package/template-[react]-[]-ts/tsconfig.json +14 -0
  54. package/template-[react]-[storybook,vitest]-js/.storybook/main.js +38 -0
  55. package/template-[react]-[storybook,vitest]-js/.storybook/preview.js +12 -0
  56. package/template-[react]-[storybook,vitest]-js/package.json +45 -0
  57. package/template-[react]-[storybook,vitest]-js/rslib.config.mjs +20 -0
  58. package/template-[react]-[storybook,vitest]-js/src/Button.jsx +21 -0
  59. package/template-[react]-[storybook,vitest]-js/src/button.css +34 -0
  60. package/template-[react]-[storybook,vitest]-js/src/index.jsx +1 -0
  61. package/template-[react]-[storybook,vitest]-js/stories/Button.stories.jsx +50 -0
  62. package/template-[react]-[storybook,vitest]-js/tests/index.test.jsx +11 -0
  63. package/template-[react]-[storybook,vitest]-js/vitest.config.js +11 -0
  64. package/template-[react]-[storybook,vitest]-js/vitest.setup.js +1 -0
  65. package/template-[react]-[storybook,vitest]-ts/.storybook/main.ts +39 -0
  66. package/template-[react]-[storybook,vitest]-ts/.storybook/preview.ts +14 -0
  67. package/template-[react]-[storybook,vitest]-ts/package.json +49 -0
  68. package/template-[react]-[storybook,vitest]-ts/rslib.config.ts +21 -0
  69. package/template-[react]-[storybook,vitest]-ts/src/Button.tsx +29 -0
  70. package/template-[react]-[storybook,vitest]-ts/src/button.css +34 -0
  71. package/template-[react]-[storybook,vitest]-ts/src/index.tsx +1 -0
  72. package/template-[react]-[storybook,vitest]-ts/stories/Button.stories.ts +52 -0
  73. package/template-[react]-[storybook,vitest]-ts/tests/index.test.tsx +11 -0
  74. package/template-[react]-[storybook,vitest]-ts/tests/tsconfig.json +4 -0
  75. package/template-[react]-[storybook,vitest]-ts/tsconfig.json +14 -0
  76. package/template-[react]-[storybook,vitest]-ts/vitest.config.ts +9 -0
  77. package/template-[react]-[storybook,vitest]-ts/vitest.setup.ts +1 -0
  78. package/template-[react]-[storybook]-js/.storybook/main.js +38 -0
  79. package/template-[react]-[storybook]-js/.storybook/preview.js +12 -0
  80. package/template-[react]-[storybook]-js/package.json +40 -0
  81. package/template-[react]-[storybook]-js/rslib.config.mjs +20 -0
  82. package/template-[react]-[storybook]-js/src/Button.jsx +21 -0
  83. package/template-[react]-[storybook]-js/src/button.css +34 -0
  84. package/template-[react]-[storybook]-js/src/index.jsx +1 -0
  85. package/template-[react]-[storybook]-js/stories/Button.stories.jsx +50 -0
  86. package/template-[react]-[storybook]-ts/.storybook/main.ts +39 -0
  87. package/template-[react]-[storybook]-ts/.storybook/preview.ts +14 -0
  88. package/template-[react]-[storybook]-ts/package.json +44 -0
  89. package/template-[react]-[storybook]-ts/rslib.config.ts +21 -0
  90. package/template-[react]-[storybook]-ts/src/Button.tsx +29 -0
  91. package/template-[react]-[storybook]-ts/src/button.css +34 -0
  92. package/template-[react]-[storybook]-ts/src/index.tsx +1 -0
  93. package/template-[react]-[storybook]-ts/stories/Button.stories.ts +52 -0
  94. package/template-[react]-[storybook]-ts/tsconfig.json +14 -0
  95. package/template-[react]-[vitest]-js/package.json +32 -0
  96. package/template-[react]-[vitest]-js/rslib.config.mjs +20 -0
  97. package/template-[react]-[vitest]-js/src/Button.jsx +21 -0
  98. package/template-[react]-[vitest]-js/src/button.css +34 -0
  99. package/template-[react]-[vitest]-js/src/index.jsx +1 -0
  100. package/template-[react]-[vitest]-js/tests/index.test.jsx +11 -0
  101. package/template-[react]-[vitest]-js/vitest.config.js +11 -0
  102. package/template-[react]-[vitest]-js/vitest.setup.js +1 -0
  103. package/template-[react]-[vitest]-ts/package.json +36 -0
  104. package/template-[react]-[vitest]-ts/rslib.config.ts +21 -0
  105. package/template-[react]-[vitest]-ts/src/Button.tsx +29 -0
  106. package/template-[react]-[vitest]-ts/src/button.css +34 -0
  107. package/template-[react]-[vitest]-ts/src/index.tsx +1 -0
  108. package/template-[react]-[vitest]-ts/tests/index.test.tsx +11 -0
  109. package/template-[react]-[vitest]-ts/tests/tsconfig.json +4 -0
  110. package/template-[react]-[vitest]-ts/tsconfig.json +14 -0
  111. package/template-[react]-[vitest]-ts/vitest.config.ts +9 -0
  112. package/template-[react]-[vitest]-ts/vitest.setup.ts +1 -0
  113. package/template-common/README.md +23 -0
  114. package/template-common/gitignore +13 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present Bytedance, Inc. and its affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ <picture>
2
+ <img alt="Rslib Banner" src="https://assets.rspack.dev/rslib/rslib-banner.png">
3
+ </picture>
4
+
5
+ # Rslib
6
+
7
+ Rslib is a library development tool powered by [Rsbuild](https://rsbuild.dev). It allows library developers to leverage the knowledge and ecosystem of webpack and Rspack.
8
+
9
+ ## Documentation
10
+
11
+ https://lib.rsbuild.dev/
12
+
13
+ ## Contributing
14
+
15
+ Please read the [Contributing Guide](https://github.com/web-infra-dev/rslib/blob/main/CONTRIBUTING.md).
16
+
17
+ ## License
18
+
19
+ Rslib is [MIT licensed](https://github.com/web-infra-dev/rslib/blob/main/LICENSE).
package/dist/index.js ADDED
@@ -0,0 +1,187 @@
1
+ #!/usr/bin/env node
2
+ import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_create_rstack_aeeb76b8__ from "create-rstack";
5
+ import "node:fs";
6
+ const helpers_filename = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(import.meta.url);
7
+ const helpers_dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(helpers_filename);
8
+ __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(helpers_dirname, '../fragments');
9
+ const composeTemplateName = ({ template, tools, lang })=>`[${template}]-[${(tools ? Object.keys(tools) : []).sort()}]-${lang}`;
10
+ const TEMPLATES = [
11
+ {
12
+ template: 'node-dual',
13
+ lang: 'js'
14
+ },
15
+ {
16
+ template: 'node-dual',
17
+ lang: 'ts'
18
+ },
19
+ {
20
+ template: 'node-dual',
21
+ lang: 'js',
22
+ tools: {
23
+ vitest: 'vitest-node-js'
24
+ }
25
+ },
26
+ {
27
+ template: 'node-dual',
28
+ lang: 'ts',
29
+ tools: {
30
+ vitest: 'vitest-node-ts'
31
+ }
32
+ },
33
+ {
34
+ template: 'node-esm',
35
+ lang: 'js'
36
+ },
37
+ {
38
+ template: 'node-esm',
39
+ lang: 'ts'
40
+ },
41
+ {
42
+ template: 'node-esm',
43
+ lang: 'js',
44
+ tools: {
45
+ vitest: 'vitest-node-js'
46
+ }
47
+ },
48
+ {
49
+ template: 'node-esm',
50
+ lang: 'ts',
51
+ tools: {
52
+ vitest: 'vitest-node-ts'
53
+ }
54
+ },
55
+ {
56
+ template: 'react',
57
+ lang: 'js'
58
+ },
59
+ {
60
+ template: 'react',
61
+ lang: 'js',
62
+ tools: {
63
+ storybook: 'storybook-react-js'
64
+ }
65
+ },
66
+ {
67
+ template: 'react',
68
+ lang: 'js',
69
+ tools: {
70
+ vitest: 'vitest-react-js'
71
+ }
72
+ },
73
+ {
74
+ template: 'react',
75
+ lang: 'js',
76
+ tools: {
77
+ storybook: 'storybook-react-js',
78
+ vitest: 'vitest-react-js'
79
+ }
80
+ },
81
+ {
82
+ template: 'react',
83
+ lang: 'ts'
84
+ },
85
+ {
86
+ template: 'react',
87
+ lang: 'ts',
88
+ tools: {
89
+ storybook: 'storybook-react-ts'
90
+ }
91
+ },
92
+ {
93
+ template: 'react',
94
+ lang: 'ts',
95
+ tools: {
96
+ vitest: 'vitest-react-ts'
97
+ }
98
+ },
99
+ {
100
+ template: 'react',
101
+ lang: 'ts',
102
+ tools: {
103
+ storybook: 'storybook-react-ts',
104
+ vitest: 'vitest-react-ts'
105
+ }
106
+ }
107
+ ];
108
+ const src_dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(import.meta.url));
109
+ async function getTemplateName({ template }) {
110
+ if ('string' == typeof template) {
111
+ const pair = template.split('-');
112
+ const lang = pair[pair.length - 1];
113
+ if (lang && [
114
+ 'js',
115
+ 'ts'
116
+ ].includes(lang)) return template;
117
+ return `${template}-ts`;
118
+ }
119
+ const templateName = (0, __WEBPACK_EXTERNAL_MODULE_create_rstack_aeeb76b8__.checkCancel)(await (0, __WEBPACK_EXTERNAL_MODULE_create_rstack_aeeb76b8__.select)({
120
+ message: 'Select template',
121
+ options: [
122
+ {
123
+ value: 'node-dual',
124
+ label: 'Node.js dual ESM/CJS package'
125
+ },
126
+ {
127
+ value: 'node-esm',
128
+ label: 'Node.js pure ESM package'
129
+ },
130
+ {
131
+ value: 'react',
132
+ label: 'React'
133
+ }
134
+ ]
135
+ }));
136
+ const language = (0, __WEBPACK_EXTERNAL_MODULE_create_rstack_aeeb76b8__.checkCancel)(await (0, __WEBPACK_EXTERNAL_MODULE_create_rstack_aeeb76b8__.select)({
137
+ message: 'Select language',
138
+ options: [
139
+ {
140
+ value: 'ts',
141
+ label: 'TypeScript'
142
+ },
143
+ {
144
+ value: 'js',
145
+ label: 'JavaScript'
146
+ }
147
+ ]
148
+ }));
149
+ const supportStorybook = 'react' === templateName;
150
+ const tools = (0, __WEBPACK_EXTERNAL_MODULE_create_rstack_aeeb76b8__.checkCancel)(await (0, __WEBPACK_EXTERNAL_MODULE_create_rstack_aeeb76b8__.multiselect)({
151
+ message: 'Select development tools (Use <space> to select, <enter> to continue)',
152
+ required: false,
153
+ options: [
154
+ supportStorybook && {
155
+ value: 'storybook',
156
+ label: 'Storybook'
157
+ },
158
+ {
159
+ value: 'vitest',
160
+ label: 'Vitest'
161
+ }
162
+ ].filter(Boolean)
163
+ }));
164
+ return composeTemplateName({
165
+ template: templateName,
166
+ lang: language,
167
+ tools: Object.fromEntries(tools.map((tool)=>[
168
+ tool,
169
+ `vitest-${tool}-${language}`
170
+ ]))
171
+ });
172
+ }
173
+ function mapESLintTemplate(templateName) {
174
+ const language = templateName.split('-').pop();
175
+ return `vanilla-${language}`;
176
+ }
177
+ (0, __WEBPACK_EXTERNAL_MODULE_create_rstack_aeeb76b8__.create)({
178
+ root: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(src_dirname, '..'),
179
+ name: 'rslib',
180
+ templates: TEMPLATES.map(({ template, tools, lang })=>composeTemplateName({
181
+ template,
182
+ lang,
183
+ tools
184
+ })),
185
+ getTemplateName,
186
+ mapESLintTemplate
187
+ });
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "create-rslib",
3
+ "version": "0.0.0-20250124083417",
4
+ "description": "Create a new Rslib project",
5
+ "homepage": "https://lib.rsbuild.dev",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/web-infra-dev/rslib.git",
9
+ "directory": "packages/create-rslib"
10
+ },
11
+ "license": "MIT",
12
+ "type": "module",
13
+ "exports": {
14
+ ".": "./dist/index.js"
15
+ },
16
+ "main": "./dist/index.js",
17
+ "bin": {
18
+ "create-rslib": "./dist/index.js"
19
+ },
20
+ "files": [
21
+ "template-*",
22
+ "dist"
23
+ ],
24
+ "dependencies": {
25
+ "create-rstack": "1.1.0"
26
+ },
27
+ "devDependencies": {
28
+ "@types/fs-extra": "^11.0.4",
29
+ "@types/node": "^22.8.1",
30
+ "fs-extra": "^11.3.0",
31
+ "rsbuild-plugin-publint": "^0.2.1",
32
+ "rslib": "npm:@rslib/core@0.3.2",
33
+ "tsx": "^4.19.2",
34
+ "typescript": "^5.7.3",
35
+ "@rslib/tsconfig": "0.0.1"
36
+ },
37
+ "engines": {
38
+ "node": ">=16.7.0"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public",
42
+ "provenance": true,
43
+ "registry": "https://registry.npmjs.org/"
44
+ },
45
+ "scripts": {
46
+ "build": "rslib build && pnpm generate-templates",
47
+ "dev": "rslib build --watch",
48
+ "generate-templates": "pnpm tsx ./src/genTemplates.ts",
49
+ "start": "node ./dist/index.js",
50
+ "test": "vitest run"
51
+ }
52
+ }
@@ -0,0 +1,23 @@
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
+ "module": "./dist/index.js",
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "build": "rslib build",
18
+ "dev": "rslib build --watch"
19
+ },
20
+ "devDependencies": {
21
+ "@rslib/core": "workspace:*"
22
+ }
23
+ }
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from '@rslib/core';
2
+
3
+ export default defineConfig({
4
+ lib: [
5
+ {
6
+ format: 'esm',
7
+ syntax: 'es2021',
8
+ },
9
+ {
10
+ format: 'cjs',
11
+ syntax: 'es2021',
12
+ },
13
+ ],
14
+ });
@@ -0,0 +1 @@
1
+ export const squared = (n) => n * n;
@@ -0,0 +1,27 @@
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
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "rslib build",
20
+ "dev": "rslib build --watch"
21
+ },
22
+ "devDependencies": {
23
+ "@rslib/core": "workspace:*",
24
+ "@types/node": "^22.8.1",
25
+ "typescript": "^5.7.3"
26
+ }
27
+ }
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from '@rslib/core';
2
+
3
+ export default defineConfig({
4
+ lib: [
5
+ {
6
+ format: 'esm',
7
+ syntax: 'es2021',
8
+ dts: true,
9
+ },
10
+ {
11
+ format: 'cjs',
12
+ syntax: 'es2021',
13
+ },
14
+ ],
15
+ });
@@ -0,0 +1 @@
1
+ export const squared = (n: number): number => n * n;
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ES2021"],
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,25 @@
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
+ "module": "./dist/index.js",
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "build": "rslib build",
18
+ "dev": "rslib build --watch",
19
+ "test": "vitest run"
20
+ },
21
+ "devDependencies": {
22
+ "@rslib/core": "workspace:*",
23
+ "vitest": "^3.0.4"
24
+ }
25
+ }
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from '@rslib/core';
2
+
3
+ export default defineConfig({
4
+ lib: [
5
+ {
6
+ format: 'esm',
7
+ syntax: 'es2021',
8
+ },
9
+ {
10
+ format: 'cjs',
11
+ syntax: 'es2021',
12
+ },
13
+ ],
14
+ });
@@ -0,0 +1 @@
1
+ export const squared = (n) => n * n;
@@ -0,0 +1,7 @@
1
+ import { expect, test } from 'vitest';
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,8 @@
1
+ /// <reference types="vitest/config" />
2
+
3
+ import { defineConfig } from 'vitest/config';
4
+
5
+ export default defineConfig({
6
+ // Configure Vitest (https://vitest.dev/config/)
7
+ test: {},
8
+ });
@@ -0,0 +1,29 @@
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
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "rslib build",
20
+ "dev": "rslib build --watch",
21
+ "test": "vitest run"
22
+ },
23
+ "devDependencies": {
24
+ "@rslib/core": "workspace:*",
25
+ "@types/node": "^22.8.1",
26
+ "typescript": "^5.7.3",
27
+ "vitest": "^3.0.4"
28
+ }
29
+ }
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from '@rslib/core';
2
+
3
+ export default defineConfig({
4
+ lib: [
5
+ {
6
+ format: 'esm',
7
+ syntax: 'es2021',
8
+ dts: true,
9
+ },
10
+ {
11
+ format: 'cjs',
12
+ syntax: 'es2021',
13
+ },
14
+ ],
15
+ });
@@ -0,0 +1 @@
1
+ export const squared = (n: number): number => n * n;
@@ -0,0 +1,7 @@
1
+ import { expect, test } from 'vitest';
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,4 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "include": [".", "../vitest.setup.ts"]
4
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ES2021"],
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,6 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ // Configure Vitest (https://vitest.dev/config/)
5
+ test: {},
6
+ });
@@ -0,0 +1,21 @@
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
+ "module": "./dist/index.js",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "build": "rslib build",
16
+ "dev": "rslib build --watch"
17
+ },
18
+ "devDependencies": {
19
+ "@rslib/core": "workspace:*"
20
+ }
21
+ }
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from '@rslib/core';
2
+
3
+ export default defineConfig({
4
+ lib: [
5
+ {
6
+ format: 'esm',
7
+ syntax: 'es2021',
8
+ },
9
+ ],
10
+ });
@@ -0,0 +1 @@
1
+ export const squared = (n) => n * n;
@@ -0,0 +1,25 @@
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
+ "module": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "build": "rslib build",
18
+ "dev": "rslib build --watch"
19
+ },
20
+ "devDependencies": {
21
+ "@rslib/core": "workspace:*",
22
+ "@types/node": "^22.8.1",
23
+ "typescript": "^5.7.3"
24
+ }
25
+ }
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from '@rslib/core';
2
+
3
+ export default defineConfig({
4
+ lib: [
5
+ {
6
+ format: 'esm',
7
+ syntax: 'es2021',
8
+ dts: true,
9
+ },
10
+ ],
11
+ });
@@ -0,0 +1 @@
1
+ export const squared = (n: number): number => n * n;
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ES2021"],
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,23 @@
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
+ "module": "./dist/index.js",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "build": "rslib build",
16
+ "dev": "rslib build --watch",
17
+ "test": "vitest run"
18
+ },
19
+ "devDependencies": {
20
+ "@rslib/core": "workspace:*",
21
+ "vitest": "^3.0.4"
22
+ }
23
+ }
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from '@rslib/core';
2
+
3
+ export default defineConfig({
4
+ lib: [
5
+ {
6
+ format: 'esm',
7
+ syntax: 'es2021',
8
+ },
9
+ ],
10
+ });