@winner-fed/bundler-rsbuild 0.13.4 → 0.13.5
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/bundler-rsbuild.js +2 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +93 -0
- package/dist/config/config.js +2 -2
- package/dist/requireHook.d.ts +3 -0
- package/dist/requireHook.js +11 -0
- package/package.json +11 -8
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from))
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
|
|
24
|
+
// src/cli.ts
|
|
25
|
+
var import_esbuild = __toESM(require("@winner-fed/bundler-utils/compiled/esbuild"));
|
|
26
|
+
var import_utils = require("@winner-fed/utils");
|
|
27
|
+
var import_assert = __toESM(require("assert"));
|
|
28
|
+
var import_fs = require("fs");
|
|
29
|
+
var import_path = require("path");
|
|
30
|
+
var import_build = require("./build");
|
|
31
|
+
var import_dev = require("./dev");
|
|
32
|
+
var args = (0, import_utils.yParser)(process.argv.slice(2), {});
|
|
33
|
+
var command = args._[0];
|
|
34
|
+
var cwd = process.cwd();
|
|
35
|
+
var entry = (0, import_utils.tryPaths)([
|
|
36
|
+
(0, import_path.join)(cwd, "src/index.tsx"),
|
|
37
|
+
(0, import_path.join)(cwd, "src/index.ts"),
|
|
38
|
+
(0, import_path.join)(cwd, "index.tsx"),
|
|
39
|
+
(0, import_path.join)(cwd, "index.ts")
|
|
40
|
+
]);
|
|
41
|
+
var config = {};
|
|
42
|
+
var configFile = (0, import_path.join)(cwd, args.config || "config.ts");
|
|
43
|
+
import_utils.register.register({
|
|
44
|
+
implementor: import_esbuild.default
|
|
45
|
+
});
|
|
46
|
+
import_utils.register.clearFiles();
|
|
47
|
+
if ((0, import_fs.existsSync)(configFile)) {
|
|
48
|
+
require("./requireHook");
|
|
49
|
+
config = require(configFile).default;
|
|
50
|
+
}
|
|
51
|
+
Object.assign(config, args);
|
|
52
|
+
if (command === "build") {
|
|
53
|
+
(async () => {
|
|
54
|
+
process.env.NODE_ENV = "production";
|
|
55
|
+
(0, import_assert.default)(entry, `Build failed: entry not found.`);
|
|
56
|
+
try {
|
|
57
|
+
await (0, import_build.build)({
|
|
58
|
+
config,
|
|
59
|
+
cwd,
|
|
60
|
+
entry: {
|
|
61
|
+
[getEntryKey(entry)]: entry
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
} catch (e) {
|
|
65
|
+
console.error(e);
|
|
66
|
+
}
|
|
67
|
+
})();
|
|
68
|
+
} else if (command === "dev") {
|
|
69
|
+
(async () => {
|
|
70
|
+
process.env.NODE_ENV = "development";
|
|
71
|
+
try {
|
|
72
|
+
(0, import_assert.default)(entry, `Build failed: entry not found.`);
|
|
73
|
+
await (0, import_dev.dev)({
|
|
74
|
+
config,
|
|
75
|
+
cwd,
|
|
76
|
+
port: process.env.PORT,
|
|
77
|
+
entry: {
|
|
78
|
+
[getEntryKey(entry)]: entry
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.error(e);
|
|
83
|
+
}
|
|
84
|
+
})();
|
|
85
|
+
} else {
|
|
86
|
+
error(`Unsupported command ${command}.`);
|
|
87
|
+
}
|
|
88
|
+
function error(msg) {
|
|
89
|
+
console.error(import_utils.chalk.red(msg));
|
|
90
|
+
}
|
|
91
|
+
function getEntryKey(path) {
|
|
92
|
+
return (0, import_path.basename)(path, (0, import_path.extname)(path));
|
|
93
|
+
}
|
package/dist/config/config.js
CHANGED
|
@@ -48,7 +48,7 @@ var import_serverConfig = require("./serverConfig");
|
|
|
48
48
|
var import_sourceConfig = require("./sourceConfig");
|
|
49
49
|
var import_toolsConfig = require("./toolsConfig");
|
|
50
50
|
async function getRsbuildConfig(opts) {
|
|
51
|
-
var _a, _b;
|
|
51
|
+
var _a, _b, _c;
|
|
52
52
|
const { userConfig = {} } = opts;
|
|
53
53
|
const isDev = opts.env === import_types.Env.development;
|
|
54
54
|
const sourceConfig = (0, import_sourceConfig.getSourceConfig)(opts);
|
|
@@ -128,7 +128,7 @@ async function getRsbuildConfig(opts) {
|
|
|
128
128
|
rspack: import_core.rspack
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
if (Object.keys((userConfig == null ? void 0 : userConfig.rsbuild.config) ?? {}).length) {
|
|
131
|
+
if (Object.keys(((_c = userConfig == null ? void 0 : userConfig.rsbuild) == null ? void 0 : _c.config) ?? {}).length) {
|
|
132
132
|
return (0, import_core.mergeRsbuildConfig)(rsbuildConfig, userConfig == null ? void 0 : userConfig.rsbuild.config);
|
|
133
133
|
}
|
|
134
134
|
return rsbuildConfig;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/requireHook.ts
|
|
2
|
+
var hookPropertyMap = /* @__PURE__ */ new Map([
|
|
3
|
+
["less", "@winner-fed/bundler-utils/compiled/less"]
|
|
4
|
+
]);
|
|
5
|
+
var mod = require("module");
|
|
6
|
+
var resolveFilename = mod._resolveFilename;
|
|
7
|
+
mod._resolveFilename = function(request, parent, isMain, options) {
|
|
8
|
+
const hookResolved = hookPropertyMap.get(request);
|
|
9
|
+
if (hookResolved) request = hookResolved;
|
|
10
|
+
return resolveFilename.call(mod, request, parent, isMain, options);
|
|
11
|
+
};
|
package/package.json
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@winner-fed/bundler-rsbuild",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.5",
|
|
4
4
|
"description": "@winner-fed/bundler-rsbuild",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"bundler-rsbuild": "bin/bundler-rsbuild.js"
|
|
10
|
+
},
|
|
8
11
|
"files": [
|
|
9
12
|
"dist"
|
|
10
13
|
],
|
|
11
14
|
"dependencies": {
|
|
12
|
-
"@rsbuild/core": "1.2.
|
|
13
|
-
"@rsbuild/plugin-babel": "1.0.
|
|
14
|
-
"@rsbuild/plugin-less": "1.1.
|
|
15
|
+
"@rsbuild/core": "1.2.17",
|
|
16
|
+
"@rsbuild/plugin-babel": "1.0.4",
|
|
17
|
+
"@rsbuild/plugin-less": "1.1.1",
|
|
15
18
|
"@rsbuild/plugin-node-polyfill": "1.3.0",
|
|
16
|
-
"@rsbuild/plugin-sass": "1.2.
|
|
17
|
-
"@rsbuild/plugin-stylus": "1.0.
|
|
19
|
+
"@rsbuild/plugin-sass": "1.2.2",
|
|
20
|
+
"@rsbuild/plugin-stylus": "1.0.8",
|
|
18
21
|
"@rsbuild/plugin-type-check": "1.2.1",
|
|
19
|
-
"@winner-fed/bundler-utils": "0.13.
|
|
20
|
-
"@winner-fed/utils": "0.13.
|
|
22
|
+
"@winner-fed/bundler-utils": "0.13.5",
|
|
23
|
+
"@winner-fed/utils": "0.13.5"
|
|
21
24
|
},
|
|
22
25
|
"publishConfig": {
|
|
23
26
|
"access": "public"
|