@nocobase/build 1.2.12-alpha → 1.3.0-alpha.20240710084543
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/package.json +2 -2
- package/lib/build.js +0 -151
- package/lib/buildCjs.js +0 -68
- package/lib/buildClient.js +0 -145
- package/lib/buildDeclaration.js +0 -62
- package/lib/buildEsm.js +0 -98
- package/lib/buildPlugin.js +0 -344
- package/lib/constant.js +0 -109
- package/lib/index.d.ts +0 -23
- package/lib/index.js +0 -23
- package/lib/tarPlugin.js +0 -58
- package/lib/utils/addlicense.js +0 -73
- package/lib/utils/buildPluginUtils.js +0 -171
- package/lib/utils/getDepsConfig.js +0 -108
- package/lib/utils/getPackages.js +0 -80
- package/lib/utils/index.js +0 -21
- package/lib/utils/utils.js +0 -134
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/build",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-alpha.20240710084543",
|
|
4
4
|
"description": "Library build tool based on rollup.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsup"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "07a8b596fc64a9779a194cb9b0dc2ca7570ed9d4"
|
|
40
40
|
}
|
package/lib/build.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
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 build_exports = {};
|
|
29
|
-
__export(build_exports, {
|
|
30
|
-
build: () => build,
|
|
31
|
-
buildPackage: () => buildPackage,
|
|
32
|
-
buildPackages: () => buildPackages
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(build_exports);
|
|
35
|
-
var import_execa = __toESM(require("execa"));
|
|
36
|
-
var import_chalk = __toESM(require("chalk"));
|
|
37
|
-
var import_path = __toESM(require("path"));
|
|
38
|
-
var import_constant = require("./constant");
|
|
39
|
-
var import_buildClient = require("./buildClient");
|
|
40
|
-
var import_buildCjs = require("./buildCjs");
|
|
41
|
-
var import_buildPlugin = require("./buildPlugin");
|
|
42
|
-
var import_buildDeclaration = require("./buildDeclaration");
|
|
43
|
-
var import_utils = require("./utils");
|
|
44
|
-
var import_getPackages = require("./utils/getPackages");
|
|
45
|
-
var import_tarPlugin = require("./tarPlugin");
|
|
46
|
-
var import_buildEsm = require("./buildEsm");
|
|
47
|
-
var import_addlicense = require("./utils/addlicense");
|
|
48
|
-
const BUILD_ERROR = "build-error";
|
|
49
|
-
async function build(pkgs) {
|
|
50
|
-
const isDev = process.argv.includes("--development");
|
|
51
|
-
process.env.NODE_ENV = isDev ? "development" : "production";
|
|
52
|
-
let packages = (0, import_getPackages.getPackages)(pkgs);
|
|
53
|
-
const cachePkg = (0, import_utils.readFromCache)(BUILD_ERROR);
|
|
54
|
-
if (process.argv.includes("--retry") && cachePkg?.pkg) {
|
|
55
|
-
packages = packages.slice(packages.findIndex((item) => item.name === cachePkg.pkg));
|
|
56
|
-
}
|
|
57
|
-
if (packages.length === 0) {
|
|
58
|
-
let msg = "";
|
|
59
|
-
if (pkgs.length) {
|
|
60
|
-
msg = `'${pkgs.join(", ")}' did not match any packages`;
|
|
61
|
-
} else {
|
|
62
|
-
msg = "No package matched";
|
|
63
|
-
}
|
|
64
|
-
console.warn(import_chalk.default.yellow(`[@nocobase/build]: ${msg}`));
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const pluginPackages = (0, import_constant.getPluginPackages)(packages);
|
|
68
|
-
const cjsPackages = (0, import_constant.getCjsPackages)(packages);
|
|
69
|
-
const presetsPackages = (0, import_constant.getPresetsPackages)(packages);
|
|
70
|
-
await buildPackages(cjsPackages, "lib", import_buildCjs.buildCjs);
|
|
71
|
-
const clientCore = packages.find((item) => item.location === import_constant.CORE_CLIENT);
|
|
72
|
-
if (clientCore) {
|
|
73
|
-
await buildPackage(clientCore, "es", import_buildClient.buildClient);
|
|
74
|
-
}
|
|
75
|
-
const esmPackages = packages.filter((pkg) => import_constant.ESM_PACKAGES.includes(pkg.name));
|
|
76
|
-
await buildPackages(esmPackages, "lib", import_buildCjs.buildCjs);
|
|
77
|
-
await buildPackages(esmPackages, "es", import_buildEsm.buildEsm);
|
|
78
|
-
await buildPackages(pluginPackages, "dist", import_buildPlugin.buildPlugin);
|
|
79
|
-
await buildPackages(presetsPackages, "lib", import_buildCjs.buildCjs);
|
|
80
|
-
const appClient = packages.find((item) => item.location === import_constant.CORE_APP);
|
|
81
|
-
if (appClient) {
|
|
82
|
-
await runScript(["umi", "build"], import_constant.ROOT_PATH, {
|
|
83
|
-
APP_ROOT: import_path.default.join(import_constant.CORE_APP, "client")
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
(0, import_utils.writeToCache)(BUILD_ERROR, {});
|
|
87
|
-
}
|
|
88
|
-
async function buildPackages(packages, targetDir, doBuildPackage) {
|
|
89
|
-
for await (const pkg of packages) {
|
|
90
|
-
(0, import_utils.writeToCache)(BUILD_ERROR, { pkg: pkg.name });
|
|
91
|
-
await buildPackage(pkg, targetDir, doBuildPackage);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
async function buildPackage(pkg, targetDir, doBuildPackage) {
|
|
95
|
-
const sourcemap = process.argv.includes("--sourcemap");
|
|
96
|
-
const noDeclaration = process.argv.includes("--no-dts");
|
|
97
|
-
const hasTar = process.argv.includes("--tar");
|
|
98
|
-
const onlyTar = process.argv.includes("--only-tar");
|
|
99
|
-
const log = (0, import_utils.getPkgLog)(pkg.name);
|
|
100
|
-
const packageJson = (0, import_utils.getPackageJson)(pkg.location);
|
|
101
|
-
if (onlyTar) {
|
|
102
|
-
await (0, import_tarPlugin.tarPlugin)(pkg.location, log);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
log(`${import_chalk.default.bold((0, import_utils.toUnixPath)(pkg.location.replace(import_constant.PACKAGES_PATH, "").slice(1)))} build start`);
|
|
106
|
-
const userConfig = (0, import_utils.getUserConfig)(pkg.location);
|
|
107
|
-
if (packageJson?.scripts?.prebuild) {
|
|
108
|
-
log("prebuild");
|
|
109
|
-
await runScript(["prebuild"], pkg.location);
|
|
110
|
-
await packageJson.prebuild(pkg.location);
|
|
111
|
-
}
|
|
112
|
-
if (userConfig.beforeBuild) {
|
|
113
|
-
log("beforeBuild");
|
|
114
|
-
await userConfig.beforeBuild(log);
|
|
115
|
-
}
|
|
116
|
-
await doBuildPackage(pkg.location, userConfig, sourcemap, log);
|
|
117
|
-
if (!noDeclaration) {
|
|
118
|
-
log("build declaration");
|
|
119
|
-
await (0, import_buildDeclaration.buildDeclaration)(pkg.location, targetDir);
|
|
120
|
-
}
|
|
121
|
-
if (packageJson?.scripts?.postbuild) {
|
|
122
|
-
log("postbuild");
|
|
123
|
-
await runScript(["postbuild"], pkg.location);
|
|
124
|
-
}
|
|
125
|
-
if (userConfig.afterBuild) {
|
|
126
|
-
log("afterBuild");
|
|
127
|
-
await userConfig.afterBuild(log);
|
|
128
|
-
}
|
|
129
|
-
await (0, import_addlicense.addLicense)(import_path.default.join(pkg.location, targetDir), log);
|
|
130
|
-
if (hasTar) {
|
|
131
|
-
await (0, import_tarPlugin.tarPlugin)(pkg.location, log);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
function runScript(args, cwd, envs = {}) {
|
|
135
|
-
return (0, import_execa.default)("yarn", args, {
|
|
136
|
-
cwd,
|
|
137
|
-
stdio: "inherit",
|
|
138
|
-
env: {
|
|
139
|
-
...process.env,
|
|
140
|
-
...envs,
|
|
141
|
-
sourcemap: process.argv.includes("--sourcemap") ? "sourcemap" : void 0,
|
|
142
|
-
NODE_ENV: process.env.NODE_ENV || "production"
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
147
|
-
0 && (module.exports = {
|
|
148
|
-
build,
|
|
149
|
-
buildPackage,
|
|
150
|
-
buildPackages
|
|
151
|
-
});
|
package/lib/buildCjs.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
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 buildCjs_exports = {};
|
|
29
|
-
__export(buildCjs_exports, {
|
|
30
|
-
buildCjs: () => buildCjs
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(buildCjs_exports);
|
|
33
|
-
var import_tsup = require("tsup");
|
|
34
|
-
var import_fast_glob = __toESM(require("fast-glob"));
|
|
35
|
-
var import_path = __toESM(require("path"));
|
|
36
|
-
var import_chalk = __toESM(require("chalk"));
|
|
37
|
-
var import_constant = require("./constant");
|
|
38
|
-
function buildCjs(cwd, userConfig, sourcemap = false, log) {
|
|
39
|
-
log("build cjs");
|
|
40
|
-
const entry = import_fast_glob.default.globSync(["src/**", ...import_constant.globExcludeFiles], { cwd, absolute: true });
|
|
41
|
-
const outDir = import_path.default.join(cwd, "lib");
|
|
42
|
-
const otherExts = Array.from(new Set(entry.map((item) => import_path.default.extname(item)).filter((item) => !import_constant.EsbuildSupportExts.includes(item))));
|
|
43
|
-
if (otherExts.length) {
|
|
44
|
-
log("%s will not be processed, only be copied to the lib directory.", import_chalk.default.yellow(otherExts.join(",")));
|
|
45
|
-
}
|
|
46
|
-
return (0, import_tsup.build)(userConfig.modifyTsupConfig({
|
|
47
|
-
entry,
|
|
48
|
-
splitting: false,
|
|
49
|
-
clean: true,
|
|
50
|
-
bundle: false,
|
|
51
|
-
silent: true,
|
|
52
|
-
sourcemap,
|
|
53
|
-
treeshake: false,
|
|
54
|
-
target: "node16",
|
|
55
|
-
keepNames: true,
|
|
56
|
-
outDir,
|
|
57
|
-
loader: {
|
|
58
|
-
...otherExts.reduce((prev, cur) => ({ ...prev, [cur]: "copy" }), {}),
|
|
59
|
-
".json": "copy"
|
|
60
|
-
},
|
|
61
|
-
format: "cjs",
|
|
62
|
-
skipNodeModulesBundle: true
|
|
63
|
-
}));
|
|
64
|
-
}
|
|
65
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
-
0 && (module.exports = {
|
|
67
|
-
buildCjs
|
|
68
|
-
});
|
package/lib/buildClient.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
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 buildClient_exports = {};
|
|
29
|
-
__export(buildClient_exports, {
|
|
30
|
-
buildClient: () => buildClient,
|
|
31
|
-
buildLocale: () => buildLocale
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(buildClient_exports);
|
|
34
|
-
var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
|
|
35
|
-
var import_fast_glob = __toESM(require("fast-glob"));
|
|
36
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
|
-
var import_path = __toESM(require("path"));
|
|
38
|
-
var import_tsup = require("tsup");
|
|
39
|
-
var import_vite = require("vite");
|
|
40
|
-
var import_vite_plugin_lib_inject_css = require("vite-plugin-lib-inject-css");
|
|
41
|
-
var import_constant = require("./constant");
|
|
42
|
-
var import_utils = require("./utils");
|
|
43
|
-
async function buildClient(cwd, userConfig, sourcemap = false, log) {
|
|
44
|
-
log("build client");
|
|
45
|
-
const cwdWin = cwd.replaceAll(/\\/g, "/");
|
|
46
|
-
const cwdUnix = cwd.replaceAll(/\//g, "\\");
|
|
47
|
-
const external = function(id) {
|
|
48
|
-
if (id.startsWith(".") || id.startsWith(cwdUnix) || id.startsWith(cwdWin)) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
52
|
-
};
|
|
53
|
-
await buildClientEsm(cwd, userConfig, sourcemap, external, log);
|
|
54
|
-
await buildClientLib(cwd, userConfig, sourcemap, external, log);
|
|
55
|
-
await buildLocale(cwd, userConfig, log);
|
|
56
|
-
}
|
|
57
|
-
function buildClientEsm(cwd, userConfig, sourcemap, external, log) {
|
|
58
|
-
log("build client esm");
|
|
59
|
-
const entry = import_path.default.join(cwd, "src/index.ts").replaceAll(/\\/g, "/");
|
|
60
|
-
const outDir = import_path.default.resolve(cwd, "es");
|
|
61
|
-
return (0, import_vite.build)(
|
|
62
|
-
userConfig.modifyViteConfig({
|
|
63
|
-
mode: process.env.NODE_ENV || "production",
|
|
64
|
-
define: (0, import_utils.getEnvDefine)(),
|
|
65
|
-
build: {
|
|
66
|
-
minify: process.env.NODE_ENV === "production",
|
|
67
|
-
outDir,
|
|
68
|
-
cssCodeSplit: true,
|
|
69
|
-
emptyOutDir: true,
|
|
70
|
-
sourcemap,
|
|
71
|
-
lib: {
|
|
72
|
-
entry,
|
|
73
|
-
formats: ["es"],
|
|
74
|
-
fileName: "index"
|
|
75
|
-
},
|
|
76
|
-
target: ["es2015", "edge88", "firefox78", "chrome87", "safari14"],
|
|
77
|
-
rollupOptions: {
|
|
78
|
-
cache: true,
|
|
79
|
-
treeshake: true,
|
|
80
|
-
external
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
plugins: [(0, import_plugin_react.default)(), (0, import_vite_plugin_lib_inject_css.libInjectCss)()]
|
|
84
|
-
})
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
async function buildClientLib(cwd, userConfig, sourcemap, external, log) {
|
|
88
|
-
log("build client lib");
|
|
89
|
-
const outDir = import_path.default.resolve(cwd, "lib");
|
|
90
|
-
const esDir = import_path.default.resolve(cwd, "es");
|
|
91
|
-
const entry = import_path.default.join(esDir, "index.ts");
|
|
92
|
-
import_fs_extra.default.removeSync(entry);
|
|
93
|
-
import_fs_extra.default.linkSync(import_path.default.join(cwd, "es/index.mjs"), entry);
|
|
94
|
-
await (0, import_vite.build)(
|
|
95
|
-
userConfig.modifyViteConfig({
|
|
96
|
-
mode: process.env.NODE_ENV || "production",
|
|
97
|
-
esbuild: {
|
|
98
|
-
format: "cjs"
|
|
99
|
-
},
|
|
100
|
-
build: {
|
|
101
|
-
outDir,
|
|
102
|
-
minify: process.env.NODE_ENV === "production",
|
|
103
|
-
sourcemap,
|
|
104
|
-
lib: {
|
|
105
|
-
entry: import_path.default.join(cwd, "es/index.ts"),
|
|
106
|
-
formats: ["cjs"],
|
|
107
|
-
fileName: "index"
|
|
108
|
-
},
|
|
109
|
-
rollupOptions: {
|
|
110
|
-
external
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
);
|
|
115
|
-
import_fs_extra.default.removeSync(entry);
|
|
116
|
-
const css = import_fast_glob.default.sync("*.css", { cwd: esDir, absolute: true });
|
|
117
|
-
css.forEach((file) => {
|
|
118
|
-
import_fs_extra.default.copySync(file, import_path.default.join(outDir, import_path.default.basename(file)));
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
function buildLocale(cwd, userConfig, log) {
|
|
122
|
-
log("build client locale");
|
|
123
|
-
const entry = import_fast_glob.default.globSync(["src/locale/**", ...import_constant.globExcludeFiles], { cwd, absolute: true });
|
|
124
|
-
const outDir = import_path.default.resolve(cwd, "lib", "locale");
|
|
125
|
-
return (0, import_tsup.build)(
|
|
126
|
-
userConfig.modifyTsupConfig({
|
|
127
|
-
entry,
|
|
128
|
-
splitting: false,
|
|
129
|
-
clean: false,
|
|
130
|
-
bundle: false,
|
|
131
|
-
silent: true,
|
|
132
|
-
treeshake: false,
|
|
133
|
-
target: "node16",
|
|
134
|
-
keepNames: true,
|
|
135
|
-
outDir,
|
|
136
|
-
format: "cjs",
|
|
137
|
-
skipNodeModulesBundle: true
|
|
138
|
-
})
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
142
|
-
0 && (module.exports = {
|
|
143
|
-
buildClient,
|
|
144
|
-
buildLocale
|
|
145
|
-
});
|
package/lib/buildDeclaration.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
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 buildDeclaration_exports = {};
|
|
29
|
-
__export(buildDeclaration_exports, {
|
|
30
|
-
buildDeclaration: () => buildDeclaration
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(buildDeclaration_exports);
|
|
33
|
-
var import_gulp = __toESM(require("gulp"));
|
|
34
|
-
var import_gulp_typescript = __toESM(require("gulp-typescript"));
|
|
35
|
-
var import_path = __toESM(require("path"));
|
|
36
|
-
var import_constant = require("./constant");
|
|
37
|
-
const buildDeclaration = (cwd, targetDir) => {
|
|
38
|
-
return new Promise((resolve, reject) => {
|
|
39
|
-
const srcPath = import_path.default.join(cwd, "src");
|
|
40
|
-
const targetPath = import_path.default.join(cwd, targetDir);
|
|
41
|
-
const tsConfig = import_gulp_typescript.default.createProject(import_path.default.join(import_constant.ROOT_PATH, "tsconfig.json"));
|
|
42
|
-
delete tsConfig.config.compilerOptions.paths;
|
|
43
|
-
const patterns = [
|
|
44
|
-
import_path.default.join(srcPath, "**/*.{ts,tsx}"),
|
|
45
|
-
`!${import_path.default.join(srcPath, "**/fixtures{,/**}")}`,
|
|
46
|
-
`!${import_path.default.join(srcPath, "**/demos{,/**}")}`,
|
|
47
|
-
`!${import_path.default.join(srcPath, "**/__test__{,/**}")}`,
|
|
48
|
-
`!${import_path.default.join(srcPath, "**/__tests__{,/**}")}`,
|
|
49
|
-
`!${import_path.default.join(srcPath, "**/__e2e__{,/**}")}`,
|
|
50
|
-
`!${import_path.default.join(srcPath, "**/*.mdx")}`,
|
|
51
|
-
`!${import_path.default.join(srcPath, "**/*.md")}`,
|
|
52
|
-
`!${import_path.default.join(srcPath, "**/*.+(test|e2e|spec).+(js|jsx|ts|tsx)")}`,
|
|
53
|
-
`!${import_path.default.join(srcPath, "**/tsconfig{,.*}.json")}`,
|
|
54
|
-
`!${import_path.default.join(srcPath, ".umi{,-production,-test}{,/**}")}`
|
|
55
|
-
];
|
|
56
|
-
import_gulp.default.src(patterns, { base: srcPath, allowEmpty: true }).pipe((0, import_gulp_typescript.default)(tsConfig.config.compilerOptions)).dts.pipe(import_gulp.default.dest(targetPath)).on("end", resolve).on("error", reject);
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
-
0 && (module.exports = {
|
|
61
|
-
buildDeclaration
|
|
62
|
-
});
|
package/lib/buildEsm.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
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 buildEsm_exports = {};
|
|
29
|
-
__export(buildEsm_exports, {
|
|
30
|
-
buildEsm: () => buildEsm
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(buildEsm_exports);
|
|
33
|
-
var import_path = __toESM(require("path"));
|
|
34
|
-
var import_utils = require("./utils");
|
|
35
|
-
var import_vite = require("vite");
|
|
36
|
-
var import_fast_glob = __toESM(require("fast-glob"));
|
|
37
|
-
const clientExt = ".{ts,tsx,js,jsx}";
|
|
38
|
-
function getSingleEntry(file, cwd) {
|
|
39
|
-
return import_fast_glob.default.sync([`${file}${clientExt}`], { cwd, absolute: true, onlyFiles: true })?.[0]?.replaceAll(/\\/g, "/");
|
|
40
|
-
}
|
|
41
|
-
async function buildEsm(cwd, userConfig, sourcemap = false, log) {
|
|
42
|
-
log("build esm");
|
|
43
|
-
const indexEntry = getSingleEntry("src/index", cwd);
|
|
44
|
-
const outDir = import_path.default.resolve(cwd, "es");
|
|
45
|
-
await build(cwd, indexEntry, outDir, userConfig, sourcemap, log);
|
|
46
|
-
const clientEntry = getSingleEntry("src/client/index", cwd) || getSingleEntry("src/client", cwd);
|
|
47
|
-
const clientOutDir = import_path.default.resolve(cwd, "es/client");
|
|
48
|
-
if (clientEntry) {
|
|
49
|
-
await build(cwd, clientEntry, clientOutDir, userConfig, sourcemap, log);
|
|
50
|
-
}
|
|
51
|
-
const pkg = require(import_path.default.join(cwd, "package.json"));
|
|
52
|
-
if (pkg.name === "@nocobase/test") {
|
|
53
|
-
const e2eEntry = getSingleEntry("src/e2e/index", cwd);
|
|
54
|
-
const e2eOutDir = import_path.default.resolve(cwd, "es/e2e");
|
|
55
|
-
await build(cwd, e2eEntry, e2eOutDir, userConfig, sourcemap, log);
|
|
56
|
-
const webEntry = getSingleEntry("src/web/index", cwd);
|
|
57
|
-
const webOutDir = import_path.default.resolve(cwd, "es/web");
|
|
58
|
-
await build(cwd, webEntry, webOutDir, userConfig, sourcemap, log);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function build(cwd, entry, outDir, userConfig, sourcemap = false, log) {
|
|
62
|
-
const cwdWin = cwd.replaceAll(/\\/g, "/");
|
|
63
|
-
const cwdUnix = cwd.replaceAll(/\//g, "\\");
|
|
64
|
-
const external = function(id) {
|
|
65
|
-
if (id.startsWith(".") || id.startsWith(cwdUnix) || id.startsWith(cwdWin)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
return true;
|
|
69
|
-
};
|
|
70
|
-
return (0, import_vite.build)(
|
|
71
|
-
userConfig.modifyViteConfig({
|
|
72
|
-
mode: process.env.NODE_ENV || "production",
|
|
73
|
-
define: (0, import_utils.getEnvDefine)(),
|
|
74
|
-
build: {
|
|
75
|
-
minify: false,
|
|
76
|
-
outDir,
|
|
77
|
-
cssCodeSplit: true,
|
|
78
|
-
emptyOutDir: true,
|
|
79
|
-
sourcemap,
|
|
80
|
-
lib: {
|
|
81
|
-
entry,
|
|
82
|
-
formats: ["es"],
|
|
83
|
-
fileName: "index"
|
|
84
|
-
},
|
|
85
|
-
target: ["node16"],
|
|
86
|
-
rollupOptions: {
|
|
87
|
-
cache: true,
|
|
88
|
-
treeshake: true,
|
|
89
|
-
external
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
-
0 && (module.exports = {
|
|
97
|
-
buildEsm
|
|
98
|
-
});
|