@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.
@@ -4,38 +4,33 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = _default;
7
-
8
7
  var _path = require("path");
9
-
10
8
  function transformImportLess2Css() {
11
9
  return {
12
10
  name: 'transform-import-less-to-css',
13
11
  visitor: {
14
12
  ImportDeclaration(path, source) {
15
13
  const re = /\.less$/;
16
-
17
14
  if (re.test(path.node.source.value)) {
18
15
  path.node.source.value = path.node.source.value.replace(re, '.css');
19
16
  }
20
17
  }
21
-
22
18
  }
23
19
  };
24
20
  }
25
-
26
21
  function _default(opts) {
27
22
  const target = opts.target,
28
- typescript = opts.typescript,
29
- type = opts.type,
30
- runtimeHelpers = opts.runtimeHelpers,
31
- filePath = opts.filePath,
32
- browserFiles = opts.browserFiles,
33
- nodeFiles = opts.nodeFiles,
34
- nodeVersion = opts.nodeVersion,
35
- lazy = opts.lazy,
36
- lessInBabelMode = opts.lessInBabelMode;
37
- let isBrowser = target === 'browser'; // rollup 场景下不会传入 filePath
38
-
23
+ typescript = opts.typescript,
24
+ type = opts.type,
25
+ runtimeHelpers = opts.runtimeHelpers,
26
+ filePath = opts.filePath,
27
+ browserFiles = opts.browserFiles,
28
+ nodeFiles = opts.nodeFiles,
29
+ nodeVersion = opts.nodeVersion,
30
+ lazy = opts.lazy,
31
+ lessInBabelMode = opts.lessInBabelMode;
32
+ let isBrowser = target === 'browser';
33
+ // rollup 场景下不会传入 filePath
39
34
  if (filePath) {
40
35
  if ((0, _path.extname)(filePath) === '.tsx' || (0, _path.extname)(filePath) === '.jsx') {
41
36
  isBrowser = true;
@@ -47,7 +42,6 @@ function _default(opts) {
47
42
  }
48
43
  }
49
44
  }
50
-
51
45
  const targets = isBrowser ? {
52
46
  browsers: ['last 2 versions', 'IE 10']
53
47
  } : {
@@ -4,113 +4,88 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = _default;
7
-
8
7
  var _fs = require("fs");
9
-
10
8
  var _path = require("path");
11
-
12
9
  var _pluginUrl = _interopRequireDefault(require("@rollup/plugin-url"));
13
-
14
10
  var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
15
-
16
11
  var _pluginReplace = _interopRequireDefault(require("@rollup/plugin-replace"));
17
-
18
12
  var _pluginCommonjs = _interopRequireDefault(require("@rollup/plugin-commonjs"));
19
-
20
13
  var _pluginNodeResolve = _interopRequireDefault(require("@rollup/plugin-node-resolve"));
21
-
22
14
  var _pluginInject = _interopRequireDefault(require("@rollup/plugin-inject"));
23
-
24
15
  var _pluginBabel = _interopRequireDefault(require("@rollup/plugin-babel"));
25
-
26
16
  var _pluginutils = require("@rollup/pluginutils");
27
-
28
17
  var _rollupPluginPostcss = _interopRequireDefault(require("rollup-plugin-postcss"));
29
-
30
18
  var _rollupPluginTerser = require("rollup-plugin-terser");
31
-
32
19
  var _rollupPluginTypescript = _interopRequireDefault(require("rollup-plugin-typescript2"));
33
-
34
20
  var _lodash = require("lodash");
35
-
36
21
  var _tempDir = _interopRequireDefault(require("temp-dir"));
37
-
38
22
  var _autoprefixer = _interopRequireDefault(require("autoprefixer"));
39
-
40
23
  var _lessPluginNpmImport = _interopRequireDefault(require("less-plugin-npm-import"));
41
-
42
24
  var _rollup = _interopRequireDefault(require("@svgr/rollup"));
43
-
44
25
  var _getBabelConfig = _interopRequireDefault(require("./getBabelConfig"));
45
-
46
26
  var _es5ImcompatibleVersions = require("./es5ImcompatibleVersions");
47
-
48
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
49
-
50
28
  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; }
51
-
52
29
  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; }
