@nocobase/build 0.9.1-alpha.2 → 0.9.2-alpha.2

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/rollup.js CHANGED
@@ -4,54 +4,37 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = _default;
7
-
8
7
  var _rollup = require("rollup");
9
-
10
8
  var _signale = _interopRequireDefault(require("signale"));
11
-
12
9
  var _chalk = _interopRequireDefault(require("chalk"));
13
-
14
10
  var _getRollupConfig = _interopRequireDefault(require("./getRollupConfig"));
15
-
16
11
  var _normalizeBundleOpts = _interopRequireDefault(require("./normalizeBundleOpts"));
17
-
18
12
  const _excluded = ["output"];
19
-
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
14
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
23
-
24
15
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
25
-
26
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
-
28
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
-
30
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
-
18
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
20
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
32
21
  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; } } }; }
33
-
34
22
  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); }
35
-
36
23
  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; }
37
-
38
24
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
39
-
40
25
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
41
-
42
26
  function build(_x, _x2) {
43
27
  return _build.apply(this, arguments);
44
28
  }
45
-
46
29
  function _build() {
47
30
  _build = _asyncToGenerator(function* (entry, opts) {
48
31
  const cwd = opts.cwd,
49
- rootPath = opts.rootPath,
50
- type = opts.type,
51
- log = opts.log,
52
- bundleOpts = opts.bundleOpts,
53
- importLibToEs = opts.importLibToEs,
54
- dispose = opts.dispose;
32
+ rootPath = opts.rootPath,
33
+ type = opts.type,
34
+ log = opts.log,
35
+ bundleOpts = opts.bundleOpts,
36
+ importLibToEs = opts.importLibToEs,
37
+ dispose = opts.dispose;
55
38
  const rollupConfigs = (0, _getRollupConfig.default)({
56
39
  cwd,
57
40
  rootPath: rootPath || cwd,
@@ -60,14 +43,11 @@ function _build() {
60
43
  importLibToEs,
61
44
  bundleOpts: (0, _normalizeBundleOpts.default)(entry, bundleOpts)
62
45
  });
63
-
64
46
  var _iterator = _createForOfIteratorHelper(rollupConfigs),
65
- _step;
66
-
47
+ _step;
67
48
  try {
68
49
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
69
50
  const rollupConfig = _step.value;
70
-
71
51
  if (opts.watch) {
72
52
  const watcher = (0, _rollup.watch)([_objectSpread(_objectSpread({}, rollupConfig), {}, {
73
53
  watch: {}
@@ -78,7 +58,6 @@ function _build() {
78
58
  // 当第一次构建完成或出错就 resolve
79
59
  if (event.code === 'ERROR') {
80
60
  _signale.default.error(event.error);
81
-
82
61
  resolve();
83
62
  } else if (event.code === 'BUNDLE_END') {
84
63
  log(`${_chalk.default.green(`Build ${type} success`)} ${_chalk.default.gray(`entry: ${entry}`)}`);
@@ -92,12 +71,9 @@ function _build() {
92
71
  dispose === null || dispose === void 0 ? void 0 : dispose.push(() => watcher.close());
93
72
  } else {
94
73
  const output = rollupConfig.output,
95
- input = _objectWithoutProperties(rollupConfig, _excluded);
96
-
74
+ input = _objectWithoutProperties(rollupConfig, _excluded);
97
75
  const bundle = yield (0, _rollup.rollup)(input); // eslint-disable-line
98
-
99
76
  yield bundle.write(output); // eslint-disable-line
100
-
101
77
  log(`${_chalk.default.green(`Build ${type} success`)} ${_chalk.default.gray(`entry: ${entry}`)}`);
102
78
  }
103
79
  }
@@ -109,19 +85,15 @@ function _build() {
109
85
  });
110
86
  return _build.apply(this, arguments);
111
87
  }
112
-
113
88
  function _default(_x3) {
114
89
  return _ref.apply(this, arguments);
115
90
  }
116
-
117
91
  function _ref() {
118
92
  _ref = _asyncToGenerator(function* (opts) {
119
93
  if (Array.isArray(opts.entry)) {
120
94
  const entries = opts.entry;
121
-
122
95
  var _iterator2 = _createForOfIteratorHelper(entries),
123
- _step2;
124
-
96
+ _step2;
125
97
  try {
126
98
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
127
99
  const entry = _step2.value;
@@ -135,7 +107,6 @@ function _ref() {
135
107
  } else {
136
108
  yield build(opts.entry, opts);
137
109
  }
138
-
139
110
  if (opts.watch) {
140
111
  opts.log(_chalk.default.magentaBright(`Rebuild ${opts.type} since file changed 👀`));
141
112
  }
@@ -5,17 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getLernaPackages = getLernaPackages;
7
7
  exports.getStreamPackages = getStreamPackages;
8
-
9
8
  var _project = require("@lerna/project");
10
-
11
9
  var _queryGraph = require("@lerna/query-graph");
12
-
13
10
  var _filterPackages = require("@lerna/filter-packages");
14
-
15
11
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
16
-
17
12
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
18
-
19
13
  /**
20
14
  * 获取lerna项目包集合
21
15
  * @param cwd
@@ -23,30 +17,27 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
23
17
  function getLernaPackages(_x) {
24
18
  return _getLernaPackages.apply(this, arguments);
25
19
  }
26
-
27
20
  function _getLernaPackages() {
28
21
  _getLernaPackages = _asyncToGenerator(function* (cwd, ops = {}) {
29
22
  var _getPackagesSync;
30
-
31
23
  const _ops$include = ops.include,
32
- include = _ops$include === void 0 ? [] : _ops$include,
33
- _ops$exclude = ops.exclude,
34
- exclude = _ops$exclude === void 0 ? [] : _ops$exclude,
35
- _ops$skipPrivate = ops.skipPrivate,
36
- skipPrivate = _ops$skipPrivate === void 0 ? false : _ops$skipPrivate;
24
+ include = _ops$include === void 0 ? [] : _ops$include,
25
+ _ops$exclude = ops.exclude,
26
+ exclude = _ops$exclude === void 0 ? [] : _ops$exclude,
27
+ _ops$skipPrivate = ops.skipPrivate,
28
+ skipPrivate = _ops$skipPrivate === void 0 ? false : _ops$skipPrivate;
37
29
  const allPkgs = (_getPackagesSync = (0, _project.getPackagesSync)(cwd)) !== null && _getPackagesSync !== void 0 ? _getPackagesSync : [];
38
30
  const pkgs = (0, _filterPackages.filterPackages)(allPkgs, include, exclude, !skipPrivate, true);
39
31
  return yield getStreamPackages(pkgs);
40
32
  });
41
33
  return _getLernaPackages.apply(this, arguments);
42
34
  }
43
-
44
35
  function getStreamPackages(pkgs) {
45
36
  const graph = new _queryGraph.QueryGraph(pkgs, 'allDependencies', true);
46
37
  return new Promise(resolve => {
47
38
  const returnValues = [];
48
-
49
- const queueNextAvailablePackages = () => graph.getAvailablePackages() // @ts-ignore
39
+ const queueNextAvailablePackages = () => graph.getAvailablePackages()
40
+ // @ts-ignore
50
41
  .forEach(({
51
42
  pkg,
52
43
  name
@@ -54,7 +45,6 @@ function getStreamPackages(pkgs) {
54
45
  graph.markAsTaken(name);
55
46
  Promise.resolve(pkg).then(value => returnValues.push(value)).then(() => graph.markAsDone(pkg)).then(() => queueNextAvailablePackages());
56
47
  });
57
-
58
48
  queueNextAvailablePackages();
59
49
  setTimeout(() => {
60
50
  resolve(returnValues);
@@ -10,32 +10,23 @@ Object.defineProperty(exports, "getLernaPackages", {
10
10
  return _getLernaPackages.getLernaPackages;
11
11
  }
12
12
  });
13
-
14
13
  var _fs = require("fs");
15
-
16
14
  var _path = require("path");
17
-
18
15
  var _getLernaPackages = require("./getLernaPackages");
19
-
20
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; } } }; }
21
-
22
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); }
23
-
24
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; }
25
-
26
19
  function getExistFile({
27
20
  cwd,
28
21
  files,
29
22
  returnRelative
30
23
  }) {
31
24
  var _iterator = _createForOfIteratorHelper(files),
32
- _step;
33
-
25
+ _step;
34
26
  try {
35
27
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
36
28
  const file = _step.value;
37
29
  const absFilePath = (0, _path.join)(cwd, file);
38
-
39
30
  if ((0, _fs.existsSync)(absFilePath)) {
40
31
  return returnRelative ? file : absFilePath;
41
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/build",
3
- "version": "0.9.1-alpha.2",
3
+ "version": "0.9.2-alpha.2",
4
4
  "description": "Library build tool based on rollup.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -74,5 +74,5 @@
74
74
  "@types/gulp-plumber": "^0.0.32",
75
75
  "umi-tools": "^0.4.0"
76
76
  },
77
- "gitHead": "d588a68eca4feed4642a4cb317301011266fe5c9"
77
+ "gitHead": "1a0de6908b2b1854bdf434fcafa8909cb65bb8a3"
78
78
  }