@yannick-z/modulo 0.3.1 → 0.3.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/bin/modulo.js +1 -1
- package/dist/183.js +130 -0
- package/dist/740.js +793 -0
- package/dist/882.js +697 -0
- package/dist/bin/modulo.js +93 -0
- package/dist/index.js +200 -0
- package/package.json +14 -7
- package/src/bin/modulo.ts +16 -0
- package/src/packer/auto-external-plugin.ts +4 -5
- package/src/packer/get-externals-and-tags.ts +6 -3
- package/src/packer/lib.ts +6 -4
- package/.vscode/extensions.json +0 -3
- package/biome.json +0 -34
- package/rslib.config.ts +0 -22
- package/template/index.html +0 -12
- package/tsconfig.json +0 -11
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
var __webpack_modules__ = {};
|
|
3
|
+
var __webpack_module_cache__ = {};
|
|
4
|
+
function __webpack_require__(moduleId) {
|
|
5
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
6
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
7
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
8
|
+
exports: {}
|
|
9
|
+
};
|
|
10
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
11
|
+
return module.exports;
|
|
12
|
+
}
|
|
13
|
+
__webpack_require__.m = __webpack_modules__;
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.d = (exports, definition)=>{
|
|
16
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: definition[key]
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
})();
|
|
22
|
+
(()=>{
|
|
23
|
+
__webpack_require__.f = {};
|
|
24
|
+
__webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>{
|
|
25
|
+
__webpack_require__.f[key](chunkId, promises);
|
|
26
|
+
return promises;
|
|
27
|
+
}, []));
|
|
28
|
+
})();
|
|
29
|
+
(()=>{
|
|
30
|
+
__webpack_require__.u = (chunkId)=>"" + chunkId + ".js";
|
|
31
|
+
})();
|
|
32
|
+
(()=>{
|
|
33
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
34
|
+
})();
|
|
35
|
+
(()=>{
|
|
36
|
+
__webpack_require__.r = (exports)=>{
|
|
37
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
|
|
38
|
+
value: 'Module'
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(exports, '__esModule', {
|
|
41
|
+
value: true
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
(()=>{
|
|
46
|
+
var installedChunks = {
|
|
47
|
+
660: 0
|
|
48
|
+
};
|
|
49
|
+
var installChunk = (data)=>{
|
|
50
|
+
var __webpack_ids__ = data.__webpack_ids__;
|
|
51
|
+
var __webpack_modules__ = data.__webpack_modules__;
|
|
52
|
+
var __webpack_runtime__ = data.__webpack_runtime__;
|
|
53
|
+
var moduleId, chunkId, i = 0;
|
|
54
|
+
for(moduleId in __webpack_modules__)if (__webpack_require__.o(__webpack_modules__, moduleId)) __webpack_require__.m[moduleId] = __webpack_modules__[moduleId];
|
|
55
|
+
if (__webpack_runtime__) __webpack_runtime__(__webpack_require__);
|
|
56
|
+
for(; i < __webpack_ids__.length; i++){
|
|
57
|
+
chunkId = __webpack_ids__[i];
|
|
58
|
+
if (__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) installedChunks[chunkId][0]();
|
|
59
|
+
installedChunks[__webpack_ids__[i]] = 0;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
__webpack_require__.f.j = function(chunkId, promises) {
|
|
63
|
+
var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : void 0;
|
|
64
|
+
if (0 !== installedChunkData) if (installedChunkData) promises.push(installedChunkData[1]);
|
|
65
|
+
else {
|
|
66
|
+
var promise = import("../" + __webpack_require__.u(chunkId)).then(installChunk, (e)=>{
|
|
67
|
+
if (0 !== installedChunks[chunkId]) installedChunks[chunkId] = void 0;
|
|
68
|
+
throw e;
|
|
69
|
+
});
|
|
70
|
+
var promise = Promise.race([
|
|
71
|
+
promise,
|
|
72
|
+
new Promise((resolve)=>{
|
|
73
|
+
installedChunkData = installedChunks[chunkId] = [
|
|
74
|
+
resolve
|
|
75
|
+
];
|
|
76
|
+
})
|
|
77
|
+
]);
|
|
78
|
+
promises.push(installedChunkData[1] = promise);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
})();
|
|
82
|
+
__webpack_require__.e("183").then(__webpack_require__.bind(__webpack_require__, "./src/index.ts?fb01")).then((module)=>{
|
|
83
|
+
try {
|
|
84
|
+
module.exec();
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.error(e);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
}).catch((e)=>{
|
|
90
|
+
console.error("\x1b[31mError: Failed to load modulo.\x1b[0m");
|
|
91
|
+
console.error(e);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
});
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_picocolors__ from "picocolors";
|
|
4
|
+
import { cac } from "cac";
|
|
5
|
+
var __webpack_modules__ = {
|
|
6
|
+
"./src/tools/log.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
n: ()=>debug_log,
|
|
9
|
+
v: ()=>logger
|
|
10
|
+
});
|
|
11
|
+
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
12
|
+
var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:path");
|
|
13
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("picocolors");
|
|
14
|
+
const logFile = node_path__WEBPACK_IMPORTED_MODULE_1__.join(process.cwd(), "modulo.debug.log");
|
|
15
|
+
let index = 0;
|
|
16
|
+
function debug_log(hint, ...params) {
|
|
17
|
+
const argv_debug = process.env.DEBUG || process.argv.includes("--debug");
|
|
18
|
+
const argv_verbose = process.argv.includes("--verbose") || process.argv.includes("-v");
|
|
19
|
+
if (!argv_debug && !argv_verbose) return;
|
|
20
|
+
const timestamp = new Date().toISOString();
|
|
21
|
+
const sn = String(index++).padStart(3, "0");
|
|
22
|
+
const logEntry = `--------------\n${sn} [${timestamp}] ${hint}\n${params.map((p)=>"object" == typeof p ? JSON.stringify(p, null, 2) : String(p)).join("\n")}\n---------------\n\n`;
|
|
23
|
+
if (argv_verbose) console.log(logEntry);
|
|
24
|
+
if (argv_debug) {
|
|
25
|
+
console.log(picocolors__WEBPACK_IMPORTED_MODULE_2__["default"].blue(`\ndebug log ${sn}`));
|
|
26
|
+
node_fs__WEBPACK_IMPORTED_MODULE_0__.appendFileSync(logFile, logEntry);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const logger = {
|
|
30
|
+
info: (msg)=>console.log(picocolors__WEBPACK_IMPORTED_MODULE_2__["default"].cyan(msg)),
|
|
31
|
+
success: (msg)=>console.log(picocolors__WEBPACK_IMPORTED_MODULE_2__["default"].green(msg)),
|
|
32
|
+
warn: (msg)=>console.log(picocolors__WEBPACK_IMPORTED_MODULE_2__["default"].yellow(msg)),
|
|
33
|
+
error: (msg)=>console.log(picocolors__WEBPACK_IMPORTED_MODULE_2__["default"].red(msg)),
|
|
34
|
+
debug: (msg)=>{
|
|
35
|
+
if (process.env.DEBUG) console.log(picocolors__WEBPACK_IMPORTED_MODULE_2__["default"].gray(`[DEBUG] ${msg}`));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
"node:fs": function(module) {
|
|
40
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
41
|
+
},
|
|
42
|
+
"node:path": function(module) {
|
|
43
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__;
|
|
44
|
+
},
|
|
45
|
+
picocolors: function(module) {
|
|
46
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_picocolors__;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __webpack_module_cache__ = {};
|
|
50
|
+
function __webpack_require__(moduleId) {
|
|
51
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
52
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
53
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
54
|
+
exports: {}
|
|
55
|
+
};
|
|
56
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
57
|
+
return module.exports;
|
|
58
|
+
}
|
|
59
|
+
__webpack_require__.m = __webpack_modules__;
|
|
60
|
+
(()=>{
|
|
61
|
+
__webpack_require__.d = (exports, definition)=>{
|
|
62
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: definition[key]
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
})();
|
|
68
|
+
(()=>{
|
|
69
|
+
__webpack_require__.f = {};
|
|
70
|
+
__webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>{
|
|
71
|
+
__webpack_require__.f[key](chunkId, promises);
|
|
72
|
+
return promises;
|
|
73
|
+
}, []));
|
|
74
|
+
})();
|
|
75
|
+
(()=>{
|
|
76
|
+
__webpack_require__.u = (chunkId)=>"" + chunkId + ".js";
|
|
77
|
+
})();
|
|
78
|
+
(()=>{
|
|
79
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
80
|
+
})();
|
|
81
|
+
(()=>{
|
|
82
|
+
__webpack_require__.r = (exports)=>{
|
|
83
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
|
|
84
|
+
value: 'Module'
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(exports, '__esModule', {
|
|
87
|
+
value: true
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
})();
|
|
91
|
+
(()=>{
|
|
92
|
+
var installedChunks = {
|
|
93
|
+
410: 0
|
|
94
|
+
};
|
|
95
|
+
var installChunk = (data)=>{
|
|
96
|
+
var __webpack_ids__ = data.__webpack_ids__;
|
|
97
|
+
var __webpack_modules__ = data.__webpack_modules__;
|
|
98
|
+
var __webpack_runtime__ = data.__webpack_runtime__;
|
|
99
|
+
var moduleId, chunkId, i = 0;
|
|
100
|
+
for(moduleId in __webpack_modules__)if (__webpack_require__.o(__webpack_modules__, moduleId)) __webpack_require__.m[moduleId] = __webpack_modules__[moduleId];
|
|
101
|
+
if (__webpack_runtime__) __webpack_runtime__(__webpack_require__);
|
|
102
|
+
for(; i < __webpack_ids__.length; i++){
|
|
103
|
+
chunkId = __webpack_ids__[i];
|
|
104
|
+
if (__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) installedChunks[chunkId][0]();
|
|
105
|
+
installedChunks[__webpack_ids__[i]] = 0;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
__webpack_require__.f.j = function(chunkId, promises) {
|
|
109
|
+
var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : void 0;
|
|
110
|
+
if (0 !== installedChunkData) if (installedChunkData) promises.push(installedChunkData[1]);
|
|
111
|
+
else {
|
|
112
|
+
var promise = import("./" + __webpack_require__.u(chunkId)).then(installChunk, (e)=>{
|
|
113
|
+
if (0 !== installedChunks[chunkId]) installedChunks[chunkId] = void 0;
|
|
114
|
+
throw e;
|
|
115
|
+
});
|
|
116
|
+
var promise = Promise.race([
|
|
117
|
+
promise,
|
|
118
|
+
new Promise((resolve)=>{
|
|
119
|
+
installedChunkData = installedChunks[chunkId] = [
|
|
120
|
+
resolve
|
|
121
|
+
];
|
|
122
|
+
})
|
|
123
|
+
]);
|
|
124
|
+
promises.push(installedChunkData[1] = promise);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
})();
|
|
128
|
+
var log = __webpack_require__("./src/tools/log.ts");
|
|
129
|
+
var package_namespaceObject = {
|
|
130
|
+
rE: "0.3.2"
|
|
131
|
+
};
|
|
132
|
+
const cli = cac("modulo");
|
|
133
|
+
cli.command("init <target>", "Initialize modulo configuration or scripts").option("-f, --force", "Force overwrite existing files").option("--path <path>", "Specify the path to initialize").option("--preset <preset>", "Specify the preset to use").action((target, options)=>{
|
|
134
|
+
__webpack_require__.e("882").then(__webpack_require__.bind(__webpack_require__, "./src/cli/init.ts")).then(({ init_tool })=>{
|
|
135
|
+
init_tool({
|
|
136
|
+
cmd: "init",
|
|
137
|
+
target: target,
|
|
138
|
+
init: {
|
|
139
|
+
path: options.path,
|
|
140
|
+
force: options.force,
|
|
141
|
+
preset: options.preset
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
cli.command("build <target>", "Build the project for production").option("-c, --config <file>", "Use specified config file").option("-w, --watch", "Watch for changes").option("--env <env>", "Specify the environment (dev/prd)").action((target, options)=>{
|
|
147
|
+
__webpack_require__.e("740").then(__webpack_require__.bind(__webpack_require__, "./src/cli/pack-code.ts")).then(({ pack_code })=>{
|
|
148
|
+
pack_code({
|
|
149
|
+
cmd: "build",
|
|
150
|
+
target: target,
|
|
151
|
+
pack: {
|
|
152
|
+
config: options.config,
|
|
153
|
+
env: options.env || "prd",
|
|
154
|
+
watch: options.watch,
|
|
155
|
+
esm: true
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
cli.command("dev <target>", "Start development server").option("-c, --config <file>", "Use specified config file").option("--env <env>", "Specify the environment (dev/prd)").option("--debug", "Enable debug mode").action((target, options)=>{
|
|
161
|
+
if (options.debug) process.env.DEBUG = "true";
|
|
162
|
+
__webpack_require__.e("740").then(__webpack_require__.bind(__webpack_require__, "./src/cli/pack-code.ts")).then(({ pack_code })=>{
|
|
163
|
+
pack_code({
|
|
164
|
+
cmd: "dev",
|
|
165
|
+
target: target,
|
|
166
|
+
pack: {
|
|
167
|
+
config: options.config,
|
|
168
|
+
env: options.env || "dev",
|
|
169
|
+
watch: true,
|
|
170
|
+
esm: true
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
cli.command("preview <target>", "Preview the production build").option("-c, --config <file>", "Use specified config file").action((target, options)=>{
|
|
176
|
+
__webpack_require__.e("740").then(__webpack_require__.bind(__webpack_require__, "./src/cli/pack-code.ts")).then(({ pack_code })=>{
|
|
177
|
+
pack_code({
|
|
178
|
+
cmd: "preview",
|
|
179
|
+
target: target,
|
|
180
|
+
pack: {
|
|
181
|
+
config: options.config,
|
|
182
|
+
env: "prd",
|
|
183
|
+
watch: false,
|
|
184
|
+
esm: true
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
cli.help();
|
|
190
|
+
cli.version(package_namespaceObject.rE);
|
|
191
|
+
function exec() {
|
|
192
|
+
try {
|
|
193
|
+
cli.parse();
|
|
194
|
+
} catch (error) {
|
|
195
|
+
log.v.error(`Error: ${error.message}`);
|
|
196
|
+
cli.outputHelp();
|
|
197
|
+
process.exit(1);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
export { exec };
|
package/package.json
CHANGED
|
@@ -2,18 +2,25 @@
|
|
|
2
2
|
"name": "@yannick-z/modulo",
|
|
3
3
|
"description": "",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.3.
|
|
6
|
-
"main": "./
|
|
5
|
+
"version": "0.3.2",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
7
|
"author": "oyangxiao",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "
|
|
10
|
-
"lint": "biome lint .",
|
|
11
|
-
"format": "biome format --write .",
|
|
12
|
-
"check": "biome check --write ."
|
|
9
|
+
"build": "rslib build",
|
|
10
|
+
"lint": "biome lint src bin rslib.config.ts",
|
|
11
|
+
"format": "biome format --write src bin rslib.config.ts package.json biome.json",
|
|
12
|
+
"check": "biome check --write src bin rslib.config.ts package.json biome.json"
|
|
13
13
|
},
|
|
14
14
|
"bin": {
|
|
15
|
-
"modulo": "./bin/modulo.js"
|
|
15
|
+
"modulo": "./dist/bin/modulo.js"
|
|
16
16
|
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"bin",
|
|
20
|
+
"src",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
17
24
|
"dependencies": {
|
|
18
25
|
"@rsbuild/core": "^1.7.3",
|
|
19
26
|
"@rsbuild/plugin-less": "^1.6.0",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import("../index.js")
|
|
4
|
+
.then((module) => {
|
|
5
|
+
try {
|
|
6
|
+
module.exec();
|
|
7
|
+
} catch (e) {
|
|
8
|
+
console.error(e);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
.catch((e) => {
|
|
13
|
+
console.error("\x1b[31mError: Failed to load modulo.\x1b[0m");
|
|
14
|
+
console.error(e);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
-
import type { Compiler, Compilation } from "@rspack/core";
|
|
3
2
|
const require = createRequire(import.meta.url);
|
|
4
3
|
import type { ModuloArgs_Pack } from "../args/index.ts";
|
|
5
4
|
import type { GLOBAL_CONFIG } from "../config/type.ts";
|
|
@@ -25,12 +24,12 @@ export class AutoExternalPlugin {
|
|
|
25
24
|
this.usedExternals = new Set<string>();
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
apply(compiler:
|
|
27
|
+
apply(compiler: any) {
|
|
29
28
|
compiler.hooks.compilation.tap(
|
|
30
29
|
"AutoExternalPlugin",
|
|
31
|
-
(compilation:
|
|
30
|
+
(compilation: any) => {
|
|
32
31
|
// 1. 扫描模块依赖
|
|
33
|
-
compilation.hooks.finishModules.tap("AutoExternalPlugin", (modules) => {
|
|
32
|
+
compilation.hooks.finishModules.tap("AutoExternalPlugin", (modules: any[]) => {
|
|
34
33
|
// ... (省略模块扫描逻辑,这里没有问题) ...
|
|
35
34
|
for (const module of modules) {
|
|
36
35
|
// @ts-ignore
|
|
@@ -86,7 +85,7 @@ export class AutoExternalPlugin {
|
|
|
86
85
|
// 或者我们可以尝试直接使用 tapAsync 到 HtmlWebpackPlugin 的实例上,如果我们能找到它
|
|
87
86
|
|
|
88
87
|
// 终极 Hook 调试: 使用 compiler.hooks.emit 来检查 assets,看是否包含 index.html,以及内容
|
|
89
|
-
compiler.hooks.emit.tapAsync("AutoExternalPlugin", (compilation, cb) => {
|
|
88
|
+
compiler.hooks.emit.tapAsync("AutoExternalPlugin", (compilation: any, cb: any) => {
|
|
90
89
|
if (process.env.DEBUG) console.log('[AutoExternalPlugin] emit hook triggered');
|
|
91
90
|
// 检查 compilation.assets
|
|
92
91
|
const assetNames = Object.keys(compilation.assets);
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
is_env_external,
|
|
9
9
|
is_string,
|
|
10
|
-
is_import_external,
|
|
11
10
|
} from "../type/guard.ts";
|
|
12
11
|
|
|
13
12
|
function getExternalUrl(args: ModuloArgs_Pack, url: ConfigExternalUrl) {
|
|
@@ -61,7 +60,9 @@ export function getExternalsAndImportMap(
|
|
|
61
60
|
const globalVar = externalLib.global || libName;
|
|
62
61
|
const importName = externalLib.importName || libName;
|
|
63
62
|
(Array.isArray(importName) ? importName : [importName]).forEach(
|
|
64
|
-
(name) =>
|
|
63
|
+
(name) => {
|
|
64
|
+
externals[name] = globalVar;
|
|
65
|
+
},
|
|
65
66
|
);
|
|
66
67
|
|
|
67
68
|
if (url) {
|
|
@@ -71,7 +72,9 @@ export function getExternalsAndImportMap(
|
|
|
71
72
|
// Importmap 模式:external 映射为包名(由 importmap 解析)
|
|
72
73
|
const importName = externalLib.importName || libName;
|
|
73
74
|
(Array.isArray(importName) ? importName : [importName]).forEach(
|
|
74
|
-
(name) =>
|
|
75
|
+
(name) => {
|
|
76
|
+
externals[name] = libName;
|
|
77
|
+
},
|
|
75
78
|
);
|
|
76
79
|
|
|
77
80
|
if (url) {
|
package/src/packer/lib.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pluginLess } from "@rsbuild/plugin-less";
|
|
2
|
-
import
|
|
2
|
+
import { build as rslibBuild, defineConfig } from "@rslib/core";
|
|
3
3
|
import picocolors from "picocolors";
|
|
4
4
|
import type { ModuloArgs_Pack } from "../args/index.ts";
|
|
5
5
|
import { get_global_config, get_packagejson } from "../config/index.ts";
|
|
@@ -23,7 +23,7 @@ export async function lib_pack(args: ModuloArgs_Pack) {
|
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const rslibConfig =
|
|
26
|
+
const rslibConfig = defineConfig({
|
|
27
27
|
source: {
|
|
28
28
|
define: config.define,
|
|
29
29
|
entry: entries,
|
|
@@ -83,8 +83,10 @@ export async function lib_pack(args: ModuloArgs_Pack) {
|
|
|
83
83
|
},
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
await rslibBuild(rslibConfig, {
|
|
87
|
+
watch: args.cmd === "build" && !!args.pack.watch,
|
|
88
|
+
root: process.cwd(),
|
|
89
|
+
});
|
|
88
90
|
|
|
89
91
|
if (args.cmd === "build") {
|
|
90
92
|
console.log(picocolors.green("\n**** 构建【module】完成 ****\n"));
|
package/.vscode/extensions.json
DELETED
package/biome.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/2.4.4/schema.json",
|
|
3
|
-
"vcs": {
|
|
4
|
-
"enabled": false,
|
|
5
|
-
"clientKind": "git",
|
|
6
|
-
"useIgnoreFile": false
|
|
7
|
-
},
|
|
8
|
-
"files": {
|
|
9
|
-
"ignoreUnknown": false
|
|
10
|
-
},
|
|
11
|
-
"formatter": {
|
|
12
|
-
"enabled": true,
|
|
13
|
-
"indentStyle": "tab"
|
|
14
|
-
},
|
|
15
|
-
"linter": {
|
|
16
|
-
"enabled": true,
|
|
17
|
-
"rules": {
|
|
18
|
-
"recommended": true
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"javascript": {
|
|
22
|
-
"formatter": {
|
|
23
|
-
"quoteStyle": "double"
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"assist": {
|
|
27
|
-
"enabled": true,
|
|
28
|
-
"actions": {
|
|
29
|
-
"source": {
|
|
30
|
-
"organizeImports": "on"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
package/rslib.config.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "@rslib/core";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
lib: [
|
|
5
|
-
{
|
|
6
|
-
dts: false,
|
|
7
|
-
format: "esm",
|
|
8
|
-
syntax: "esnext",
|
|
9
|
-
},
|
|
10
|
-
],
|
|
11
|
-
output: {
|
|
12
|
-
distPath: {
|
|
13
|
-
root: "./dist",
|
|
14
|
-
},
|
|
15
|
-
target: "node",
|
|
16
|
-
},
|
|
17
|
-
source: {
|
|
18
|
-
entry: {
|
|
19
|
-
index: "./src/index.ts",
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
package/template/index.html
DELETED
package/tsconfig.json
DELETED