53
-
54
- 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; }
55
-
30
+ 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; }
31
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
32
+ 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); }
56
33
  function _default(opts) {
57
34
  const type = opts.type,
58
- entry = opts.entry,
59
- cwd = opts.cwd,
60
- rootPath = opts.rootPath,
61
- importLibToEs = opts.importLibToEs,
62
- bundleOpts = opts.bundleOpts;
35
+ entry = opts.entry,
36
+ cwd = opts.cwd,
37
+ rootPath = opts.rootPath,
38
+ importLibToEs = opts.importLibToEs,
39
+ bundleOpts = opts.bundleOpts;
63
40
  const umd = bundleOpts.umd,
64
- esm = bundleOpts.esm,
65
- cjs = bundleOpts.cjs,
66
- file = bundleOpts.file,
67
- _bundleOpts$target = bundleOpts.target,
68
- target = _bundleOpts$target === void 0 ? 'browser' : _bundleOpts$target,
69
- _bundleOpts$extractCS = bundleOpts.extractCSS,
70
- extractCSS = _bundleOpts$extractCS === void 0 ? false : _bundleOpts$extractCS,
71
- _bundleOpts$injectCSS = bundleOpts.injectCSS,
72
- injectCSS = _bundleOpts$injectCSS === void 0 ? true : _bundleOpts$injectCSS,
73
- modules = bundleOpts.cssModules,
74
- _bundleOpts$extraPost = bundleOpts.extraPostCSSPlugins,
75
- extraPostCSSPlugins = _bundleOpts$extraPost === void 0 ? [] : _bundleOpts$extraPost,
76
- _bundleOpts$extraBabe = bundleOpts.extraBabelPresets,
77
- extraBabelPresets = _bundleOpts$extraBabe === void 0 ? [] : _bundleOpts$extraBabe,
78
- _bundleOpts$extraBabe2 = bundleOpts.extraBabelPlugins,
79
- extraBabelPlugins = _bundleOpts$extraBabe2 === void 0 ? [] : _bundleOpts$extraBabe2,
80
- _bundleOpts$extraRoll = bundleOpts.extraRollupPlugins,
81
- extraRollupPlugins = _bundleOpts$extraRoll === void 0 ? [] : _bundleOpts$extraRoll,
82
- autoprefixerOpts = bundleOpts.autoprefixer,
83
- _bundleOpts$include = bundleOpts.include,
84
- include = _bundleOpts$include === void 0 ? /node_modules/ : _bundleOpts$include,
85
- runtimeHelpersOpts = bundleOpts.runtimeHelpers,
86
- replaceOpts = bundleOpts.replace,
87
- injectOpts = bundleOpts.inject,
88
- _bundleOpts$extraExte = bundleOpts.extraExternals,
89
- extraExternals = _bundleOpts$extraExte === void 0 ? [] : _bundleOpts$extraExte,
90
- _bundleOpts$externals = bundleOpts.externalsExclude,
91
- externalsExclude = _bundleOpts$externals === void 0 ? [] : _bundleOpts$externals,
92
- nodeVersion = bundleOpts.nodeVersion,
93
- typescriptOpts = bundleOpts.typescriptOpts,
94
- _bundleOpts$nodeResol = bundleOpts.nodeResolveOpts,
95
- nodeResolveOpts = _bundleOpts$nodeResol === void 0 ? {} : _bundleOpts$nodeResol,
96
- disableTypeCheck = bundleOpts.disableTypeCheck,
97
- _bundleOpts$lessInRol = bundleOpts.lessInRollupMode,
98
- lessInRollupMode = _bundleOpts$lessInRol === void 0 ? {} : _bundleOpts$lessInRol,
99
- _bundleOpts$sassInRol = bundleOpts.sassInRollupMode,
100
- sassInRollupMode = _bundleOpts$sassInRol === void 0 ? {} : _bundleOpts$sassInRol;
41
+ esm = bundleOpts.esm,
42
+ cjs = bundleOpts.cjs,
43
+ file = bundleOpts.file,
44
+ _bundleOpts$target = bundleOpts.target,
45
+ target = _bundleOpts$target === void 0 ? 'browser' : _bundleOpts$target,
46
+ _bundleOpts$extractCS = bundleOpts.extractCSS,
47
+ extractCSS = _bundleOpts$extractCS === void 0 ? false : _bundleOpts$extractCS,
48
+ _bundleOpts$injectCSS = bundleOpts.injectCSS,
49
+ injectCSS = _bundleOpts$injectCSS === void 0 ? true : _bundleOpts$injectCSS,
50
+ modules = bundleOpts.cssModules,
51
+ _bundleOpts$extraPost = bundleOpts.extraPostCSSPlugins,
52
+ extraPostCSSPlugins = _bundleOpts$extraPost === void 0 ? [] : _bundleOpts$extraPost,
53
+ _bundleOpts$extraBabe = bundleOpts.extraBabelPresets,
54
+ extraBabelPresets = _bundleOpts$extraBabe === void 0 ? [] : _bundleOpts$extraBabe,
55
+ _bundleOpts$extraBabe2 = bundleOpts.extraBabelPlugins,
56
+ extraBabelPlugins = _bundleOpts$extraBabe2 === void 0 ? [] : _bundleOpts$extraBabe2,
57
+ _bundleOpts$extraRoll = bundleOpts.extraRollupPlugins,
58
+ extraRollupPlugins = _bundleOpts$extraRoll === void 0 ? [] : _bundleOpts$extraRoll,
59
+ autoprefixerOpts = bundleOpts.autoprefixer,
60
+ _bundleOpts$include = bundleOpts.include,
61
+ include = _bundleOpts$include === void 0 ? /node_modules/ : _bundleOpts$include,
62
+ runtimeHelpersOpts = bundleOpts.runtimeHelpers,
63
+ replaceOpts = bundleOpts.replace,
64
+ injectOpts = bundleOpts.inject,
65
+ _bundleOpts$extraExte = bundleOpts.extraExternals,
66
+ extraExternals = _bundleOpts$extraExte === void 0 ? [] : _bundleOpts$extraExte,
67
+ _bundleOpts$externals = bundleOpts.externalsExclude,
68
+ externalsExclude = _bundleOpts$externals === void 0 ? [] : _bundleOpts$externals,
69
+ nodeVersion = bundleOpts.nodeVersion,
70
+ typescriptOpts = bundleOpts.typescriptOpts,
71
+ _bundleOpts$nodeResol = bundleOpts.nodeResolveOpts,
72
+ nodeResolveOpts = _bundleOpts$nodeResol === void 0 ? {} : _bundleOpts$nodeResol,
73
+ disableTypeCheck = bundleOpts.disableTypeCheck,
74
+ _bundleOpts$lessInRol = bundleOpts.lessInRollupMode,
75
+ lessInRollupMode = _bundleOpts$lessInRol === void 0 ? {} : _bundleOpts$lessInRol,
76
+ _bundleOpts$sassInRol = bundleOpts.sassInRollupMode,
77
+ sassInRollupMode = _bundleOpts$sassInRol === void 0 ? {} : _bundleOpts$sassInRol;
101
78
  const entryExt = (0, _path.extname)(entry);
102
79
  const name = file || (0, _path.basename)(entry, entryExt);
103
80
  const isTypeScript = entryExt === '.ts' || entryExt === '.tsx';
104
81
  const extensions = ['.js', '.jsx', '.ts', '.tsx', '.es6', '.es', '.mjs'];
105
82
  let pkg = {};
106
-
107
83
  try {
108
84
  pkg = require((0, _path.join)(cwd, 'package.json')); // eslint-disable-line
109
- } catch (e) {} // cjs 不给浏览器用,所以无需 runtimeHelpers
110
-
85
+ } catch (e) {}
111
86
 
