@nocobase/build 0.10.1-alpha.1 → 0.11.0-alpha.1

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
@@ -39,9 +39,10 @@ function getBundleOpts(opts) {
39
39
  buildArgs = _opts$buildArgs === void 0 ? {} : _opts$buildArgs,
40
40
  _opts$rootConfig = opts.rootConfig,
41
41
  rootConfig = _opts$rootConfig === void 0 ? {} : _opts$rootConfig;
42
- const entry = (0, _utils.getExistFile)({
42
+ const entry = (0, _utils.getExistFiles)({
43
43
  cwd,
44
- files: ['src/index.tsx', 'src/index.ts', 'src/index.jsx', 'src/index.js'],
44
+ files: ['src/index.tsx', 'src/index.ts', 'src/index.jsx', 'src/index.js', 'src/server/index.ts', 'src/server/index.js', 'src/client/index.js', 'src/client/index.ts', 'src/client/index.tsx'],
45
+ onlyOne: false,
45
46
  returnRelative: true
46
47
  });
47
48
  const userConfig = (0, _getUserConfig.default)({
@@ -43,7 +43,7 @@ function _default({
43
43
  throw new Error(`can\'t found config file: ${customPath}`);
44
44
  }
45
45
  }
46
- const configFile = finalPath || (0, _utils.getExistFile)({
46
+ const configFile = finalPath || (0, _utils.getExistFiles)({
47
47
  cwd,
48
48
  files: CONFIG_FILES,
49
49
  returnRelative: false
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getExistFile = getExistFile;
6
+ exports.getExistFiles = getExistFiles;
7
7
  Object.defineProperty(exports, "getLernaPackages", {
8
8
  enumerable: true,
9
9
  get: function get() {
@@ -16,11 +16,13 @@ var _getLernaPackages = require("./getLernaPackages");
16
16
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
17
17
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18
18
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
19
- function getExistFile({
19
+ function getExistFiles({
20
20
  cwd,
21
21
  files,
22
- returnRelative
22
+ returnRelative,
23
+ onlyOne = true
23
24
  }) {
25
+ const res = [];
24
26
  var _iterator = _createForOfIteratorHelper(files),
25
27
  _step;
26
28
  try {
@@ -28,7 +30,8 @@ function getExistFile({
28
30
  const file = _step.value;
29
31
  const absFilePath = (0, _path.join)(cwd, file);
30
32
  if ((0, _fs.existsSync)(absFilePath)) {
31
- return returnRelative ? file : absFilePath;
33
+ const filePath = returnRelative ? file : absFilePath;
34
+ res.push(filePath);
32
35
  }
33
36
  }
34
37
  } catch (err) {
@@ -36,4 +39,5 @@ function getExistFile({
36
39
  } finally {
37
40
  _iterator.f();
38
41
  }
42
+ return onlyOne ? res[0] : res; // undefined or string[]
39
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/build",
3
- "version": "0.10.1-alpha.1",
3
+ "version": "0.11.0-alpha.1",
4
4
  "description": "Library build tool based on rollup.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -8,31 +8,31 @@
8
8
  },
9
9
  "typings": "./index.d.ts",
10
10
  "dependencies": {
11
- "@babel/core": "7.12.3",
12
- "@babel/plugin-proposal-class-properties": "7.12.1",
13
- "@babel/plugin-proposal-decorators": "7.12.1",
14
- "@babel/plugin-proposal-do-expressions": "7.12.1",
15
- "@babel/plugin-proposal-export-default-from": "7.12.1",
16
- "@babel/plugin-proposal-export-namespace-from": "7.12.1",
17
- "@babel/plugin-proposal-nullish-coalescing-operator": "7.12.1",
18
- "@babel/plugin-proposal-optional-chaining": "7.12.1",
11
+ "@babel/core": "7.22.5",
12
+ "@babel/plugin-proposal-class-properties": "7.18.6",
13
+ "@babel/plugin-proposal-decorators": "7.22.5",
14
+ "@babel/plugin-proposal-do-expressions": "7.22.5",
15
+ "@babel/plugin-proposal-export-default-from": "7.22.5",
16
+ "@babel/plugin-proposal-export-namespace-from": "7.18.9",
17
+ "@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
18
+ "@babel/plugin-proposal-optional-chaining": "7.21.0",
19
19
  "@babel/plugin-syntax-dynamic-import": "7.8.3",
20
- "@babel/plugin-transform-modules-commonjs": "7.12.1",
21
- "@babel/plugin-transform-runtime": "7.12.1",
20
+ "@babel/plugin-transform-modules-commonjs": "7.22.5",
21
+ "@babel/plugin-transform-runtime": "7.22.5",
22
22
  "@babel/preset-env": "7.12.1",
23
- "@babel/preset-react": "7.12.1",
24
- "@babel/preset-typescript": "7.12.1",
25
- "@babel/register": "7.12.1",
23
+ "@babel/preset-react": "7.22.5",
24
+ "@babel/preset-typescript": "7.22.5",
25
+ "@babel/register": "7.22.5",
26
26
  "@lerna/filter-packages": "4.0.0",
27
27
  "@lerna/project": "4.0.0",
28
28
  "@lerna/query-graph": "4.0.0",
29
- "@rollup/plugin-babel": "5.3.1",
30
- "@rollup/plugin-commonjs": "16.0.0",
31
- "@rollup/plugin-inject": "4.0.2",
32
- "@rollup/plugin-json": "4.1.0",
33
- "@rollup/plugin-node-resolve": "10.0.0",
34
- "@rollup/plugin-replace": "2.3.4",
35
- "@rollup/plugin-url": "5.0.1",
29
+ "@rollup/plugin-babel": "6.0.3",
30
+ "@rollup/plugin-commonjs": "25.0.1",
31
+ "@rollup/plugin-inject": "5.0.3",
32
+ "@rollup/plugin-json": "6.0.0",
33
+ "@rollup/plugin-node-resolve": "15.1.0",
34
+ "@rollup/plugin-replace": "5.0.2",
35
+ "@rollup/plugin-url": "8.0.1",
36
36
  "@svgr/rollup": "5.5.0",
37
37
  "ajv": "6.12.6",
38
38
  "autoprefixer": "9.6.0",
@@ -45,23 +45,23 @@
45
45
  "gulp-if": "2.0.2",
46
46
  "gulp-less": "^5.0.0",
47
47
  "gulp-plumber": "^1.2.1",
48
- "gulp-typescript": "5.0.1",
48
+ "gulp-typescript": "6.0.0-alpha.1",
49
49
  "less": "4.1.3",
50
50
  "less-plugin-npm-import": "2.1.0",
51
51
  "lodash": "4.17.21",
52
52
  "pkg-up": "3.1.0",
53
53
  "rimraf": "2.6.3",
54
- "rollup": "2.33.3",
55
- "rollup-plugin-postcss": "3.1.8",
54
+ "rollup": "3.25.1",
55
+ "rollup-plugin-postcss": "4.0.2",
56
56
  "rollup-plugin-terser": "7.0.2",
57
- "rollup-plugin-typescript2": "0.29.0",
57
+ "rollup-plugin-typescript2": "0.34.1",
58
58
  "semver": "6.1.1",
59
59
  "signale": "1.4.0",
60
60
  "slash2": "2.0.0",
61
61
  "temp-dir": "2.0.0",
62
62
  "through2": "3.0.1",
63
- "ts-loader": "^8.0.7",
64
- "typescript": "4.5.5",
63
+ "ts-loader": "^9.4.3",
64
+ "typescript": "5.1.3",
65
65
  "update-notifier": "3.0.0",
66
66
  "vinyl-fs": "3.0.3",
67
67
  "yargs-parser": "13.1.2"
@@ -74,5 +74,5 @@
74
74
  "@types/gulp-plumber": "^0.0.32",
75
75
  "umi-tools": "^0.4.0"
76
76
  },
77
- "gitHead": "8f415f5e0ee2e72d681f9ab16af5911b52c374a9"
77
+ "gitHead": "7581b6d3a3a54f09f06a9effb7e3e65328281b2b"
78
78
  }
package/src/build.ts CHANGED
@@ -11,13 +11,24 @@ import randomColor from './randomColor';
11
11
  import registerBabel from './registerBabel';
12
12
  import rollup from './rollup';
13
13
  import { Dispose, IBundleOptions, IBundleTypeOutput, ICjs, IEsm, IOpts } from './types';
14
- import { getExistFile, getLernaPackages } from './utils';
14
+ import { getExistFiles, getLernaPackages } from './utils';
15
15
 
16
16
  export function getBundleOpts(opts: IOpts): IBundleOptions[] {
17
17
  const { cwd, buildArgs = {}, rootConfig = {} } = opts;
18
- const entry = getExistFile({
18
+ const entry = getExistFiles({
19
19
  cwd,
20
- files: ['src/index.tsx', 'src/index.ts', 'src/index.jsx', 'src/index.js'],
20
+ files: [
21
+ 'src/index.tsx',
22
+ 'src/index.ts',
23
+ 'src/index.jsx',
24
+ 'src/index.js',
25
+ 'src/server/index.ts',
26
+ 'src/server/index.js',
27
+ 'src/client/index.js',
28
+ 'src/client/index.ts',
29
+ 'src/client/index.tsx'
30
+ ],
31
+ onlyOne: false,
21
32
  returnRelative: true,
22
33
  });
23
34
  const userConfig = getUserConfig({ cwd, customPath: buildArgs.config });
@@ -5,7 +5,7 @@ import signale from 'signale';
5
5
  import slash from 'slash2';
6
6
  import schema from './schema';
7
7
  import { IBundleOptions } from './types';
8
- import { getExistFile } from './utils';
8
+ import { getExistFiles } from './utils';
9
9
 
10
10
  function testDefault(obj) {
11
11
  return obj.default || obj;
@@ -51,7 +51,7 @@ export default function({ cwd, customPath }: { cwd: string; customPath?: string
51
51
 
52
52
  const configFile =
53
53
  finalPath ||
54
- getExistFile({
54
+ getExistFiles({
55
55
  cwd,
56
56
  files: CONFIG_FILES,
57
57
  returnRelative: false,
@@ -1,13 +1,17 @@
1
1
  import { existsSync } from 'fs';
2
2
  import { join } from 'path';
3
3
 
4
- export function getExistFile({ cwd, files, returnRelative }) {
4
+ export function getExistFiles({ cwd, files, returnRelative, onlyOne = true }) {
5
+ const res = [];
5
6
  for (const file of files) {
6
7
  const absFilePath = join(cwd, file);
7
8
  if (existsSync(absFilePath)) {
8
- return returnRelative ? file : absFilePath;
9
+ const filePath = returnRelative ? file : absFilePath;
10
+ res.push(filePath);
9
11
  }
10
12
  }
13
+
14
+ return onlyOne ? res[0] : res; // undefined or string[]
11
15
  }
12
16
 
13
17
  export { getLernaPackages } from './getLernaPackages';