@nocobase/build 1.5.0-beta.2 → 1.5.0-beta.4

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/build.js CHANGED
@@ -80,7 +80,8 @@ async function build(pkgs) {
80
80
  const appClient = packages.find((item) => item.location === import_constant.CORE_APP);
81
81
  if (appClient) {
82
82
  await runScript(["umi", "build"], import_constant.ROOT_PATH, {
83
- APP_ROOT: import_path.default.join(import_constant.CORE_APP, "client")
83
+ APP_ROOT: import_path.default.join(import_constant.CORE_APP, "client"),
84
+ ANALYZE: process.env.BUILD_ANALYZE === "true" ? "1" : void 0
84
85
  });
85
86
  }
86
87
  (0, import_utils.writeToCache)(BUILD_ERROR, {});
package/lib/buildEsm.js CHANGED
@@ -32,8 +32,8 @@ __export(buildEsm_exports, {
32
32
  module.exports = __toCommonJS(buildEsm_exports);
33
33
  var import_path = __toESM(require("path"));
34
34
  var import_utils = require("./utils");
35
- var import_vite = require("vite");
36
35
  var import_fast_glob = __toESM(require("fast-glob"));
36
+ var import_core = require("@rspack/core");
37
37
  const clientExt = ".{ts,tsx,js,jsx}";
38
38
  function getSingleEntry(file, cwd) {
39
39
  return import_fast_glob.default.sync([`${file}${clientExt}`], { cwd, absolute: true, onlyFiles: true })?.[0]?.replaceAll(/\\/g, "/");
@@ -67,30 +67,134 @@ function build(cwd, entry, outDir, userConfig, sourcemap = false, log) {
67
67
  }
68
68
  return true;
69
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"
70
+ return (0, import_core.rspack)({
71
+ entry: {
72
+ index: entry
73
+ },
74
+ output: {
75
+ path: outDir,
76
+ library: {
77
+ type: "module"
78
+ },
79
+ clean: true
80
+ },
81
+ target: ["node16"],
82
+ mode: process.env.NODE_ENV === "production" ? "production" : "development",
83
+ resolve: {
84
+ tsConfig: import_path.default.join(process.cwd(), "tsconfig.json"),
85
+ extensions: [".js", ".jsx", ".ts", ".tsx", ".json", ".less", ".css"]
86
+ },
87
+ module: {
88
+ rules: [
89
+ {
90
+ test: /\.less$/,
91
+ use: [
92
+ { loader: "style-loader" },
93
+ { loader: "css-loader" },
94
+ { loader: require.resolve("less-loader") },
95
+ {
96
+ loader: "postcss-loader",
97
+ options: {
98
+ postcssOptions: {
99
+ plugins: {
100
+ "postcss-preset-env": {
101
+ browsers: ["last 2 versions", "> 1%", "cover 99.5%", "not dead"]
102
+ },
103
+ autoprefixer: {}
104
+ }
105
+ }
106
+ }
107
+ }
108
+ ],
109
+ type: "javascript/auto"
84
110
  },
85
- target: ["node16"],
86
- rollupOptions: {
87
- cache: true,
88
- treeshake: true,
89
- external
111
+ {
112
+ test: /\.css$/,
113
+ use: [
114
+ "style-loader",
115
+ "css-loader",
116
+ {
117
+ loader: "postcss-loader",
118
+ options: {
119
+ postcssOptions: {
120
+ plugins: {
121
+ "postcss-preset-env": {
122
+ browsers: ["last 2 versions", "> 1%", "cover 99.5%", "not dead"]
123
+ },
124
+ autoprefixer: {}
125
+ }
126
+ }
127
+ }
128
+ }
129
+ ],
130
+ type: "javascript/auto"
131
+ },
132
+ {
133
+ test: /\.(png|jpe?g|gif)$/i,
134
+ type: "asset"
135
+ },
136
+ {
137
+ test: /\.svg$/i,
138
+ issuer: /\.[jt]sx?$/,
139
+ use: ["@svgr/webpack"]
140
+ },
141
+ {
142
+ test: /\.jsx$/,
143
+ exclude: /[\\/]node_modules[\\/]/,
144
+ loader: "builtin:swc-loader",
145
+ options: {
146
+ sourceMap: true,
147
+ jsc: {
148
+ parser: {
149
+ syntax: "ecmascript",
150
+ jsx: true
151
+ },
152
+ target: "es5"
153
+ }
154
+ }
155
+ },
156
+ {
157
+ test: /\.tsx$/,
158
+ exclude: /[\\/]node_modules[\\/]/,
159
+ loader: "builtin:swc-loader",
160
+ options: {
161
+ sourceMap: true,
162
+ jsc: {
163
+ parser: {
164
+ syntax: "typescript",
165
+ tsx: true
166
+ },
167
+ target: "es5"
168
+ }
169
+ }
170
+ },
171
+ {
172
+ test: /\.ts$/,
173
+ exclude: /[\\/]node_modules[\\/]/,
174
+ loader: "builtin:swc-loader",
175
+ options: {
176
+ sourceMap: true,
177
+ jsc: {
178
+ parser: {
179
+ syntax: "typescript"
180
+ },
181
+ target: "es5"
182
+ }
183
+ }
184
+ }
185
+ ]
186
+ },
187
+ externals: [
188
+ function({ request }, callback) {
189
+ if (external(request)) {
190
+ return callback(null, true);
90
191
  }
192
+ callback();
91
193
  }
92
- })
93
- );
194
+ ],
195
+ plugins: [new import_core.rspack.DefinePlugin((0, import_utils.getEnvDefine)())],
196
+ stats: "errors-warnings"
197
+ });
94
198
  }
95
199
  // Annotate the CommonJS export names for ESM import in node:
96
200
  0 && (module.exports = {
@@ -35,19 +35,18 @@ __export(buildPlugin_exports, {
35
35
  writeExternalPackageVersion: () => writeExternalPackageVersion
36
36
  });
37
37
  module.exports = __toCommonJS(buildPlugin_exports);
38
+ var import_core = require("@rspack/core");
38
39
  var import_ncc = __toESM(require("@vercel/ncc"));
39
- var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
40
40
  var import_chalk = __toESM(require("chalk"));
41
41
  var import_fast_glob = __toESM(require("fast-glob"));
42
42
  var import_fs_extra = __toESM(require("fs-extra"));
43
43
  var import_path = __toESM(require("path"));
44
44
  var import_tsup = require("tsup");
45
- var import_vite = require("vite");
46
- var import_vite_plugin_css_injected_by_js = __toESM(require("vite-plugin-css-injected-by-js"));
47
45
  var import_constant = require("./constant");
48
46
  var import_utils = require("./utils");
49
47
  var import_buildPluginUtils = require("./utils/buildPluginUtils");
50
48
  var import_getDepsConfig = require("./utils/getDepsConfig");
49
+ var import_rspack_plugin = require("@rsdoctor/rspack-plugin");
51
50
  const validExts = [".ts", ".tsx", ".js", ".jsx", ".mjs"];
52
51
  const serverGlobalFiles = ["src/**", "!src/client/**", ...import_constant.globExcludeFiles];
53
52
  const clientGlobalFiles = ["src/**", "!src/server/**", ...import_constant.globExcludeFiles];
@@ -62,8 +61,10 @@ const external = [
62
61
  "@nocobase/database",
63
62
  "@nocobase/data-source-manager",
64
63
  "@nocobase/evaluators",
64
+ "@nocobase/lock-manager",
65
65
  "@nocobase/logger",
66
66
  "@nocobase/resourcer",
67
+ "@nocobase/telemetry",
67
68
  "@nocobase/sdk",
68
69
  "@nocobase/server",
69
70
  "@nocobase/test",
@@ -133,7 +134,8 @@ const external = [
133
134
  "@emotion/css",
134
135
  "ahooks",
135
136
  "lodash",
136
- "china-division"
137
+ "china-division",
138
+ "file-saver"
137
139
  ];
138
140
  const pluginPrefix = (process.env.PLUGIN_PACKAGE_PREFIX || "@nocobase/plugin-,@nocobase/preset-,@nocobase/plugin-pro-").split(",");
139
141
  const target_dir = "dist";
@@ -187,7 +189,9 @@ async function buildServerDeps(cwd, serverFiles, log) {
187
189
  if (excludePackages.length) {
188
190
  tips.push(`These packages ${import_chalk.default.yellow(excludePackages.join(", "))} will be ${import_chalk.default.italic("exclude")}.`);
189
191
  }
190
- tips.push(`For more information, please refer to: ${import_chalk.default.blue("https://docs.nocobase.com/development/deps")}.`);
192
+ tips.push(
193
+ `For more information, please refer to: ${import_chalk.default.blue("https://docs.nocobase.com/development/others/deps")}.`
194
+ );
191
195
  log(tips.join(" "));
192
196
  if (!includePackages.length) return;
193
197
  const deps = (0, import_getDepsConfig.getDepsConfig)(cwd, outDir, includePackages, external);
@@ -287,48 +291,184 @@ async function buildPluginClient(cwd, userConfig, sourcemap, log) {
287
291
  const outDir = import_path.default.join(cwd, target_dir, "client");
288
292
  const globals = excludePackages.reduce((prev, curr) => {
289
293
  if (curr.startsWith("@nocobase")) {
290
- prev[`${curr}/client`] = curr;
294
+ prev[`${curr}/client`] = `${curr}/client`;
291
295
  }
292
296
  prev[curr] = curr;
293
297
  return prev;
294
298
  }, {});
295
- const entry = import_fast_glob.default.globSync("src/client/index.{ts,tsx,js,jsx}", { absolute: true, cwd });
299
+ const entry = import_fast_glob.default.globSync("index.{ts,tsx,js,jsx}", { absolute: false, cwd: import_path.default.join(cwd, "src/client") });
296
300
  const outputFileName = "index.js";
297
- await (0, import_vite.build)(
298
- userConfig.modifyViteConfig({
299
- mode: process.env.NODE_ENV || "production",
300
- define: (0, import_utils.getEnvDefine)(),
301
- logLevel: "warn",
302
- build: {
303
- minify: process.env.NODE_ENV === "production",
304
- outDir,
305
- cssCodeSplit: false,
306
- emptyOutDir: true,
307
- sourcemap,
308
- lib: {
309
- entry,
310
- formats: ["umd"],
311
- name: packageJson.name,
312
- fileName: () => outputFileName
301
+ const compiler = (0, import_core.rspack)({
302
+ mode: "production",
303
+ // mode: "development",
304
+ context: cwd,
305
+ entry: "./src/client/" + entry[0],
306
+ target: ["web", "es5"],
307
+ output: {
308
+ path: outDir,
309
+ filename: outputFileName,
310
+ chunkFilename: "[chunkhash].js",
311
+ publicPath: `/static/plugins/${packageJson.name}/dist/client/`,
312
+ clean: true,
313
+ library: {
314
+ name: packageJson.name,
315
+ type: "umd",
316
+ umdNamedDefine: true
317
+ }
318
+ },
319
+ resolve: {
320
+ tsConfig: import_path.default.join(process.cwd(), "tsconfig.json"),
321
+ extensions: [".js", ".jsx", ".ts", ".tsx", ".json", ".less", ".css"]
322
+ },
323
+ module: {
324
+ rules: [
325
+ {
326
+ test: /\.less$/,
327
+ use: [
328
+ { loader: "style-loader" },
329
+ { loader: "css-loader" },
330
+ { loader: require.resolve("less-loader") },
331
+ {
332
+ loader: "postcss-loader",
333
+ options: {
334
+ postcssOptions: {
335
+ plugins: {
336
+ "postcss-preset-env": {
337
+ browsers: ["last 2 versions", "> 1%", "cover 99.5%", "not dead"]
338
+ },
339
+ autoprefixer: {}
340
+ }
341
+ }
342
+ }
343
+ }
344
+ ],
345
+ type: "javascript/auto"
346
+ },
347
+ {
348
+ test: /\.css$/,
349
+ use: [
350
+ "style-loader",
351
+ "css-loader",
352
+ {
353
+ loader: "postcss-loader",
354
+ options: {
355
+ postcssOptions: {
356
+ plugins: {
357
+ "postcss-preset-env": {
358
+ browsers: ["last 2 versions", "> 1%", "cover 99.5%", "not dead"]
359
+ },
360
+ autoprefixer: {}
361
+ }
362
+ }
363
+ }
364
+ }
365
+ ],
366
+ type: "javascript/auto"
367
+ },
368
+ {
369
+ test: /\.(png|jpe?g|gif)$/i,
370
+ type: "asset"
371
+ },
372
+ {
373
+ test: /\.svg$/i,
374
+ issuer: /\.[jt]sx?$/,
375
+ use: ["@svgr/webpack"]
376
+ },
377
+ {
378
+ test: /\.(?:js|mjs|cjs|ts|tsx)$/,
379
+ exclude: /node_modules/,
380
+ use: {
381
+ loader: "babel-loader",
382
+ options: {
383
+ targets: "defaults",
384
+ // presets: [['@babel/preset-env']],
385
+ plugins: ["react-imported-component/babel"]
386
+ }
387
+ }
388
+ },
389
+ {
390
+ test: /\.jsx$/,
391
+ exclude: /[\\/]node_modules[\\/]/,
392
+ loader: "builtin:swc-loader",
393
+ options: {
394
+ sourceMap: true,
395
+ jsc: {
396
+ parser: {
397
+ syntax: "ecmascript",
398
+ jsx: true
399
+ },
400
+ target: "es5"
401
+ }
402
+ }
403
+ },
404
+ {
405
+ test: /\.tsx$/,
406
+ exclude: /[\\/]node_modules[\\/]/,
407
+ loader: "builtin:swc-loader",
408
+ options: {
409
+ sourceMap: true,
410
+ jsc: {
411
+ parser: {
412
+ syntax: "typescript",
413
+ tsx: true
414
+ },
415
+ target: "es5"
416
+ }
417
+ }
313
418
  },
314
- target: ["es2015", "edge88", "firefox78", "chrome87", "safari14"],
315
- rollupOptions: {
316
- cache: true,
317
- external: [...Object.keys(globals), "react", "react/jsx-runtime"],
318
- output: {
319
- exports: "named",
320
- globals: {
321
- react: "React",
322
- "react/jsx-runtime": "jsxRuntime",
323
- ...globals
419
+ {
420
+ test: /\.ts$/,
421
+ exclude: /[\\/]node_modules[\\/]/,
422
+ loader: "builtin:swc-loader",
423
+ options: {
424
+ sourceMap: true,
425
+ jsc: {
426
+ parser: {
427
+ syntax: "typescript"
428
+ },
429
+ target: "es5"
324
430
  }
325
431
  }
326
432
  }
327
- },
328
- plugins: [(0, import_plugin_react.default)(), (0, import_vite_plugin_css_injected_by_js.default)({ styleId: packageJson.name })]
329
- })
330
- );
331
- (0, import_buildPluginUtils.checkFileSize)(outDir, log);
433
+ ]
434
+ },
435
+ plugins: [
436
+ new import_core.rspack.DefinePlugin({
437
+ "process.env.NODE_ENV": JSON.stringify("production")
438
+ }),
439
+ process.env.BUILD_ANALYZE === "true" && new import_rspack_plugin.RsdoctorRspackPlugin({
440
+ // plugin options
441
+ // supports: {
442
+ // generateTileGraph: true,
443
+ // },
444
+ mode: "brief"
445
+ })
446
+ ].filter(Boolean),
447
+ node: {
448
+ global: true
449
+ },
450
+ externals: {
451
+ react: "React",
452
+ lodash: "lodash",
453
+ // 'react/jsx-runtime': 'jsxRuntime',
454
+ ...globals
455
+ },
456
+ stats: "errors-warnings"
457
+ });
458
+ return new Promise((resolve, reject) => {
459
+ compiler.run((err, stats) => {
460
+ const compilationErrors = stats?.compilation.errors;
461
+ const infos = stats.toString({
462
+ colors: true
463
+ });
464
+ if (err || compilationErrors?.length) {
465
+ reject(err || infos);
466
+ return;
467
+ }
468
+ console.log(infos);
469
+ resolve(null);
470
+ });
471
+ });
332
472
  }
333
473
  async function buildPlugin(cwd, userConfig, sourcemap, log) {
334
474
  await buildPluginClient(cwd, userConfig, sourcemap, log);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/build",
3
- "version": "1.5.0-beta.2",
3
+ "version": "1.5.0-beta.4",
4
4
  "description": "Library build tool based on rollup.",
5
5
  "main": "lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -9,29 +9,35 @@
9
9
  },
10
10
  "typings": "./index.d.ts",
11
11
  "dependencies": {
12
- "@babel/core": "7.25.2",
12
+ "@babel/core": "^7.26.0",
13
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
13
14
  "@babel/plugin-transform-modules-amd": "7.24.7",
14
- "@babel/preset-env": "7.25.4",
15
+ "@babel/preset-env": "^7.26.0",
15
16
  "@hapi/topo": "^6.0.0",
16
17
  "@lerna/project": "4.0.0",
17
- "@rspack/core": "1.0.14",
18
+ "@rsbuild/plugin-babel": "^1.0.3",
19
+ "@rsdoctor/rspack-plugin": "^0.4.8",
20
+ "@rspack/core": "1.1.1",
18
21
  "@svgr/webpack": "^8.1.0",
19
22
  "@types/gulp": "^4.0.13",
20
23
  "@types/lerna__package": "5.1.0",
21
24
  "@types/lerna__project": "5.1.0",
22
25
  "@types/tar": "^6.1.5",
23
26
  "@vercel/ncc": "0.36.1",
27
+ "babel-loader": "^9.2.1",
28
+ "babel-plugin-syntax-dynamic-import": "^6.18.0",
24
29
  "chalk": "2.4.2",
25
30
  "css-loader": "^6.8.1",
26
31
  "esbuild-register": "^3.4.2",
27
32
  "fast-glob": "^3.3.1",
28
33
  "gulp": "4.0.2",
29
34
  "gulp-typescript": "6.0.0-alpha.1",
30
- "less": "^4.1.3",
31
- "less-loader": "11.1.0",
35
+ "less": "^4.2.0",
36
+ "less-loader": "^12.2.0",
32
37
  "postcss": "^8.4.29",
33
38
  "postcss-loader": "^7.3.3",
34
39
  "postcss-preset-env": "^9.1.2",
40
+ "react-imported-component": "^6.5.4",
35
41
  "style-loader": "^3.3.3",
36
42
  "tar": "^6.2.0",
37
43
  "tsup": "8.2.4",
@@ -45,5 +51,5 @@
45
51
  "scripts": {
46
52
  "build": "tsup"
47
53
  },
48
- "gitHead": "8a9c29fdac5c6295dcc7abf00c3fa81bd9e01a36"
54
+ "gitHead": "f5ca1548fe8d8eda32699137434306c44a5df84c"
49
55
  }