@zohodesk/react-cli 1.1.22-exp.4 → 1.1.22-exp.5

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.
@@ -13,13 +13,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
13
13
 
14
14
  const {
15
15
  module: {
16
- mode,
17
- alias
16
+ mode
18
17
  },
19
18
  babelCustomizationForLibrary: {
20
19
  babelPlugins
21
20
  },
22
- enableTypeScript
21
+ enableTypeScript,
22
+ alias
23
23
  } = (0, _utils.getOptions)();
24
24
  const isProd = mode.toLowerCase() === 'prod';
25
25
  const defaultPlugins = [[require.resolve('babel-plugin-transform-define'), isProd ? {
@@ -14,13 +14,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
14
14
  const {
15
15
  module: {
16
16
  mode,
17
- disableES5Transpile,
18
- alias
17
+ disableES5Transpile
19
18
  },
20
19
  babelCustomizationForLibrary: {
21
20
  babelPlugins
22
21
  },
23
- enableTypeScript
22
+ enableTypeScript,
23
+ alias
24
24
  } = (0, _utils.getOptions)();
25
25
  const isProd = mode.toLowerCase() === 'prod';
26
26
  const defaultPlugins = [[require.resolve('babel-plugin-transform-define'), isProd ? {
@@ -3,12 +3,45 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.aliasPathCreation = aliasPathCreation;
6
7
  exports.libAlias = exports.jestModuleNameMapper = void 0;
8
+
9
+ var _utils = require("../utils");
10
+
11
+ var _path = _interopRequireDefault(require("path"));
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
7
15
  // the reason for alias at the time was code tree shaking
8
16
  // tree shaking was most compactable with ES module system
9
17
  // FIXME: But there is a posiblity when these package does not have lib,
10
18
  // app will work because of alias, But may be jest won't work because of not alais
11
19
  // So need to think about use alais in jest
20
+ const appPath = process.cwd();
21
+ const {
22
+ alias,
23
+ app
24
+ } = (0, _utils.getOptions)();
25
+ const {
26
+ disableES5Transpile
27
+ } = app;
28
+
29
+ function aliasPathCreation(customAlias) {
30
+ if (customAlias == null) {
31
+ return {};
32
+ }
33
+
34
+ const newAlias = {};
35
+ Object.keys(customAlias).forEach(key => {
36
+ if (customAlias[key].startsWith('.')) {
37
+ newAlias[key] = _path.default.resolve(appPath, customAlias[key]);
38
+ } else {
39
+ newAlias[key] = customAlias[key];
40
+ }
41
+ });
42
+ return newAlias;
43
+ }
44
+
12
45
  const libAlias = {
13
46
  '@zohodesk/components/lib': '@zohodesk/components/es',
14
47
  // '@zohodesk/zc-custom/lib': '@zohodesk/zc-custom/es',
@@ -31,8 +64,9 @@ const libAlias = {
31
64
  // '^@components(.*)$': '<rootDir>/src/components$1',
32
65
 
33
66
  exports.libAlias = libAlias;
34
- const jestModuleNameMapper = Object.keys(libAlias).reduce((previousValue, key) => {
35
- previousValue[`^${key}(.*)$`] = `${libAlias[key]}$1`;
67
+ const totalAlias = disableES5Transpile ? Object.assign({}, libAlias, aliasPathCreation(alias)) : aliasPathCreation(alias);
68
+ const jestModuleNameMapper = Object.keys(totalAlias).reduce((previousValue, key) => {
69
+ previousValue[`^${key}(.*)$`] = `${totalAlias[key]}$1`;
36
70
  return previousValue;
37
71
  }, {});
38
72
  exports.jestModuleNameMapper = jestModuleNameMapper;
@@ -21,7 +21,7 @@ function moduleResolver(options) {
21
21
  moduleResolvePath,
22
22
  disableES5Transpile
23
23
  } = options.app;
24
- const customAlias = options.app.alias;
24
+ const customAlias = options.alias;
25
25
  let required = moduleResolvePath && (0, _requireLocalOrGlobal.requireLocal)(moduleResolvePath);
26
26
 
27
27
  if (!required) {
@@ -33,11 +33,11 @@ function moduleResolver(options) {
33
33
  }
34
34
 
35
35
  const nodeModulesPath = required ? required.nodeModulesPath : _client_packages_group.nodeModulesPath;
36
- const totalAlias = Object.assign({}, _libAlias.libAlias, customAlias);
36
+ const totalAlias = disableES5Transpile ? Object.assign({}, _libAlias.libAlias, (0, _libAlias.aliasPathCreation)(customAlias)) : (0, _libAlias.aliasPathCreation)(customAlias);
37
37
  return {
38
38
  extensions: ['.js', '.jsx', '.ts', '.tsx'],
39
39
  modules: [nodeModulesPath, _constants.cliNodeModulesPath, 'node_modules'].filter(Boolean),
40
- alias: disableES5Transpile ? totalAlias : {} // alias: { ...libAlias, ...clientDependenies }
40
+ alias: totalAlias // alias: { ...libAlias, ...clientDependenies }
41
41
 
42
42
  };
43
43
  }
@@ -15,6 +15,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
15
15
 
16
16
  // TODO move deprecated options to separate file and manage seperately
17
17
  var _default = {
18
+ alias: null,
18
19
  unstableDepsInverse: {
19
20
  value: false,
20
21
  cli: 'unstable_deps_inverse'
@@ -125,7 +126,6 @@ var _default = {
125
126
  cssDirStatement: null
126
127
  },
127
128
  app: {
128
- alias: null,
129
129
  moduleResolvePath: {
130
130
  value: '@zohodesk/client_packages_group',
131
131
  cli: 'module_resolve_path'
@@ -729,8 +729,7 @@ var _default = {
729
729
  value: 'prod',
730
730
  cli: 'module_mode'
731
731
  },
732
- disableES5Transpile: true,
733
- alias: null
732
+ disableES5Transpile: true
734
733
  },
735
734
  stats: {
736
735
  enable: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/react-cli",
3
- "version": "1.1.22-exp.4",
3
+ "version": "1.1.22-exp.5",
4
4
  "description": "A CLI tool for build modern web application and libraries",
5
5
  "scripts": {
6
6
  "init": "node ./lib/utils/init.js",