@nocobase/build 2.1.0-beta.30 → 2.1.0-beta.33
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/lib/buildPlugin.js +6 -37
- package/lib/deleteServerFiles.js +68 -0
- package/package.json +2 -2
package/lib/buildPlugin.js
CHANGED
|
@@ -32,7 +32,6 @@ __export(buildPlugin_exports, {
|
|
|
32
32
|
buildPluginServer: () => buildPluginServer,
|
|
33
33
|
buildProPluginServer: () => buildProPluginServer,
|
|
34
34
|
buildServerDeps: () => buildServerDeps,
|
|
35
|
-
deleteServerFiles: () => deleteServerFiles,
|
|
36
35
|
writeExternalPackageVersion: () => writeExternalPackageVersion
|
|
37
36
|
});
|
|
38
37
|
module.exports = __toCommonJS(buildPlugin_exports);
|
|
@@ -47,6 +46,7 @@ var import_path = __toESM(require("path"));
|
|
|
47
46
|
var import_tsup = require("tsup");
|
|
48
47
|
var import_constant = require("./constant");
|
|
49
48
|
var import_pluginEsbuildCommercialInject = __toESM(require("./plugins/pluginEsbuildCommercialInject"));
|
|
49
|
+
var import_deleteServerFiles = require("./deleteServerFiles");
|
|
50
50
|
var import_utils = require("./utils");
|
|
51
51
|
var import_buildPluginUtils = require("./utils/buildPluginUtils");
|
|
52
52
|
var import_getDepsConfig = require("./utils/getDepsConfig");
|
|
@@ -160,7 +160,6 @@ const external = [
|
|
|
160
160
|
"ahooks",
|
|
161
161
|
"lodash",
|
|
162
162
|
"china-division",
|
|
163
|
-
"file-saver",
|
|
164
163
|
// langChain
|
|
165
164
|
"langchain",
|
|
166
165
|
"@langchain/core",
|
|
@@ -249,36 +248,6 @@ async function copyAiDocSources(cwd, log) {
|
|
|
249
248
|
await import_fs_extra.default.writeJSON(rootMetaPath, Array.from(rootMetaMap.values()), { spaces: 2 });
|
|
250
249
|
}
|
|
251
250
|
}
|
|
252
|
-
function deleteServerFiles(cwd, log) {
|
|
253
|
-
log("delete server files");
|
|
254
|
-
const files = import_fast_glob.default.globSync(["*"], {
|
|
255
|
-
cwd: import_path.default.join(cwd, target_dir),
|
|
256
|
-
absolute: true,
|
|
257
|
-
deep: 1,
|
|
258
|
-
onlyFiles: true
|
|
259
|
-
});
|
|
260
|
-
const dirs = import_fast_glob.default.globSync(["*", "!client", "!node_modules"], {
|
|
261
|
-
cwd: import_path.default.join(cwd, target_dir),
|
|
262
|
-
absolute: true,
|
|
263
|
-
deep: 1,
|
|
264
|
-
onlyDirectories: true
|
|
265
|
-
});
|
|
266
|
-
const extraClientDirs = import_fast_glob.default.globSync(["client-v2"], {
|
|
267
|
-
cwd: import_path.default.join(cwd, target_dir),
|
|
268
|
-
absolute: true,
|
|
269
|
-
deep: 1,
|
|
270
|
-
onlyDirectories: true
|
|
271
|
-
});
|
|
272
|
-
[...files, ...dirs.filter((item) => !extraClientDirs.includes(item)), ...extraClientDirs].forEach((item) => {
|
|
273
|
-
if (item.endsWith(`${import_path.default.sep}client-v2`) || item.endsWith(`/client-v2`)) {
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
if (item.endsWith(`${import_path.default.sep}client`) || item.endsWith(`/client`)) {
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
import_fs_extra.default.removeSync(item);
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
251
|
function writeExternalPackageVersion(cwd, log) {
|
|
283
252
|
log("write external version");
|
|
284
253
|
const sourceFiles = import_fast_glob.default.globSync(sourceGlobalFiles, { cwd, absolute: true }).map((item) => import_fs_extra.default.readFileSync(item, "utf-8"));
|
|
@@ -380,7 +349,7 @@ async function buildPluginServer(cwd, userConfig, sourcemap, log) {
|
|
|
380
349
|
if (otherExts.length) {
|
|
381
350
|
log("%s will not be processed, only be copied to the dist directory.", import_chalk.default.yellow(otherExts.join(",")));
|
|
382
351
|
}
|
|
383
|
-
deleteServerFiles(cwd, log);
|
|
352
|
+
(0, import_deleteServerFiles.deleteServerFiles)(cwd, log);
|
|
384
353
|
await (0, import_tsup.build)(
|
|
385
354
|
userConfig.modifyTsupConfig({
|
|
386
355
|
entry: serverFiles,
|
|
@@ -415,7 +384,7 @@ async function buildProPluginServer(cwd, userConfig, sourcemap, log) {
|
|
|
415
384
|
if (otherExts.length) {
|
|
416
385
|
log("%s will not be processed, only be copied to the dist directory.", import_chalk.default.yellow(otherExts.join(",")));
|
|
417
386
|
}
|
|
418
|
-
deleteServerFiles(cwd, log);
|
|
387
|
+
(0, import_deleteServerFiles.deleteServerFiles)(cwd, log);
|
|
419
388
|
let tsconfig = bundleRequire.loadTsConfig(import_path.default.join(cwd, "tsconfig.json"));
|
|
420
389
|
import_fs_extra.default.writeFileSync(
|
|
421
390
|
import_path.default.join(cwd, "tsconfig.json"),
|
|
@@ -535,10 +504,11 @@ async function buildPluginClient(cwd, userConfig, sourcemap, log, lane = "client
|
|
|
535
504
|
}
|
|
536
505
|
const sourcePackages = (0, import_buildPluginUtils.getPluginBrowserSourcePackages)(sourceCwds, import_constant.globExcludeFiles);
|
|
537
506
|
const excludePackages = (0, import_buildPluginUtils.getExcludePackages)(sourcePackages, external, pluginPrefix);
|
|
507
|
+
const browserExternalPackages = excludePackages.filter((packageName) => packageName !== "file-saver");
|
|
538
508
|
(0, import_buildPluginUtils.checkRequire)(clientFiles, log);
|
|
539
509
|
(0, import_buildPluginUtils.buildCheck)({ cwd, packageJson, entry: lane, files: clientFiles, log });
|
|
540
510
|
const outDir = import_path.default.join(cwd, target_dir, laneConfig.distDir);
|
|
541
|
-
const globals =
|
|
511
|
+
const globals = browserExternalPackages.reduce((prev, curr) => {
|
|
542
512
|
if (curr.startsWith("@nocobase")) {
|
|
543
513
|
laneConfig.externalSubpaths.forEach((subpath) => {
|
|
544
514
|
prev[`${curr}/${subpath}`] = `${curr}/${subpath}`;
|
|
@@ -562,7 +532,7 @@ async function buildPluginClient(cwd, userConfig, sourcemap, log, lane = "client
|
|
|
562
532
|
// will be generated by the custom plugin
|
|
563
533
|
clean: true,
|
|
564
534
|
library: {
|
|
565
|
-
name: packageJson.name,
|
|
535
|
+
name: lane === "client-v2" ? `${packageJson.name}/client-v2` : packageJson.name,
|
|
566
536
|
type: "umd",
|
|
567
537
|
umdNamedDefine: true
|
|
568
538
|
}
|
|
@@ -767,6 +737,5 @@ async function buildPlugin(cwd, userConfig, sourcemap, log) {
|
|
|
767
737
|
buildPluginServer,
|
|
768
738
|
buildProPluginServer,
|
|
769
739
|
buildServerDeps,
|
|
770
|
-
deleteServerFiles,
|
|
771
740
|
writeExternalPackageVersion
|
|
772
741
|
});
|
|
@@ -0,0 +1,68 @@
|
|
|
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 __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var deleteServerFiles_exports = {};
|
|
29
|
+
__export(deleteServerFiles_exports, {
|
|
30
|
+
deleteServerFiles: () => deleteServerFiles,
|
|
31
|
+
shouldPreserveDistEntry: () => shouldPreserveDistEntry
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(deleteServerFiles_exports);
|
|
34
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
35
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
36
|
+
var import_path = __toESM(require("path"));
|
|
37
|
+
const targetDir = "dist";
|
|
38
|
+
const preservedDistEntries = /* @__PURE__ */ new Set(["client", "client-v2"]);
|
|
39
|
+
function shouldPreserveDistEntry(item) {
|
|
40
|
+
return preservedDistEntries.has(import_path.default.win32.basename(item));
|
|
41
|
+
}
|
|
42
|
+
function deleteServerFiles(cwd, log) {
|
|
43
|
+
log("delete server files");
|
|
44
|
+
const distDir = import_path.default.join(cwd, targetDir);
|
|
45
|
+
const files = import_fast_glob.default.globSync(["*"], {
|
|
46
|
+
cwd: distDir,
|
|
47
|
+
absolute: true,
|
|
48
|
+
deep: 1,
|
|
49
|
+
onlyFiles: true
|
|
50
|
+
});
|
|
51
|
+
const dirs = import_fast_glob.default.globSync(["*", "!node_modules"], {
|
|
52
|
+
cwd: distDir,
|
|
53
|
+
absolute: true,
|
|
54
|
+
deep: 1,
|
|
55
|
+
onlyDirectories: true
|
|
56
|
+
});
|
|
57
|
+
[...files, ...dirs].forEach((item) => {
|
|
58
|
+
if (shouldPreserveDistEntry(item)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
import_fs_extra.default.removeSync(item);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
deleteServerFiles,
|
|
67
|
+
shouldPreserveDistEntry
|
|
68
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/build",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.33",
|
|
4
4
|
"description": "Library build tool based on rollup.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"build": "tsup",
|
|
54
54
|
"build:watch": "tsup --watch"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "4815c394e80a264fa8ed619246280923c47aeb72"
|
|
57
57
|
}
|