87
+ // cjs 不给浏览器用,所以无需 runtimeHelpers
112
88
  const runtimeHelpers = type === 'cjs' ? false : runtimeHelpersOpts;
113
-
114
89
  const babelOpts = _objectSpread(_objectSpread({}, (0, _getBabelConfig.default)({
115
90
  type,
116
91
  target: type === 'esm' ? 'browser' : target,
@@ -124,54 +99,49 @@ function _default(opts) {
124
99
  babelHelpers: runtimeHelpers ? 'runtime' : 'bundled',
125
100
  // exclude: /\/node_modules\//,
126
101
  filter: filePath => {
127
- const rollupFilter = (0, _pluginutils.createFilter)(null, /\/node_modules\//); // 默认过滤 node_modules
128
-
102
+ const rollupFilter = (0, _pluginutils.createFilter)(null, /\/node_modules\//);
103
+ // 默认过滤 node_modules
129
104
  if (!rollupFilter(filePath)) {
130
105
  const pkgPath = (0, _es5ImcompatibleVersions.getPkgPath)(filePath);
131
106
  return (0, _es5ImcompatibleVersions.shouldTransform)(pkgPath);
132
107
  }
133
-
134
108
  return true;
135
109
  },
136
110
  babelrc: false,
137
111
  // ref: https://github.com/rollup/rollup-plugin-babel#usage
138
112
  extensions
139
113
  });
140
-
141
114
  if (importLibToEs && type === 'esm') {
142
115
  babelOpts.plugins.push(require.resolve('../lib/importLibToEs'));
143
116
  }
144
-
145
117
  babelOpts.presets.push(...extraBabelPresets);
146
- babelOpts.plugins.push(...extraBabelPlugins); // rollup configs
118
+ babelOpts.plugins.push(...extraBabelPlugins);
147
119
 
120
+ // rollup configs
148
121
  const input = (0, _path.join)(cwd, entry);
149
- const format = type; // ref: https://rollupjs.org/guide/en#external
122
+ const format = type;
123
+
124
+ // ref: https://rollupjs.org/guide/en#external
150
125
  // 潜在问题:引用包的子文件时会报 warning,比如 @babel/runtime/helpers/esm/createClass
151
126
  // 解决方案:可以用 function 处理
152
-
153
- const external = [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {}), ...extraExternals]; // umd 只要 external peerDependencies
154
-
127
+ const external = [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {}), ...extraExternals];
128
+ // umd 只要 external peerDependencies
155
129
  const externalPeerDeps = [...Object.keys(pkg.peerDependencies || {}), ...extraExternals];
156
-
157
130
  function getPkgNameByid(id) {
158
- const splitted = id.split('/'); // @ 和 @tmp 是为了兼容 umi 的逻辑
159
-
131
+ const splitted = id.split('/');
132
+ // @ 和 @tmp 是为了兼容 umi 的逻辑
160
133
  if (id.charAt(0) === '@' && splitted[0] !== '@' && splitted[0] !== '@tmp') {
161
134
  return splitted.slice(0, 2).join('/');
162
135
  } else {
163
136
  return id.split('/')[0];
164
137
  }
165
138
  }
166
-
167
139
  function testExternal(pkgs, excludes, id) {
168
140
  if (excludes.includes(id)) {
169
141
  return false;
170
142
  }
171
-
172
143
  return pkgs.includes(getPkgNameByid(id));
173
144
  }
174
-
175
145
  const terserOpts = {
176
146
  compress: {
177
147
  pure_getters: true,
@@ -179,8 +149,9 @@ function _default(opts) {
179
149
  unsafe_comps: true,
180
150
  warnings: false
181
151
  }
182
- }; // https://github.com/umijs/father/issues/164
152
+ };
183
153
 
154
+ // https://github.com/umijs/father/issues/164
184
155
  function mergePlugins(defaultRollupPlugins = [], extraRollupPlugins = []) {
185
156
  const pluginsMap = Object.assign(defaultRollupPlugins.reduce((r, plugin) => _objectSpread(_objectSpread({}, r), {}, {
186
157
  [plugin.name]: plugin
@@ -189,7 +160,6 @@ function _default(opts) {
189
160
  }), {}));
190
161
  return Object.values(pluginsMap);
191
162
  }
192
-
193
163
  function getPlugins(opts = {}) {
194
164
  const minCSS = opts.minCSS;
195
165
  const defaultRollupPlugins = [(0, _pluginUrl.default)(), (0, _rollup.default)(), (0, _rollupPluginPostcss.default)(_objectSpread(_objectSpread({
@@ -241,7 +211,6 @@ function _default(opts) {
241
211
  }, typescriptOpts || {}))] : []), (0, _pluginBabel.default)(babelOpts), (0, _pluginJson.default)()];
242
212
  return mergePlugins(defaultRollupPlugins, extraRollupPlugins || []);
243
213
  }
244
-
245
214
  switch (type) {
246
215
  case 'esm':
247
216
  const output = {
@@ -266,7 +235,6 @@ function _default(opts) {
266
235
  }), (0, _rollupPluginTerser.terser)(terserOpts)],
267
236
  external: testExternal.bind(null, externalPeerDeps, externalsExclude)
268
237
  }] : [])];
