@nocobase/build 2.0.22 → 2.1.0-alpha.10
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 +2 -21
- package/lib/constant.js +6 -2
- package/lib/injectPublicPathPlugin.js +68 -0
- package/package.json +3 -3
package/lib/buildPlugin.js
CHANGED
|
@@ -51,6 +51,7 @@ var import_utils = require("./utils");
|
|
|
51
51
|
var import_buildPluginUtils = require("./utils/buildPluginUtils");
|
|
52
52
|
var import_getDepsConfig = require("./utils/getDepsConfig");
|
|
53
53
|
var import_obfuscationResult = require("./utils/obfuscationResult");
|
|
54
|
+
var import_injectPublicPathPlugin = require("./injectPublicPathPlugin");
|
|
54
55
|
const validExts = [".ts", ".tsx", ".js", ".jsx", ".mjs"];
|
|
55
56
|
const serverGlobalFiles = ["src/**", "!src/client/**", ...import_constant.globExcludeFiles];
|
|
56
57
|
const clientGlobalFiles = ["src/**", "!src/server/**", ...import_constant.globExcludeFiles];
|
|
@@ -672,27 +673,7 @@ async function buildPluginClient(cwd, userConfig, sourcemap, log, isCommercial =
|
|
|
672
673
|
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
673
674
|
"process.env.NODE_DEBUG": false
|
|
674
675
|
}),
|
|
675
|
-
|
|
676
|
-
apply(compiler2) {
|
|
677
|
-
compiler2.hooks.compilation.tap("CustomPublicPathPlugin", (compilation) => {
|
|
678
|
-
compilation.hooks.runtimeModule.tap("CustomPublicPathPlugin", (module2) => {
|
|
679
|
-
if (module2.name === "auto_public_path") {
|
|
680
|
-
module2.source = {
|
|
681
|
-
source: `
|
|
682
|
-
__webpack_require__.p = (function() {
|
|
683
|
-
var publicPath = window['__webpack_public_path__'] || '/';
|
|
684
|
-
// \u786E\u4FDD\u8DEF\u5F84\u4EE5 / \u7ED3\u5C3E
|
|
685
|
-
if (!publicPath.endsWith('/')) {
|
|
686
|
-
publicPath += '/';
|
|
687
|
-
}
|
|
688
|
-
return publicPath + 'static/plugins/${packageJson.name}/dist/client/';
|
|
689
|
-
})();`
|
|
690
|
-
};
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
},
|
|
676
|
+
new import_injectPublicPathPlugin.AutoInjectPublicPathPlugin(packageJson.name),
|
|
696
677
|
process.env.BUILD_ANALYZE === "true" && new import_rspack_plugin.RsdoctorRspackPlugin({
|
|
697
678
|
// plugin options
|
|
698
679
|
// supports: {
|
package/lib/constant.js
CHANGED
|
@@ -30,6 +30,7 @@ __export(constant_exports, {
|
|
|
30
30
|
CJS_EXCLUDE_PACKAGES: () => CJS_EXCLUDE_PACKAGES,
|
|
31
31
|
CORE_APP: () => CORE_APP,
|
|
32
32
|
CORE_CLIENT: () => CORE_CLIENT,
|
|
33
|
+
CORE_CLIENT_V2: () => CORE_CLIENT_V2,
|
|
33
34
|
ESM_PACKAGES: () => ESM_PACKAGES,
|
|
34
35
|
EsbuildSupportExts: () => EsbuildSupportExts,
|
|
35
36
|
NODE_MODULES: () => NODE_MODULES,
|
|
@@ -90,11 +91,13 @@ const getPluginPackages = (packages) => packages.filter((item) => PLUGINS_DIR.so
|
|
|
90
91
|
const getPresetsPackages = (packages) => packages.filter((item) => item.location.startsWith(PRESETS_DIR));
|
|
91
92
|
const CORE_APP = import_path.default.join(PACKAGES_PATH, "core/app");
|
|
92
93
|
const CORE_CLIENT = import_path.default.join(PACKAGES_PATH, "core/client");
|
|
93
|
-
const
|
|
94
|
+
const CORE_CLIENT_V2 = import_path.default.join(PACKAGES_PATH, "core/client-v2");
|
|
95
|
+
const ESM_PACKAGES = ["@nocobase/client-v2", "@nocobase/test"];
|
|
94
96
|
const CJS_EXCLUDE_PACKAGES = [
|
|
95
97
|
import_path.default.join(PACKAGES_PATH, "core/build"),
|
|
96
98
|
import_path.default.join(PACKAGES_PATH, "core/cli"),
|
|
97
|
-
CORE_CLIENT
|
|
99
|
+
CORE_CLIENT,
|
|
100
|
+
CORE_CLIENT_V2
|
|
98
101
|
];
|
|
99
102
|
const getCjsPackages = (packages) => packages.filter((item) => !PLUGINS_DIR.some((dir) => item.location.startsWith(dir))).filter((item) => !item.location.startsWith(PRESETS_DIR)).filter((item) => !ESM_PACKAGES.includes(item.name)).filter((item) => !CJS_EXCLUDE_PACKAGES.includes(item.location));
|
|
100
103
|
const tarIncludesFiles = ["package.json", "README.md", "LICENSE", "dist", "!node_modules"];
|
|
@@ -104,6 +107,7 @@ const TAR_OUTPUT_DIR = process.env.TAR_PATH ? process.env.TAR_PATH : import_path
|
|
|
104
107
|
CJS_EXCLUDE_PACKAGES,
|
|
105
108
|
CORE_APP,
|
|
106
109
|
CORE_CLIENT,
|
|
110
|
+
CORE_CLIENT_V2,
|
|
107
111
|
ESM_PACKAGES,
|
|
108
112
|
EsbuildSupportExts,
|
|
109
113
|
NODE_MODULES,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var injectPublicPathPlugin_exports = {};
|
|
19
|
+
__export(injectPublicPathPlugin_exports, {
|
|
20
|
+
AutoInjectPublicPathPlugin: () => AutoInjectPublicPathPlugin
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(injectPublicPathPlugin_exports);
|
|
23
|
+
function createPluginClientPublicPathDataUri(packageName) {
|
|
24
|
+
const code = `
|
|
25
|
+
var publicPath = window['__webpack_public_path__'] || '/';
|
|
26
|
+
if (publicPath.charAt(publicPath.length - 1) !== '/') {
|
|
27
|
+
publicPath += '/';
|
|
28
|
+
}
|
|
29
|
+
__webpack_public_path__ = publicPath + 'static/plugins/${packageName}/dist/client/';
|
|
30
|
+
`;
|
|
31
|
+
return `data:text/javascript,${encodeURIComponent(code)}`;
|
|
32
|
+
}
|
|
33
|
+
function prependPluginClientPublicPathEntry(entry, packageName) {
|
|
34
|
+
const dataUri = createPluginClientPublicPathDataUri(packageName);
|
|
35
|
+
if (typeof entry === "string") {
|
|
36
|
+
return [dataUri, entry];
|
|
37
|
+
}
|
|
38
|
+
if (Array.isArray(entry)) {
|
|
39
|
+
return [dataUri, ...entry];
|
|
40
|
+
}
|
|
41
|
+
if (!entry || typeof entry !== "object") {
|
|
42
|
+
return entry;
|
|
43
|
+
}
|
|
44
|
+
const entryConfig = entry;
|
|
45
|
+
if (entryConfig.import) {
|
|
46
|
+
return {
|
|
47
|
+
...entryConfig,
|
|
48
|
+
import: Array.isArray(entryConfig.import) ? [dataUri, ...entryConfig.import] : [dataUri, entryConfig.import]
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return Object.fromEntries(
|
|
52
|
+
Object.entries(entryConfig).map(([name, value]) => [name, prependPluginClientPublicPathEntry(value, packageName)])
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
class AutoInjectPublicPathPlugin {
|
|
56
|
+
constructor(pluginName) {
|
|
57
|
+
this.pluginName = pluginName;
|
|
58
|
+
}
|
|
59
|
+
apply(compiler) {
|
|
60
|
+
compiler.hooks.environment.tap("AutoInjectPublicPathPlugin", () => {
|
|
61
|
+
compiler.options.entry = prependPluginClientPublicPathEntry(compiler.options.entry, this.pluginName);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
+
0 && (module.exports = {
|
|
67
|
+
AutoInjectPublicPathPlugin
|
|
68
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/build",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.1.0-alpha.10",
|
|
4
4
|
"description": "Library build tool based on rollup.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@lerna/project": "4.0.0",
|
|
18
18
|
"@rsbuild/plugin-babel": "^1.0.3",
|
|
19
19
|
"@rsdoctor/rspack-plugin": "^0.4.8",
|
|
20
|
-
"@rspack/core": "1.
|
|
20
|
+
"@rspack/core": "1.7.8",
|
|
21
21
|
"@svgr/webpack": "^8.1.0",
|
|
22
22
|
"@types/lerna__package": "5.1.0",
|
|
23
23
|
"@types/lerna__project": "5.1.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"build": "tsup",
|
|
52
52
|
"build:watch": "tsup --watch"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "ce790d46c0a5768ca9618c7d0d77ab8300de75c8"
|
|
55
55
|
}
|