@bundlekit/service 0.0.1 → 0.0.2
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.
- package/README.md +111 -0
- package/dist/index.cjs +44 -35
- package/dist/index.mjs +1 -1
- package/package.json +7 -7
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# @bundlekit/service
|
|
2
|
+
|
|
3
|
+
BundleKit 核心服务,提供开发服务和生产构建功能,支持 5 种主流打包器。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @bundlekit/service
|
|
9
|
+
# 或
|
|
10
|
+
pnpm add -D @bundlekit/service
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 使用
|
|
14
|
+
|
|
15
|
+
### 开发服务
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
ds serve
|
|
19
|
+
ds serve --bundler vite
|
|
20
|
+
ds serve --bundler webpack --https
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### 生产构建
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
ds build
|
|
27
|
+
ds build --bundler vite --mode production
|
|
28
|
+
ds build --bundler rspack --mode staging
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 命令行选项
|
|
32
|
+
|
|
33
|
+
| 命令 | 说明 |
|
|
34
|
+
|------|------|
|
|
35
|
+
| `ds serve` | 启动开发服务 |
|
|
36
|
+
| `ds build` | 执行生产构建 |
|
|
37
|
+
|
|
38
|
+
| 选项 | 说明 |
|
|
39
|
+
|------|------|
|
|
40
|
+
| `--bundler` | 指定打包器(vite/webpack/rspack/rollup/rolldown) |
|
|
41
|
+
| `--mode` | 构建模式(development/production/staging) |
|
|
42
|
+
| `--https` | 启用 HTTPS |
|
|
43
|
+
| `--skip-plugin` | 跳过指定插件 |
|
|
44
|
+
|
|
45
|
+
## 配置文件
|
|
46
|
+
|
|
47
|
+
在项目根目录创建 `.bundlekitrc.ts`:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { defineConfig } from '@bundlekit/service';
|
|
51
|
+
|
|
52
|
+
export default defineConfig({
|
|
53
|
+
config: {
|
|
54
|
+
development: {
|
|
55
|
+
entry: 'src/index.tsx',
|
|
56
|
+
output: { dir: 'dist', filename: '[name].js' },
|
|
57
|
+
devServer: {
|
|
58
|
+
open: true,
|
|
59
|
+
port: 3000,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
production: {
|
|
63
|
+
entry: 'src/index.tsx',
|
|
64
|
+
output: { dir: 'dist', filename: '[name].[hash].js' },
|
|
65
|
+
minify: true,
|
|
66
|
+
sourcemap: false,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## SSR 支持
|
|
73
|
+
|
|
74
|
+
所有 5 个 bundler 都支持 SSR 双产物构建:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
export default defineConfig({
|
|
78
|
+
config: {
|
|
79
|
+
production: {
|
|
80
|
+
entry: 'src/entry-client.tsx',
|
|
81
|
+
output: { dir: 'dist/client', filename: '[name].js' },
|
|
82
|
+
ssr: {
|
|
83
|
+
entry: 'src/entry-server.tsx',
|
|
84
|
+
output: { dir: 'dist/server', filename: 'server.cjs' },
|
|
85
|
+
externals: 'auto',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 插件系统
|
|
93
|
+
|
|
94
|
+
支持动态加载插件:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
export default defineConfig({
|
|
98
|
+
plugins: [
|
|
99
|
+
'@bundlekit/plugin-react',
|
|
100
|
+
'@bundlekit/plugin-mock',
|
|
101
|
+
],
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## 文档
|
|
106
|
+
|
|
107
|
+
完整文档请访问 [https://bundlekit.dev](https://bundlekit.dev)
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
ISC
|
package/dist/index.cjs
CHANGED
|
@@ -1030,46 +1030,55 @@ const isPrerelease = (type) => {
|
|
|
1030
1030
|
|
|
1031
1031
|
var truncate_1 = truncate$1;
|
|
1032
1032
|
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
this.max = 1000;
|
|
1036
|
-
this.map = new Map();
|
|
1037
|
-
}
|
|
1033
|
+
var lrucache;
|
|
1034
|
+
var hasRequiredLrucache;
|
|
1038
1035
|
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
return undefined
|
|
1043
|
-
} else {
|
|
1044
|
-
// Remove the key from the map and add it to the end
|
|
1045
|
-
this.map.delete(key);
|
|
1046
|
-
this.map.set(key, value);
|
|
1047
|
-
return value
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1036
|
+
function requireLrucache () {
|
|
1037
|
+
if (hasRequiredLrucache) return lrucache;
|
|
1038
|
+
hasRequiredLrucache = 1;
|
|
1050
1039
|
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1040
|
+
class LRUCache {
|
|
1041
|
+
constructor () {
|
|
1042
|
+
this.max = 1000;
|
|
1043
|
+
this.map = new Map();
|
|
1044
|
+
}
|
|
1054
1045
|
|
|
1055
|
-
|
|
1056
|
-
|
|
1046
|
+
get (key) {
|
|
1047
|
+
const value = this.map.get(key);
|
|
1048
|
+
if (value === undefined) {
|
|
1049
|
+
return undefined
|
|
1050
|
+
} else {
|
|
1051
|
+
// Remove the key from the map and add it to the end
|
|
1052
|
+
this.map.delete(key);
|
|
1053
|
+
this.map.set(key, value);
|
|
1054
|
+
return value
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
1057
|
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
const firstKey = this.map.keys().next().value;
|
|
1062
|
-
this.delete(firstKey);
|
|
1063
|
-
}
|
|
1058
|
+
delete (key) {
|
|
1059
|
+
return this.map.delete(key)
|
|
1060
|
+
}
|
|
1064
1061
|
|
|
1065
|
-
|
|
1066
|
-
|
|
1062
|
+
set (key, value) {
|
|
1063
|
+
const deleted = this.delete(key);
|
|
1067
1064
|
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1065
|
+
if (!deleted && value !== undefined) {
|
|
1066
|
+
// If cache is full, delete the least recently used item
|
|
1067
|
+
if (this.map.size >= this.max) {
|
|
1068
|
+
const firstKey = this.map.keys().next().value;
|
|
1069
|
+
this.delete(firstKey);
|
|
1070
|
+
}
|
|
1071
1071
|
|
|
1072
|
-
|
|
1072
|
+
this.map.set(key, value);
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
return this
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
lrucache = LRUCache;
|
|
1080
|
+
return lrucache;
|
|
1081
|
+
}
|
|
1073
1082
|
|
|
1074
1083
|
var range;
|
|
1075
1084
|
var hasRequiredRange;
|
|
@@ -1292,7 +1301,7 @@ function requireRange () {
|
|
|
1292
1301
|
|
|
1293
1302
|
range = Range;
|
|
1294
1303
|
|
|
1295
|
-
const LRU =
|
|
1304
|
+
const LRU = requireLrucache();
|
|
1296
1305
|
const cache = new LRU();
|
|
1297
1306
|
|
|
1298
1307
|
const parseOptions = parseOptions_1;
|
|
@@ -2686,7 +2695,7 @@ var minimist = function (args, opts) {
|
|
|
2686
2695
|
var minimist$1 = /*@__PURE__*/getDefaultExportFromCjs(minimist);
|
|
2687
2696
|
|
|
2688
2697
|
var name = "@bundlekit/service";
|
|
2689
|
-
var version = "0.0.
|
|
2698
|
+
var version = "0.0.2";
|
|
2690
2699
|
var main = "./dist/index.cjs";
|
|
2691
2700
|
var module$1 = "./dist/index.mjs";
|
|
2692
2701
|
var cjs = "./dist/index.cjs";
|
package/dist/index.mjs
CHANGED
|
@@ -2669,7 +2669,7 @@ var minimist = function (args, opts) {
|
|
|
2669
2669
|
var minimist$1 = /*@__PURE__*/getDefaultExportFromCjs(minimist);
|
|
2670
2670
|
|
|
2671
2671
|
var name = "@bundlekit/service";
|
|
2672
|
-
var version = "0.0.
|
|
2672
|
+
var version = "0.0.2";
|
|
2673
2673
|
var main = "./dist/index.cjs";
|
|
2674
2674
|
var module$1 = "./dist/index.mjs";
|
|
2675
2675
|
var cjs = "./dist/index.cjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bundlekit/service",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"main": "./dist/index.cjs",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"cjs": "./dist/index.cjs",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"jiti": "^2.4.2",
|
|
26
26
|
"minimist": "^1.2.8",
|
|
27
27
|
"semver": "^7.7.1",
|
|
28
|
-
"@bundlekit/shared-utils": "0.0.
|
|
28
|
+
"@bundlekit/shared-utils": "0.0.2"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@bundlekit/bundler-
|
|
32
|
-
"@bundlekit/bundler-
|
|
33
|
-
"@bundlekit/bundler-
|
|
34
|
-
"@bundlekit/bundler-rolldown": "0.0.
|
|
35
|
-
"@bundlekit/bundler-
|
|
31
|
+
"@bundlekit/bundler-webpack": "0.0.2",
|
|
32
|
+
"@bundlekit/bundler-vite": "0.0.2",
|
|
33
|
+
"@bundlekit/bundler-rspack": "0.0.2",
|
|
34
|
+
"@bundlekit/bundler-rolldown": "0.0.2",
|
|
35
|
+
"@bundlekit/bundler-rollup": "0.0.2"
|
|
36
36
|
},
|
|
37
37
|
"peerDependenciesMeta": {
|
|
38
38
|
"@bundlekit/bundler-webpack": {
|