269
-
270
238
  case 'cjs':
271
239
  return [{
272
240
  input,
@@ -277,13 +245,13 @@ function _default(opts) {
277
245
  plugins: [...getPlugins(), ...(cjs && cjs.minify ? [(0, _rollupPluginTerser.terser)(terserOpts)] : [])],
278
246
  external: testExternal.bind(null, external, externalsExclude)
279
247
  }];
280
-
281
248
  case 'umd':
282
249
  // Add umd related plugins
283
250
  const extraUmdPlugins = [(0, _pluginCommonjs.default)({
284
- include // namedExports options has been remove from https://github.com/rollup/plugins/pull/149
285
-
251
+ include
252
+ // namedExports options has been remove from https://github.com/rollup/plugins/pull/149
286
253
  })];
254
+
287
255
  return [{
288
256
  input,
289
257
  output: {
@@ -313,7 +281,6 @@ function _default(opts) {
313
281
  }), (0, _rollupPluginTerser.terser)(terserOpts)],
314
282
  external: testExternal.bind(null, externalPeerDeps, externalsExclude)
315
283
  }])];
316
-
317
284
  default:
318
285
  throw new Error(`Unsupported type ${type}`);
319
286
  }
@@ -5,33 +5,22 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.CONFIG_FILES = void 0;
7
7
  exports.default = _default;
