@srvkit/rsbuild 0.1.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/LICENSE +21 -0
- package/README.md +12 -0
- package/dist/_virtual/_rolldown/runtime.js +35 -0
- package/dist/constants/path.js +13 -0
- package/dist/constants/path.js.map +1 -0
- package/dist/constants/path.mjs +12 -0
- package/dist/constants/path.mjs.map +1 -0
- package/dist/functions/ssr.js +18 -0
- package/dist/functions/ssr.js.map +1 -0
- package/dist/functions/ssr.mjs +17 -0
- package/dist/functions/ssr.mjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +17 -0
- package/dist/index.mjs +11 -0
- package/dist/node.d.ts +5 -0
- package/dist/node.js +17 -0
- package/dist/node.mjs +11 -0
- package/dist/package.js +18 -0
- package/dist/package.js.map +1 -0
- package/dist/package.mjs +12 -0
- package/dist/package.mjs.map +1 -0
- package/dist/plugin.d.ts +7 -0
- package/dist/plugin.js +12 -0
- package/dist/plugin.mjs +11 -0
- package/dist/plugins/build/index.d.ts +7 -0
- package/dist/plugins/build/index.js +97 -0
- package/dist/plugins/build/index.js.map +1 -0
- package/dist/plugins/build/index.mjs +96 -0
- package/dist/plugins/build/index.mjs.map +1 -0
- package/dist/plugins/copy/index.d.ts +7 -0
- package/dist/plugins/copy/index.js +35 -0
- package/dist/plugins/copy/index.js.map +1 -0
- package/dist/plugins/copy/index.mjs +33 -0
- package/dist/plugins/copy/index.mjs.map +1 -0
- package/dist/plugins/dev/index.d.ts +7 -0
- package/dist/plugins/dev/index.js +170 -0
- package/dist/plugins/dev/index.js.map +1 -0
- package/dist/plugins/dev/index.mjs +166 -0
- package/dist/plugins/dev/index.mjs.map +1 -0
- package/dist/plugins/index.d.ts +7 -0
- package/dist/plugins/index.js +24 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/index.mjs +24 -0
- package/dist/plugins/index.mjs.map +1 -0
- package/dist/runtime.d.ts +4 -0
- package/dist/runtime.js +17 -0
- package/dist/runtime.mjs +11 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-present, Alpheus
|
|
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,12 @@
|
|
|
1
|
+
# @srvkit/rsbuild
|
|
2
|
+
|
|
3
|
+
A toolkit for building JavaScript server applications.
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
For more information,
|
|
8
|
+
please refer to the [documentation](https://srvkit.github.io).
|
|
9
|
+
|
|
10
|
+
## License
|
|
11
|
+
|
|
12
|
+
This project is licensed under the terms of the MIT license.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
var __create = Object.create;
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
14
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
18
|
+
key = keys[i];
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
20
|
+
__defProp(to, key, {
|
|
21
|
+
get: ((k) => from[k]).bind(null, key),
|
|
22
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const VIRTUAL_ENTRY = "./__srvkit_entry__.js";
|
|
11
|
+
|
|
12
|
+
exports.VIRTUAL_ENTRY = VIRTUAL_ENTRY;
|
|
13
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","names":[],"sources":["../../src/constants/path.ts"],"sourcesContent":["const VIRTUAL_ENTRY = \"./__srvkit_entry__.js\" as const;\n\nexport { VIRTUAL_ENTRY };\n"],"mappings":";;;;;;;;;AAAA,MAAM,gBAAgB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
const VIRTUAL_ENTRY = "./__srvkit_entry__.js";
|
|
10
|
+
|
|
11
|
+
export { VIRTUAL_ENTRY };
|
|
12
|
+
//# sourceMappingURL=path.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.mjs","names":[],"sources":["../../src/constants/path.ts"],"sourcesContent":["const VIRTUAL_ENTRY = \"./__srvkit_entry__.js\" as const;\n\nexport { VIRTUAL_ENTRY };\n"],"mappings":";;;;;;;;AAAA,MAAM,gBAAgB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const getSsrTarget = (runtime) => {
|
|
11
|
+
switch (runtime) {
|
|
12
|
+
case "workerd": return "webworker";
|
|
13
|
+
default: return "node";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.getSsrTarget = getSsrTarget;
|
|
18
|
+
//# sourceMappingURL=ssr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr.js","names":[],"sources":["../../src/functions/ssr.ts"],"sourcesContent":["import type { Rspack } from \"@rsbuild/core\";\nimport type { Runtime } from \"@srvkit/common/@types/options/complete\";\n\nconst getSsrTarget = (runtime: Runtime): Rspack.Target => {\n switch (runtime) {\n case \"workerd\":\n return \"webworker\";\n default:\n return \"node\";\n }\n};\n\nexport { getSsrTarget };\n"],"mappings":";;;;;;;;;AAGA,MAAM,gBAAgB,YAAoC;CACtD,QAAQ,SAAR;EACI,KAAK,WACD,OAAO;EACX,SACI,OAAO;CACf;AACJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
const getSsrTarget = (runtime) => {
|
|
10
|
+
switch (runtime) {
|
|
11
|
+
case "workerd": return "webworker";
|
|
12
|
+
default: return "node";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { getSsrTarget };
|
|
17
|
+
//# sourceMappingURL=ssr.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr.mjs","names":[],"sources":["../../src/functions/ssr.ts"],"sourcesContent":["import type { Rspack } from \"@rsbuild/core\";\nimport type { Runtime } from \"@srvkit/common/@types/options/complete\";\n\nconst getSsrTarget = (runtime: Runtime): Rspack.Target => {\n switch (runtime) {\n case \"workerd\":\n return \"webworker\";\n default:\n return \"node\";\n }\n};\n\nexport { getSsrTarget };\n"],"mappings":";;;;;;;;AAGA,MAAM,gBAAgB,YAAoC;CACtD,QAAQ,SAAR;EACI,KAAK,WACD,OAAO;EACX,SACI,OAAO;CACf;AACJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ErrorHandler, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest } from "@srvkit/common/@types/server";
|
|
4
|
+
import { defineServer } from "@srvkit/common/functions/server/define";
|
|
5
|
+
export { type ErrorHandler, type Server, type ServerHandler, type ServerMiddleware, type ServerOptions, type ServerPlugin, type ServerRequest, defineServer };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
10
|
+
let _srvkit_common_functions_server_define = require("@srvkit/common/functions/server/define");
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, 'defineServer', {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _srvkit_common_functions_server_define.defineServer;
|
|
16
|
+
}
|
|
17
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
import { defineServer } from "@srvkit/common/functions/server/define";
|
|
10
|
+
|
|
11
|
+
export { defineServer };
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { AdapterMeta, FetchHandler, NodeHttpHandler } from "@srvkit/common/@types/node";
|
|
4
|
+
import { toFetchHandler } from "@srvkit/common/node";
|
|
5
|
+
export { type AdapterMeta, type FetchHandler, type NodeHttpHandler, toFetchHandler };
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
10
|
+
let _srvkit_common_node = require("@srvkit/common/node");
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, 'toFetchHandler', {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _srvkit_common_node.toFetchHandler;
|
|
16
|
+
}
|
|
17
|
+
});
|
package/dist/node.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
import { toFetchHandler } from "@srvkit/common/node";
|
|
10
|
+
|
|
11
|
+
export { toFetchHandler };
|
package/dist/package.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var name = "@srvkit/rsbuild";
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, 'name', {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return name;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
package/dist/package.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
var name = "@srvkit/rsbuild";
|
|
10
|
+
|
|
11
|
+
export { name };
|
|
12
|
+
//# sourceMappingURL=package.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.mjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { plugin } from "./plugins/index.js";
|
|
4
|
+
import { Runtime } from "@srvkit/common/@types/options/complete";
|
|
5
|
+
import { BuildTarget, BundleMode } from "@srvkit/common/@types/options/complete/build";
|
|
6
|
+
import { BuildOptions, DevOptions, HttpsOptions, Options } from "@srvkit/common/@types/options/default";
|
|
7
|
+
export { type BuildOptions, type BuildTarget, type BundleMode, type DevOptions, type HttpsOptions, type Options, type Runtime, plugin as pluginSrvkit };
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
10
|
+
const require_index = require('./plugins/index.js');
|
|
11
|
+
|
|
12
|
+
exports.pluginSrvkit = require_index.plugin;
|
package/dist/plugin.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
import { plugin } from "./plugins/index.mjs";
|
|
10
|
+
|
|
11
|
+
export { plugin as pluginSrvkit };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { RsbuildPlugin } from "@rsbuild/core";
|
|
4
|
+
import { ResolvedOptions } from "@srvkit/common/@types/options/resolved";
|
|
5
|
+
declare const buildPlugin: (opts: ResolvedOptions) => RsbuildPlugin;
|
|
6
|
+
export { buildPlugin };
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
10
|
+
const require_path = require('../../constants/path.js');
|
|
11
|
+
const require_ssr = require('../../functions/ssr.js');
|
|
12
|
+
const require_package = require('../../package.js');
|
|
13
|
+
let node_module = require("node:module");
|
|
14
|
+
let _srvkit_common_functions_build_virtual_entry = require("@srvkit/common/functions/build/virtual-entry");
|
|
15
|
+
let _srvkit_common_functions_package_package_json = require("@srvkit/common/functions/package/package-json");
|
|
16
|
+
|
|
17
|
+
const buildPlugin = (opts) => {
|
|
18
|
+
const build = opts.build;
|
|
19
|
+
const packageJson = (0, _srvkit_common_functions_package_package_json.getPackageJson)(opts.cwd);
|
|
20
|
+
return {
|
|
21
|
+
name: "srvkit:build",
|
|
22
|
+
apply: "build",
|
|
23
|
+
async setup(api) {
|
|
24
|
+
const ssrTarget = require_ssr.getSsrTarget(opts.runtime);
|
|
25
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig }) => {
|
|
26
|
+
const overrideConfig = {
|
|
27
|
+
source: { entry: { index: require_path.VIRTUAL_ENTRY } },
|
|
28
|
+
output: {
|
|
29
|
+
target: "node",
|
|
30
|
+
distPath: build.outputDir,
|
|
31
|
+
copy: void 0
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
if (build.bundle === "standalone") overrideConfig.source = {
|
|
35
|
+
...overrideConfig.source,
|
|
36
|
+
include: [...overrideConfig.source?.include ?? [], /[\\/]node_modules[\\/]/]
|
|
37
|
+
};
|
|
38
|
+
return mergeRsbuildConfig(config, overrideConfig);
|
|
39
|
+
});
|
|
40
|
+
api.modifyBundlerChain((chain, { rspack }) => {
|
|
41
|
+
chain.plugin("limit-chunk").use(rspack.optimize.LimitChunkCountPlugin, [{ maxChunks: 1 }]);
|
|
42
|
+
chain.plugin("virtual-modules").use(rspack.experiments.VirtualModulesPlugin, [{ [require_path.VIRTUAL_ENTRY]: (0, _srvkit_common_functions_build_virtual_entry.createVirtualEntryCode)({
|
|
43
|
+
...opts,
|
|
44
|
+
packageName: require_package.name
|
|
45
|
+
}) }]);
|
|
46
|
+
});
|
|
47
|
+
api.modifyRspackConfig((config, { mergeConfig }) => {
|
|
48
|
+
const isModule = packageJson.type === "module";
|
|
49
|
+
const nodeExternals = [...node_module.builtinModules, /^node:/];
|
|
50
|
+
const overrideConfig = {
|
|
51
|
+
resolve: {
|
|
52
|
+
/** @see https://rspack.rs/config/resolve#extend-default-value */
|
|
53
|
+
conditionNames: [opts.runtime, "..."] },
|
|
54
|
+
target: ssrTarget,
|
|
55
|
+
node: {
|
|
56
|
+
__dirname: false,
|
|
57
|
+
__filename: false
|
|
58
|
+
},
|
|
59
|
+
optimization: {
|
|
60
|
+
minimize: build.minify,
|
|
61
|
+
splitChunks: false,
|
|
62
|
+
runtimeChunk: false
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
if (build.bundle === "external") {
|
|
66
|
+
const depExternals = [
|
|
67
|
+
...Object.keys(packageJson.dependencies ?? {}),
|
|
68
|
+
...Object.keys(packageJson.peerDependencies ?? {}),
|
|
69
|
+
...Object.keys(packageJson.optionalDependencies ?? {})
|
|
70
|
+
].map((name) => new RegExp(`^${name.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)}([\\/]|$)`));
|
|
71
|
+
overrideConfig.externals = [...nodeExternals, ...depExternals];
|
|
72
|
+
overrideConfig.externalsType = isModule ? "module-import" : "commonjs";
|
|
73
|
+
}
|
|
74
|
+
if (build.bundle === "standalone") overrideConfig.externals = nodeExternals;
|
|
75
|
+
if (build.target === "server") overrideConfig.output = {
|
|
76
|
+
...overrideConfig.output,
|
|
77
|
+
filename: build.outputFile,
|
|
78
|
+
library: void 0,
|
|
79
|
+
...isModule ? { module: true } : {}
|
|
80
|
+
};
|
|
81
|
+
if (build.target === "handler") overrideConfig.output = {
|
|
82
|
+
...overrideConfig.output,
|
|
83
|
+
filename: build.outputFile,
|
|
84
|
+
library: {
|
|
85
|
+
type: isModule ? "module" : "commonjs2",
|
|
86
|
+
export: "default"
|
|
87
|
+
},
|
|
88
|
+
...isModule ? { module: true } : {}
|
|
89
|
+
};
|
|
90
|
+
return mergeConfig(config, overrideConfig);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
exports.buildPlugin = buildPlugin;
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["getSsrTarget","VIRTUAL_ENTRY","name","builtinModules"],"sources":["../../../src/plugins/build/index.ts"],"sourcesContent":["import type {\n ModifyBundlerChainUtils,\n RsbuildConfig,\n RsbuildPlugin,\n RsbuildPluginAPI,\n Rspack,\n RspackChain,\n} from \"@rsbuild/core\";\nimport type {\n ResolvedBuildOptions,\n ResolvedOptions,\n} from \"@srvkit/common/@types/options/resolved\";\nimport type { PackageJson } from \"@srvkit/common/functions/package/package-json\";\n\nimport { builtinModules } from \"node:module\";\n\nimport { createVirtualEntryCode } from \"@srvkit/common/functions/build/virtual-entry\";\nimport { getPackageJson } from \"@srvkit/common/functions/package/package-json\";\n\nimport { VIRTUAL_ENTRY } from \"#/constants/path\";\nimport { getSsrTarget } from \"#/functions/ssr\";\nimport { name } from \"#/root/package.json\";\n\nconst buildPlugin = (opts: ResolvedOptions): RsbuildPlugin => {\n const build: ResolvedBuildOptions = opts.build;\n\n const packageJson: PackageJson = getPackageJson(opts.cwd);\n\n return {\n name: \"srvkit:build\",\n apply: \"build\",\n async setup(api: RsbuildPluginAPI): Promise<void> {\n const ssrTarget: Rspack.Target = getSsrTarget(opts.runtime);\n\n api.modifyRsbuildConfig(\n (\n config: RsbuildConfig,\n { mergeRsbuildConfig },\n ): RsbuildConfig => {\n const overrideConfig: RsbuildConfig = {\n source: {\n entry: {\n index: VIRTUAL_ENTRY,\n },\n },\n output: {\n target: \"node\",\n distPath: build.outputDir,\n copy: void 0,\n },\n };\n\n // Enforce the bundler to apply SWC configuration to third-party dependencies\n if (build.bundle === \"standalone\") {\n overrideConfig.source = {\n ...overrideConfig.source,\n include: [\n ...(overrideConfig.source?.include ?? []),\n /[\\\\/]node_modules[\\\\/]/,\n ],\n };\n }\n\n return mergeRsbuildConfig(config, overrideConfig);\n },\n );\n\n api.modifyBundlerChain(\n (\n chain: RspackChain,\n { rspack }: ModifyBundlerChainUtils,\n ): void => {\n // Avoid externalizing chunks\n chain\n .plugin(\"limit-chunk\")\n .use(rspack.optimize.LimitChunkCountPlugin, [\n {\n maxChunks: 1,\n },\n ]);\n\n // Add support for virtual modules\n chain\n .plugin(\"virtual-modules\")\n .use(rspack.experiments.VirtualModulesPlugin, [\n {\n [VIRTUAL_ENTRY]: createVirtualEntryCode({\n ...opts,\n packageName: name,\n }),\n },\n ]);\n },\n );\n\n api.modifyRspackConfig(\n (config, { mergeConfig }): Rspack.Configuration => {\n const isModule: boolean = packageJson.type === \"module\";\n\n const nodeExternals: (string | RegExp)[] = [\n ...builtinModules,\n /^node:/,\n ];\n\n const overrideConfig: Rspack.Configuration = {\n resolve: {\n /** @see https://rspack.rs/config/resolve#extend-default-value */\n conditionNames: [\n opts.runtime,\n \"...\", // Default values\n ],\n },\n target: ssrTarget,\n node: {\n __dirname: false,\n __filename: false,\n },\n optimization: {\n minimize: build.minify,\n splitChunks: false,\n runtimeChunk: false,\n },\n };\n\n // bundle: external\n\n if (build.bundle === \"external\") {\n const depNames: string[] = [\n ...Object.keys(packageJson.dependencies ?? {}),\n ...Object.keys(packageJson.peerDependencies ?? {}),\n ...Object.keys(\n packageJson.optionalDependencies ?? {},\n ),\n ];\n\n const depExternals: RegExp[] = depNames.map(\n (name: string): RegExp =>\n new RegExp(\n `^${name.replace(/[.*+?^${}()|[\\]\\\\]/g, String.raw`\\$&`)}([\\\\/]|$)`,\n ),\n );\n\n overrideConfig.externals = [\n ...nodeExternals,\n ...depExternals,\n ];\n\n overrideConfig.externalsType = isModule\n ? \"module-import\"\n : \"commonjs\";\n }\n\n // bundle: standalone\n\n if (build.bundle === \"standalone\") {\n overrideConfig.externals = nodeExternals;\n }\n\n // target: server\n\n if (build.target === \"server\") {\n overrideConfig.output = {\n ...overrideConfig.output,\n filename: build.outputFile,\n library: void 0,\n ...(isModule\n ? {\n module: true,\n }\n : {}),\n };\n }\n\n // target: handler\n\n if (build.target === \"handler\") {\n overrideConfig.output = {\n ...overrideConfig.output,\n filename: build.outputFile,\n library: {\n type: isModule ? \"module\" : \"commonjs2\",\n export: \"default\",\n },\n ...(isModule\n ? {\n module: true,\n }\n : {}),\n };\n }\n\n return mergeConfig(config, overrideConfig);\n },\n );\n },\n };\n};\n\nexport { buildPlugin };\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,MAAM,eAAe,SAAyC;CAC1D,MAAM,QAA8B,KAAK;CAEzC,MAAM,gFAA0C,KAAK,GAAG;CAExD,OAAO;EACH,MAAM;EACN,OAAO;EACP,MAAM,MAAM,KAAsC;GAC9C,MAAM,YAA2BA,yBAAa,KAAK,OAAO;GAE1D,IAAI,qBAEI,QACA,EAAE,yBACc;IAChB,MAAM,iBAAgC;KAClC,QAAQ,EACJ,OAAO,EACH,OAAOC,2BACX,EACJ;KACA,QAAQ;MACJ,QAAQ;MACR,UAAU,MAAM;MAChB,MAAM,KAAK;KACf;IACJ;IAGA,IAAI,MAAM,WAAW,cACjB,eAAe,SAAS;KACpB,GAAG,eAAe;KAClB,SAAS,CACL,GAAI,eAAe,QAAQ,WAAW,CAAC,GACvC,wBACJ;IACJ;IAGJ,OAAO,mBAAmB,QAAQ,cAAc;GACpD,CACJ;GAEA,IAAI,oBAEI,OACA,EAAE,aACK;IAEP,MACK,OAAO,aAAa,CAAC,CACrB,IAAI,OAAO,SAAS,uBAAuB,CACxC,EACI,WAAW,EACf,CACJ,CAAC;IAGL,MACK,OAAO,iBAAiB,CAAC,CACzB,IAAI,OAAO,YAAY,sBAAsB,CAC1C,GACKA,sGAAuC;KACpC,GAAG;KACH,aAAaC;IACjB,CAAC,EACL,CACJ,CAAC;GACT,CACJ;GAEA,IAAI,oBACC,QAAQ,EAAE,kBAAwC;IAC/C,MAAM,WAAoB,YAAY,SAAS;IAE/C,MAAM,gBAAqC,CACvC,GAAGC,4BACH,QACJ;IAEA,MAAM,iBAAuC;KACzC,SAAS;;AAEL,gBAAgB,CACZ,KAAK,SACL,KACJ,EACJ;KACA,QAAQ;KACR,MAAM;MACF,WAAW;MACX,YAAY;KAChB;KACA,cAAc;MACV,UAAU,MAAM;MAChB,aAAa;MACb,cAAc;KAClB;IACJ;IAIA,IAAI,MAAM,WAAW,YAAY;KAS7B,MAAM,eAAyB;MAP3B,GAAG,OAAO,KAAK,YAAY,gBAAgB,CAAC,CAAC;MAC7C,GAAG,OAAO,KAAK,YAAY,oBAAoB,CAAC,CAAC;MACjD,GAAG,OAAO,KACN,YAAY,wBAAwB,CAAC,CACzC;KAGkC,CAAC,CAAC,KACnC,SACG,IAAI,OACA,IAAI,KAAK,QAAQ,uBAAuB,OAAO,GAAG,KAAK,EAAE,UAC7D,CACR;KAEA,eAAe,YAAY,CACvB,GAAG,eACH,GAAG,YACP;KAEA,eAAe,gBAAgB,WACzB,kBACA;IACV;IAIA,IAAI,MAAM,WAAW,cACjB,eAAe,YAAY;IAK/B,IAAI,MAAM,WAAW,UACjB,eAAe,SAAS;KACpB,GAAG,eAAe;KAClB,UAAU,MAAM;KAChB,SAAS,KAAK;KACd,GAAI,WACE,EACI,QAAQ,KACZ,IACA,CAAC;IACX;IAKJ,IAAI,MAAM,WAAW,WACjB,eAAe,SAAS;KACpB,GAAG,eAAe;KAClB,UAAU,MAAM;KAChB,SAAS;MACL,MAAM,WAAW,WAAW;MAC5B,QAAQ;KACZ;KACA,GAAI,WACE,EACI,QAAQ,KACZ,IACA,CAAC;IACX;IAGJ,OAAO,YAAY,QAAQ,cAAc;GAC7C,CACJ;EACJ;CACJ;AACJ"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
import { VIRTUAL_ENTRY } from "../../constants/path.mjs";
|
|
10
|
+
import { getSsrTarget } from "../../functions/ssr.mjs";
|
|
11
|
+
import { name } from "../../package.mjs";
|
|
12
|
+
import { builtinModules } from "node:module";
|
|
13
|
+
import { createVirtualEntryCode } from "@srvkit/common/functions/build/virtual-entry";
|
|
14
|
+
import { getPackageJson } from "@srvkit/common/functions/package/package-json";
|
|
15
|
+
|
|
16
|
+
const buildPlugin = (opts) => {
|
|
17
|
+
const build = opts.build;
|
|
18
|
+
const packageJson = getPackageJson(opts.cwd);
|
|
19
|
+
return {
|
|
20
|
+
name: "srvkit:build",
|
|
21
|
+
apply: "build",
|
|
22
|
+
async setup(api) {
|
|
23
|
+
const ssrTarget = getSsrTarget(opts.runtime);
|
|
24
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig }) => {
|
|
25
|
+
const overrideConfig = {
|
|
26
|
+
source: { entry: { index: VIRTUAL_ENTRY } },
|
|
27
|
+
output: {
|
|
28
|
+
target: "node",
|
|
29
|
+
distPath: build.outputDir,
|
|
30
|
+
copy: void 0
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
if (build.bundle === "standalone") overrideConfig.source = {
|
|
34
|
+
...overrideConfig.source,
|
|
35
|
+
include: [...overrideConfig.source?.include ?? [], /[\\/]node_modules[\\/]/]
|
|
36
|
+
};
|
|
37
|
+
return mergeRsbuildConfig(config, overrideConfig);
|
|
38
|
+
});
|
|
39
|
+
api.modifyBundlerChain((chain, { rspack }) => {
|
|
40
|
+
chain.plugin("limit-chunk").use(rspack.optimize.LimitChunkCountPlugin, [{ maxChunks: 1 }]);
|
|
41
|
+
chain.plugin("virtual-modules").use(rspack.experiments.VirtualModulesPlugin, [{ [VIRTUAL_ENTRY]: createVirtualEntryCode({
|
|
42
|
+
...opts,
|
|
43
|
+
packageName: name
|
|
44
|
+
}) }]);
|
|
45
|
+
});
|
|
46
|
+
api.modifyRspackConfig((config, { mergeConfig }) => {
|
|
47
|
+
const isModule = packageJson.type === "module";
|
|
48
|
+
const nodeExternals = [...builtinModules, /^node:/];
|
|
49
|
+
const overrideConfig = {
|
|
50
|
+
resolve: {
|
|
51
|
+
/** @see https://rspack.rs/config/resolve#extend-default-value */
|
|
52
|
+
conditionNames: [opts.runtime, "..."] },
|
|
53
|
+
target: ssrTarget,
|
|
54
|
+
node: {
|
|
55
|
+
__dirname: false,
|
|
56
|
+
__filename: false
|
|
57
|
+
},
|
|
58
|
+
optimization: {
|
|
59
|
+
minimize: build.minify,
|
|
60
|
+
splitChunks: false,
|
|
61
|
+
runtimeChunk: false
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
if (build.bundle === "external") {
|
|
65
|
+
const depExternals = [
|
|
66
|
+
...Object.keys(packageJson.dependencies ?? {}),
|
|
67
|
+
...Object.keys(packageJson.peerDependencies ?? {}),
|
|
68
|
+
...Object.keys(packageJson.optionalDependencies ?? {})
|
|
69
|
+
].map((name) => new RegExp(`^${name.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)}([\\/]|$)`));
|
|
70
|
+
overrideConfig.externals = [...nodeExternals, ...depExternals];
|
|
71
|
+
overrideConfig.externalsType = isModule ? "module-import" : "commonjs";
|
|
72
|
+
}
|
|
73
|
+
if (build.bundle === "standalone") overrideConfig.externals = nodeExternals;
|
|
74
|
+
if (build.target === "server") overrideConfig.output = {
|
|
75
|
+
...overrideConfig.output,
|
|
76
|
+
filename: build.outputFile,
|
|
77
|
+
library: void 0,
|
|
78
|
+
...isModule ? { module: true } : {}
|
|
79
|
+
};
|
|
80
|
+
if (build.target === "handler") overrideConfig.output = {
|
|
81
|
+
...overrideConfig.output,
|
|
82
|
+
filename: build.outputFile,
|
|
83
|
+
library: {
|
|
84
|
+
type: isModule ? "module" : "commonjs2",
|
|
85
|
+
export: "default"
|
|
86
|
+
},
|
|
87
|
+
...isModule ? { module: true } : {}
|
|
88
|
+
};
|
|
89
|
+
return mergeConfig(config, overrideConfig);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export { buildPlugin };
|
|
96
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugins/build/index.ts"],"sourcesContent":["import type {\n ModifyBundlerChainUtils,\n RsbuildConfig,\n RsbuildPlugin,\n RsbuildPluginAPI,\n Rspack,\n RspackChain,\n} from \"@rsbuild/core\";\nimport type {\n ResolvedBuildOptions,\n ResolvedOptions,\n} from \"@srvkit/common/@types/options/resolved\";\nimport type { PackageJson } from \"@srvkit/common/functions/package/package-json\";\n\nimport { builtinModules } from \"node:module\";\n\nimport { createVirtualEntryCode } from \"@srvkit/common/functions/build/virtual-entry\";\nimport { getPackageJson } from \"@srvkit/common/functions/package/package-json\";\n\nimport { VIRTUAL_ENTRY } from \"#/constants/path\";\nimport { getSsrTarget } from \"#/functions/ssr\";\nimport { name } from \"#/root/package.json\";\n\nconst buildPlugin = (opts: ResolvedOptions): RsbuildPlugin => {\n const build: ResolvedBuildOptions = opts.build;\n\n const packageJson: PackageJson = getPackageJson(opts.cwd);\n\n return {\n name: \"srvkit:build\",\n apply: \"build\",\n async setup(api: RsbuildPluginAPI): Promise<void> {\n const ssrTarget: Rspack.Target = getSsrTarget(opts.runtime);\n\n api.modifyRsbuildConfig(\n (\n config: RsbuildConfig,\n { mergeRsbuildConfig },\n ): RsbuildConfig => {\n const overrideConfig: RsbuildConfig = {\n source: {\n entry: {\n index: VIRTUAL_ENTRY,\n },\n },\n output: {\n target: \"node\",\n distPath: build.outputDir,\n copy: void 0,\n },\n };\n\n // Enforce the bundler to apply SWC configuration to third-party dependencies\n if (build.bundle === \"standalone\") {\n overrideConfig.source = {\n ...overrideConfig.source,\n include: [\n ...(overrideConfig.source?.include ?? []),\n /[\\\\/]node_modules[\\\\/]/,\n ],\n };\n }\n\n return mergeRsbuildConfig(config, overrideConfig);\n },\n );\n\n api.modifyBundlerChain(\n (\n chain: RspackChain,\n { rspack }: ModifyBundlerChainUtils,\n ): void => {\n // Avoid externalizing chunks\n chain\n .plugin(\"limit-chunk\")\n .use(rspack.optimize.LimitChunkCountPlugin, [\n {\n maxChunks: 1,\n },\n ]);\n\n // Add support for virtual modules\n chain\n .plugin(\"virtual-modules\")\n .use(rspack.experiments.VirtualModulesPlugin, [\n {\n [VIRTUAL_ENTRY]: createVirtualEntryCode({\n ...opts,\n packageName: name,\n }),\n },\n ]);\n },\n );\n\n api.modifyRspackConfig(\n (config, { mergeConfig }): Rspack.Configuration => {\n const isModule: boolean = packageJson.type === \"module\";\n\n const nodeExternals: (string | RegExp)[] = [\n ...builtinModules,\n /^node:/,\n ];\n\n const overrideConfig: Rspack.Configuration = {\n resolve: {\n /** @see https://rspack.rs/config/resolve#extend-default-value */\n conditionNames: [\n opts.runtime,\n \"...\", // Default values\n ],\n },\n target: ssrTarget,\n node: {\n __dirname: false,\n __filename: false,\n },\n optimization: {\n minimize: build.minify,\n splitChunks: false,\n runtimeChunk: false,\n },\n };\n\n // bundle: external\n\n if (build.bundle === \"external\") {\n const depNames: string[] = [\n ...Object.keys(packageJson.dependencies ?? {}),\n ...Object.keys(packageJson.peerDependencies ?? {}),\n ...Object.keys(\n packageJson.optionalDependencies ?? {},\n ),\n ];\n\n const depExternals: RegExp[] = depNames.map(\n (name: string): RegExp =>\n new RegExp(\n `^${name.replace(/[.*+?^${}()|[\\]\\\\]/g, String.raw`\\$&`)}([\\\\/]|$)`,\n ),\n );\n\n overrideConfig.externals = [\n ...nodeExternals,\n ...depExternals,\n ];\n\n overrideConfig.externalsType = isModule\n ? \"module-import\"\n : \"commonjs\";\n }\n\n // bundle: standalone\n\n if (build.bundle === \"standalone\") {\n overrideConfig.externals = nodeExternals;\n }\n\n // target: server\n\n if (build.target === \"server\") {\n overrideConfig.output = {\n ...overrideConfig.output,\n filename: build.outputFile,\n library: void 0,\n ...(isModule\n ? {\n module: true,\n }\n : {}),\n };\n }\n\n // target: handler\n\n if (build.target === \"handler\") {\n overrideConfig.output = {\n ...overrideConfig.output,\n filename: build.outputFile,\n library: {\n type: isModule ? \"module\" : \"commonjs2\",\n export: \"default\",\n },\n ...(isModule\n ? {\n module: true,\n }\n : {}),\n };\n }\n\n return mergeConfig(config, overrideConfig);\n },\n );\n },\n };\n};\n\nexport { buildPlugin };\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAM,eAAe,SAAyC;CAC1D,MAAM,QAA8B,KAAK;CAEzC,MAAM,cAA2B,eAAe,KAAK,GAAG;CAExD,OAAO;EACH,MAAM;EACN,OAAO;EACP,MAAM,MAAM,KAAsC;GAC9C,MAAM,YAA2B,aAAa,KAAK,OAAO;GAE1D,IAAI,qBAEI,QACA,EAAE,yBACc;IAChB,MAAM,iBAAgC;KAClC,QAAQ,EACJ,OAAO,EACH,OAAO,cACX,EACJ;KACA,QAAQ;MACJ,QAAQ;MACR,UAAU,MAAM;MAChB,MAAM,KAAK;KACf;IACJ;IAGA,IAAI,MAAM,WAAW,cACjB,eAAe,SAAS;KACpB,GAAG,eAAe;KAClB,SAAS,CACL,GAAI,eAAe,QAAQ,WAAW,CAAC,GACvC,wBACJ;IACJ;IAGJ,OAAO,mBAAmB,QAAQ,cAAc;GACpD,CACJ;GAEA,IAAI,oBAEI,OACA,EAAE,aACK;IAEP,MACK,OAAO,aAAa,CAAC,CACrB,IAAI,OAAO,SAAS,uBAAuB,CACxC,EACI,WAAW,EACf,CACJ,CAAC;IAGL,MACK,OAAO,iBAAiB,CAAC,CACzB,IAAI,OAAO,YAAY,sBAAsB,CAC1C,GACK,gBAAgB,uBAAuB;KACpC,GAAG;KACH,aAAa;IACjB,CAAC,EACL,CACJ,CAAC;GACT,CACJ;GAEA,IAAI,oBACC,QAAQ,EAAE,kBAAwC;IAC/C,MAAM,WAAoB,YAAY,SAAS;IAE/C,MAAM,gBAAqC,CACvC,GAAG,gBACH,QACJ;IAEA,MAAM,iBAAuC;KACzC,SAAS;;AAEL,gBAAgB,CACZ,KAAK,SACL,KACJ,EACJ;KACA,QAAQ;KACR,MAAM;MACF,WAAW;MACX,YAAY;KAChB;KACA,cAAc;MACV,UAAU,MAAM;MAChB,aAAa;MACb,cAAc;KAClB;IACJ;IAIA,IAAI,MAAM,WAAW,YAAY;KAS7B,MAAM,eAAyB;MAP3B,GAAG,OAAO,KAAK,YAAY,gBAAgB,CAAC,CAAC;MAC7C,GAAG,OAAO,KAAK,YAAY,oBAAoB,CAAC,CAAC;MACjD,GAAG,OAAO,KACN,YAAY,wBAAwB,CAAC,CACzC;KAGkC,CAAC,CAAC,KACnC,SACG,IAAI,OACA,IAAI,KAAK,QAAQ,uBAAuB,OAAO,GAAG,KAAK,EAAE,UAC7D,CACR;KAEA,eAAe,YAAY,CACvB,GAAG,eACH,GAAG,YACP;KAEA,eAAe,gBAAgB,WACzB,kBACA;IACV;IAIA,IAAI,MAAM,WAAW,cACjB,eAAe,YAAY;IAK/B,IAAI,MAAM,WAAW,UACjB,eAAe,SAAS;KACpB,GAAG,eAAe;KAClB,UAAU,MAAM;KAChB,SAAS,KAAK;KACd,GAAI,WACE,EACI,QAAQ,KACZ,IACA,CAAC;IACX;IAKJ,IAAI,MAAM,WAAW,WACjB,eAAe,SAAS;KACpB,GAAG,eAAe;KAClB,UAAU,MAAM;KAChB,SAAS;MACL,MAAM,WAAW,WAAW;MAC5B,QAAQ;KACZ;KACA,GAAI,WACE,EACI,QAAQ,KACZ,IACA,CAAC;IACX;IAGJ,OAAO,YAAY,QAAQ,cAAc;GAC7C,CACJ;EACJ;CACJ;AACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { RsbuildPlugin } from "@rsbuild/core";
|
|
4
|
+
import { ResolvedOptions } from "@srvkit/common/@types/options/resolved";
|
|
5
|
+
declare const copyPlugin: (opts: ResolvedOptions) => RsbuildPlugin[];
|
|
6
|
+
export { copyPlugin };
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
10
|
+
|
|
11
|
+
const copyPlugin = (opts) => {
|
|
12
|
+
const build = opts.build;
|
|
13
|
+
if (build.target !== "server" || !build.copyPublicDir) return [];
|
|
14
|
+
return [{
|
|
15
|
+
name: "srvkit:copy",
|
|
16
|
+
apply: "build",
|
|
17
|
+
async setup(api) {
|
|
18
|
+
api.modifyRsbuildConfig((config) => {
|
|
19
|
+
return {
|
|
20
|
+
...config,
|
|
21
|
+
output: {
|
|
22
|
+
...config.output,
|
|
23
|
+
copy: [{
|
|
24
|
+
from: build.publicDir,
|
|
25
|
+
to: build.publicDir
|
|
26
|
+
}]
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}];
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.copyPlugin = copyPlugin;
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/plugins/copy/index.ts"],"sourcesContent":["import type {\n RsbuildConfig,\n RsbuildPlugin,\n RsbuildPluginAPI,\n} from \"@rsbuild/core\";\nimport type {\n ResolvedBuildOptions,\n ResolvedOptions,\n} from \"@srvkit/common/@types/options/resolved\";\n\nconst copyPlugin = (opts: ResolvedOptions): RsbuildPlugin[] => {\n const build: ResolvedBuildOptions = opts.build;\n\n if (build.target !== \"server\" || !build.copyPublicDir) {\n return [];\n }\n\n return [\n {\n name: \"srvkit:copy\",\n apply: \"build\",\n async setup(api: RsbuildPluginAPI): Promise<void> {\n api.modifyRsbuildConfig(\n (config: RsbuildConfig): RsbuildConfig => {\n return {\n ...config,\n output: {\n ...config.output,\n copy: [\n {\n from: build.publicDir,\n to: build.publicDir,\n },\n ],\n },\n };\n },\n );\n },\n },\n ];\n};\n\nexport { copyPlugin };\n"],"mappings":";;;;;;;;;;AAUA,MAAM,cAAc,SAA2C;CAC3D,MAAM,QAA8B,KAAK;CAEzC,IAAI,MAAM,WAAW,YAAY,CAAC,MAAM,eACpC,OAAO,CAAC;CAGZ,OAAO,CACH;EACI,MAAM;EACN,OAAO;EACP,MAAM,MAAM,KAAsC;GAC9C,IAAI,qBACC,WAAyC;IACtC,OAAO;KACH,GAAG;KACH,QAAQ;MACJ,GAAG,OAAO;MACV,MAAM,CACF;OACI,MAAM,MAAM;OACZ,IAAI,MAAM;MACd,CACJ;KACJ;IACJ;GACJ,CACJ;EACJ;CACJ,CACJ;AACJ"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
9
|
+
const copyPlugin = (opts) => {
|
|
10
|
+
const build = opts.build;
|
|
11
|
+
if (build.target !== "server" || !build.copyPublicDir) return [];
|
|
12
|
+
return [{
|
|
13
|
+
name: "srvkit:copy",
|
|
14
|
+
apply: "build",
|
|
15
|
+
async setup(api) {
|
|
16
|
+
api.modifyRsbuildConfig((config) => {
|
|
17
|
+
return {
|
|
18
|
+
...config,
|
|
19
|
+
output: {
|
|
20
|
+
...config.output,
|
|
21
|
+
copy: [{
|
|
22
|
+
from: build.publicDir,
|
|
23
|
+
to: build.publicDir
|
|
24
|
+
}]
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { copyPlugin };
|
|
33
|
+
//# sourceMappingURL=index.mjs.map
|