rspkify 0.0.0-beta.0
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/bin/common/index.cjs +17658 -0
- package/bin/common/index.mjs +17623 -0
- package/bin/common/index2.cjs +633 -0
- package/bin/common/index2.mjs +630 -0
- package/bin/common/index3.cjs +17610 -0
- package/bin/common/index3.mjs +17579 -0
- package/bin/common/index4.cjs +2562 -0
- package/bin/common/index4.mjs +2560 -0
- package/bin/common/js-yaml.cjs +3871 -0
- package/bin/common/js-yaml.mjs +3855 -0
- package/bin/common/typescript.cjs +201850 -0
- package/bin/common/typescript.mjs +201848 -0
- package/bin/common/validation.cjs +100 -0
- package/bin/common/validation.mjs +98 -0
- package/bin/index.cjs +247 -0
- package/bin/index.d.ts +948 -0
- package/bin/index.mjs +228 -0
- package/bin/main.cjs +8519 -0
- package/bin/main.mjs +8510 -0
- package/package.json +77 -0
package/bin/index.mjs
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { _ as _slicedToArray } from './common/index.mjs';
|
|
2
|
+
export { R as RspackRunner, r as createRspackConfig, c as createSharedFromPackage, r as createWebpackConfig, r as rspackConfigPlugin, a as runRspackBuild, b as runWebpackBuild, s as setCSSInTSPlugin, r as webpackConfigPlugin, w as webpckConfigPlugin } from './common/index.mjs';
|
|
3
|
+
import 'path';
|
|
4
|
+
import 'node:path';
|
|
5
|
+
import '@rspack/core';
|
|
6
|
+
import 'node:module';
|
|
7
|
+
import 'net';
|
|
8
|
+
import 'child_process';
|
|
9
|
+
import 'fs';
|
|
10
|
+
import 'module';
|
|
11
|
+
import 'node:fs';
|
|
12
|
+
import 'node:os';
|
|
13
|
+
import 'node:url';
|
|
14
|
+
import 'node:fs/promises';
|
|
15
|
+
import 'node:events';
|
|
16
|
+
import 'node:stream';
|
|
17
|
+
import 'node:string_decoder';
|
|
18
|
+
import 'url';
|
|
19
|
+
import 'os';
|
|
20
|
+
import 'crypto';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 创建远程模块配置
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const remotes = createRemotes({
|
|
27
|
+
* app1: 'http://localhost:3001/remoteEntry.js',
|
|
28
|
+
* app2: 'http://localhost:3002/remoteEntry.js'
|
|
29
|
+
* })
|
|
30
|
+
* // => { app1: 'app1@http://localhost:3001/remoteEntry.js', ... }
|
|
31
|
+
*/
|
|
32
|
+
function createRemotes(remotes) {
|
|
33
|
+
var result = {};
|
|
34
|
+
Object.entries(remotes).forEach(function (_ref) {
|
|
35
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
36
|
+
name = _ref2[0],
|
|
37
|
+
url = _ref2[1];
|
|
38
|
+
// 如果 URL 已经包含 name@,直接使用
|
|
39
|
+
if (url.includes('@')) {
|
|
40
|
+
result[name] = url;
|
|
41
|
+
} else {
|
|
42
|
+
// 否则添加 name@ 前缀
|
|
43
|
+
result[name] = "".concat(name, "@").concat(url);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 创建暴露模块配置
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* const exposes = createExposes({
|
|
53
|
+
* './Button': './src/components/Button',
|
|
54
|
+
* './utils': './src/utils/index'
|
|
55
|
+
* })
|
|
56
|
+
*/
|
|
57
|
+
function createExposes(exposes) {
|
|
58
|
+
return exposes;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 创建共享依赖配置
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* const shared = createShared({
|
|
65
|
+
* react: { singleton: true },
|
|
66
|
+
* 'react-dom': { singleton: true }
|
|
67
|
+
* })
|
|
68
|
+
*/
|
|
69
|
+
function createShared(shared) {
|
|
70
|
+
return shared;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 创建常用的 React 共享依赖配置
|
|
74
|
+
*
|
|
75
|
+
* @param version - React 版本,默认 '*'
|
|
76
|
+
* @param options - 配置选项
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* const shared = createReactShared('^18.0.0')
|
|
80
|
+
*/
|
|
81
|
+
function createReactShared(version, options) {
|
|
82
|
+
var _ref3 = options || {},
|
|
83
|
+
_ref3$singleton = _ref3.singleton,
|
|
84
|
+
singleton = _ref3$singleton === void 0 ? true : _ref3$singleton,
|
|
85
|
+
_ref3$strictVersion = _ref3.strictVersion,
|
|
86
|
+
strictVersion = _ref3$strictVersion === void 0 ? false : _ref3$strictVersion,
|
|
87
|
+
_ref3$eager = _ref3.eager,
|
|
88
|
+
eager = _ref3$eager === void 0 ? false : _ref3$eager;
|
|
89
|
+
return {
|
|
90
|
+
react: {
|
|
91
|
+
singleton: singleton,
|
|
92
|
+
strictVersion: strictVersion,
|
|
93
|
+
eager: eager,
|
|
94
|
+
requiredVersion: version || '*'
|
|
95
|
+
},
|
|
96
|
+
'react-dom': {
|
|
97
|
+
singleton: singleton,
|
|
98
|
+
strictVersion: strictVersion,
|
|
99
|
+
eager: eager,
|
|
100
|
+
requiredVersion: version || '*'
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 创建常用的 Vue 共享依赖配置
|
|
106
|
+
*
|
|
107
|
+
* @param version - Vue 版本,默认 '*'
|
|
108
|
+
* @param options - 配置选项
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* const shared = createVueShared('^3.0.0')
|
|
112
|
+
*/
|
|
113
|
+
function createVueShared(version, options) {
|
|
114
|
+
var _ref4 = options || {},
|
|
115
|
+
_ref4$singleton = _ref4.singleton,
|
|
116
|
+
singleton = _ref4$singleton === void 0 ? true : _ref4$singleton,
|
|
117
|
+
_ref4$strictVersion = _ref4.strictVersion,
|
|
118
|
+
strictVersion = _ref4$strictVersion === void 0 ? false : _ref4$strictVersion,
|
|
119
|
+
_ref4$eager = _ref4.eager,
|
|
120
|
+
eager = _ref4$eager === void 0 ? false : _ref4$eager;
|
|
121
|
+
return {
|
|
122
|
+
vue: {
|
|
123
|
+
singleton: singleton,
|
|
124
|
+
strictVersion: strictVersion,
|
|
125
|
+
eager: eager,
|
|
126
|
+
requiredVersion: version || '*'
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 从环境变量创建远程模块配置
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* // .env 文件
|
|
135
|
+
* REMOTE_APP1=http://localhost:3001/remoteEntry.js
|
|
136
|
+
* REMOTE_APP2=http://localhost:3002/remoteEntry.js
|
|
137
|
+
*
|
|
138
|
+
* // 使用
|
|
139
|
+
* const remotes = createRemotesFromEnv('REMOTE_')
|
|
140
|
+
*/
|
|
141
|
+
function createRemotesFromEnv() {
|
|
142
|
+
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'REMOTE_';
|
|
143
|
+
var remotes = {};
|
|
144
|
+
Object.keys(process.env).forEach(function (key) {
|
|
145
|
+
if (key.startsWith(prefix)) {
|
|
146
|
+
var name = key.replace(prefix, '').toLowerCase();
|
|
147
|
+
var url = process.env[key];
|
|
148
|
+
if (url) {
|
|
149
|
+
remotes[name] = "".concat(name, "@").concat(url);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return remotes;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* 合并多个共享依赖配置
|
|
157
|
+
*
|
|
158
|
+
* @description
|
|
159
|
+
* 当同一个依赖在多个配置中出现时,后面的配置会覆盖前面的
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* const shared = mergeShared(
|
|
163
|
+
* createReactShared('^18.0.0'),
|
|
164
|
+
* { lodash: { singleton: false } }
|
|
165
|
+
* )
|
|
166
|
+
*/
|
|
167
|
+
function mergeShared() {
|
|
168
|
+
var result = {};
|
|
169
|
+
for (var _len = arguments.length, sharedObjects = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
170
|
+
sharedObjects[_key] = arguments[_key];
|
|
171
|
+
}
|
|
172
|
+
sharedObjects.forEach(function (obj) {
|
|
173
|
+
if (obj) {
|
|
174
|
+
Object.assign(result, obj);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* 快速创建共享依赖配置(简化版)
|
|
181
|
+
*
|
|
182
|
+
* @description
|
|
183
|
+
* 快速创建单例模式的共享依赖配置
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* const shared = createQuickShared(['react', 'react-dom', 'lodash'])
|
|
187
|
+
* // => {
|
|
188
|
+
* // react: { singleton: true, requiredVersion: '*' },
|
|
189
|
+
* // 'react-dom': { singleton: true, requiredVersion: '*' },
|
|
190
|
+
* // lodash: { singleton: true, requiredVersion: '*' }
|
|
191
|
+
* // }
|
|
192
|
+
*/
|
|
193
|
+
function createQuickShared(packages, options) {
|
|
194
|
+
var _ref5 = options || {},
|
|
195
|
+
_ref5$singleton = _ref5.singleton,
|
|
196
|
+
singleton = _ref5$singleton === void 0 ? true : _ref5$singleton,
|
|
197
|
+
_ref5$strictVersion = _ref5.strictVersion,
|
|
198
|
+
strictVersion = _ref5$strictVersion === void 0 ? false : _ref5$strictVersion,
|
|
199
|
+
_ref5$eager = _ref5.eager,
|
|
200
|
+
eager = _ref5$eager === void 0 ? false : _ref5$eager,
|
|
201
|
+
_ref5$requiredVersion = _ref5.requiredVersion,
|
|
202
|
+
requiredVersion = _ref5$requiredVersion === void 0 ? '*' : _ref5$requiredVersion;
|
|
203
|
+
var shared = {};
|
|
204
|
+
packages.forEach(function (pkg) {
|
|
205
|
+
shared[pkg] = {
|
|
206
|
+
singleton: singleton,
|
|
207
|
+
strictVersion: strictVersion,
|
|
208
|
+
eager: eager,
|
|
209
|
+
requiredVersion: requiredVersion
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
return shared;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ============================================================================
|
|
216
|
+
// Rsify 主入口文件
|
|
217
|
+
// ============================================================================
|
|
218
|
+
/**
|
|
219
|
+
* Rspack 配置生成器
|
|
220
|
+
*/
|
|
221
|
+
/**
|
|
222
|
+
* defineConfig 辅助函数(类型提示)
|
|
223
|
+
*/
|
|
224
|
+
var defineConfig = function defineConfig(config) {
|
|
225
|
+
return config;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
export { createExposes, createQuickShared, createReactShared, createRemotes, createRemotesFromEnv, createShared, createVueShared, defineConfig, mergeShared };
|