8
-
9
8
  var _ajv = _interopRequireDefault(require("ajv"));
10
-
11
9
  var _fs = require("fs");
12
-
13
10
  var _path = require("path");
14
-
15
11
  var _signale = _interopRequireDefault(require("signale"));
16
-
17
12
  var _slash = _interopRequireDefault(require("slash2"));
18
-
19
13
  var _schema = _interopRequireDefault(require("./schema"));
20
-
21
14
  var _utils = require("./utils");
22
-
23
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
-
25
16
  function testDefault(obj) {
26
17
  return obj.default || obj;
27
18
  }
28
-
29
19
  const CONFIG_FILES = ['.buildrc.js', '.buildrc.jsx', '.buildrc.ts', '.buildrc.tsx', '.fatherrc.js', '.fatherrc.jsx', '.fatherrc.ts', '.fatherrc.tsx', '.umirc.library.js', '.umirc.library.jsx', '.umirc.library.ts', '.umirc.library.tsx'];
30
20
  exports.CONFIG_FILES = CONFIG_FILES;
31
21
  const CLASSES = {
32
22
  Function: Function
33
23
  };
34
-
35
24
  const extendAjv = ajv => {
36
25
  ajv.addKeyword('instanceof', {
37
26
  compile: function compile(schema) {
@@ -43,41 +32,33 @@ const extendAjv = ajv => {
43
32
  });
44
33
  return ajv;
45
34
  };
46
-
47
35
  function _default({
48
36
  cwd,
49
37
  customPath
50
38
  }) {
51
39
  let finalPath = '';
52
-
53
40
  if (customPath) {
54
41
  finalPath = (0, _path.isAbsolute)(customPath) ? customPath : (0, _path.resolve)(process.cwd(), customPath);
55
-
56
42
  if (!(0, _fs.existsSync)(finalPath)) {
57
43
  throw new Error(`can\'t found config file: ${customPath}`);
58
44
  }
59
45
  }
60
-
61
46
  const configFile = finalPath || (0, _utils.getExistFile)({
62
47
  cwd,
63
48
  files: CONFIG_FILES,
64
49
  returnRelative: false
65
50
  });
66
-
67
51
  if (configFile) {
68
52
  if (configFile.includes('.umirc.library.')) {
69
53
  _signale.default.warn(`.umirc.library.js is deprecated, please use .fatherrc.js instead.`);
70
54
  }
71
-
72
55
  const userConfig = testDefault(require(configFile)); // eslint-disable-line
73
-
74
56
  const userConfigs = Array.isArray(userConfig) ? userConfig : [userConfig];
75
57
  userConfigs.forEach(userConfig => {
76
58
  const ajv = extendAjv(new _ajv.default({
77
59
  allErrors: true
78
60
  }));
79
61
  const isValid = ajv.validate(_schema.default, userConfig);
80
-
81
62
  if (!isValid) {
82
63
  const errors = ajv.errors.map(({
83
64
  dataPath,
@@ -4,27 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _path = require("path");
9
-
10
8
  var _fs = _interopRequireDefault(require("fs"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  const cwd = process.cwd();
15
-
16
11
  function replacePath(path) {
17
12
  if (path.node.source && /\/lib\//.test(path.node.source.value)) {
18
13
  const esModule = path.node.source.value.replace('/lib/', '/es/');
19
14
  const esPath = (0, _path.dirname)((0, _path.join)(cwd, `node_modules/${esModule}`));
20
-
21
15
  if (_fs.default.existsSync(esPath)) {
22
16
  console.log(`[es build] replace ${path.node.source.value} with ${esModule}`);
23
17
  path.node.source.value = esModule;
24
18
  }
25
19
  }
26
20
  }
27
-
28
21
  function replaceLib() {
29
22
  return {
30
23
  visitor: {
@@ -33,6 +26,5 @@ function replaceLib() {
33
26
  }
34
27
  };
35
28
  }
36
-
37
29
  var _default = replaceLib;
38
30
  exports.default = _default;
package/lib/index.js CHANGED
@@ -4,10 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _build = _interopRequireDefault(require("./build"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  var _default = _build.default;
13
10
  exports.default = _default;
@@ -4,32 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = _default;
7
-
8
7
  var _lodash = require("lodash");
9
-
10
8
  function stripDotSlashPrefix(path) {
11
9
  return path.replace(/^\.\//, '');
12
10
  }
13
-
14
11
  function _default(entry, opts) {
15
12
  let clone = (0, _lodash.cloneDeep)(opts);
16
13
  const stripedEntry = stripDotSlashPrefix(entry);
17
-
18
14
  if (clone.overridesByEntry) {
19
15
  Object.keys(clone.overridesByEntry).forEach(key => {
20
16
  const stripedKey = stripDotSlashPrefix(key);
21
-
22
17
  if (stripedKey !== key) {
23
18
  clone.overridesByEntry[stripedKey] = clone.overridesByEntry[key];
24
19
  }
25
20
  });
26
-
27
21
  if (clone.overridesByEntry[stripedEntry]) {
28
22
  clone = (0, _lodash.merge)(clone, clone.overridesByEntry[stripedEntry]);
29
23
  }
30
-
31
24
  delete clone.overridesByEntry;
32
25
  }
33
-
34
26
  return clone;
35
27
  }
@@ -4,29 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = _default;
7
-
8
7
  var _chalk = _interopRequireDefault(require("chalk"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  const colors = ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'gray', 'redBright', 'greenBright', 'yellowBright', 'blueBright', 'magentaBright', 'cyanBright'];
13
10
  let index = 0;
14
11
  const cache = {};
15
-
16
12
  function _default(pkg) {
17
13
  if (!cache[pkg]) {
18
14
  const color = colors[index];
19
-
20
15
  let str = _chalk.default[color].bold(pkg);
21
-
22
16
  cache[pkg] = str;
23
-
24
17
  if (index === colors.length - 1) {
25
18
  index = 0;
26
19
  } else {
27
20
  index += 1;
28
21
  }
29
22
  }
30
-
31
23
  return cache[pkg];
32
24
  }
@@ -4,31 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = _default;
7
-
8
7
  var _path = require("path");
9
-
10
8
  var _slash = _interopRequireDefault(require("slash2"));
11
-
12
9
  var _getBabelConfig2 = _interopRequireDefault(require("./getBabelConfig"));
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  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; }
17
-
18
12
  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; }
19
-
20
- 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; }
21
-
13
+ 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; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
15
+ 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); }
22
16
  function _default(opts) {
23
17
  const cwd = opts.cwd,
24
- only = opts.only;
25
-
18
+ only = opts.only;
26
19
  const _getBabelConfig = (0, _getBabelConfig2.default)({
27
- target: 'node',
28
- typescript: true
29
- }),
30
- babelConfig = _getBabelConfig.opts;
31
-
20
+ target: 'node',
21
+ typescript: true
22
+ }),
23
+ babelConfig = _getBabelConfig.opts;
32
24
  require('@babel/register')(_objectSpread(_objectSpread({}, babelConfig), {}, {
33
25
  extensions: ['.es6', '.es', '.jsx', '.js', '.mjs', '.ts', '.tsx'],
34
26
  only: only.map(file => (0, _slash.default)((0, _path.isAbsolute)(file) ? file : (0, _path.join)(cwd, file))),