@zimbra/zimlet-cli 12.13.0 → 13.0.0

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.
Files changed (45) hide show
  1. package/.browserslistrc +1 -0
  2. package/dist/cli.js +11 -17
  3. package/dist/commands/create.js +206 -324
  4. package/dist/commands/package.js +62 -90
  5. package/dist/entry.js +14 -12
  6. package/dist/index.js +89 -114
  7. package/dist/lib/async-command.js +8 -14
  8. package/dist/lib/setup.js +55 -133
  9. package/dist/lib/webpack/transform-config.js +8 -8
  10. package/dist/shims/@apollo/client/index.js +92 -82
  11. package/dist/shims/@apollo/client/react/components/index.js +6 -6
  12. package/dist/shims/@apollo/client/react/hoc/index.js +8 -8
  13. package/dist/shims/@apollo/client/react/index.js +16 -16
  14. package/dist/shims/@zimbra-client/blocks/index.js +28 -28
  15. package/dist/shims/@zimbra-client/browser/index.js +4 -4
  16. package/dist/shims/@zimbra-client/components/index.js +51 -51
  17. package/dist/shims/@zimbra-client/constants/index.js +7 -7
  18. package/dist/shims/@zimbra-client/enhancers/index.js +10 -10
  19. package/dist/shims/@zimbra-client/errors/index.js +5 -5
  20. package/dist/shims/@zimbra-client/graphql/index.js +29 -29
  21. package/dist/shims/@zimbra-client/hooks/graphql/index.js +8 -8
  22. package/dist/shims/@zimbra-client/hooks/index.js +8 -8
  23. package/dist/shims/@zimbra-client/platform/index.js +5 -5
  24. package/dist/shims/@zimbra-client/util/contacts/index.js +4 -4
  25. package/dist/shims/@zimbra-client/util/index.js +13 -13
  26. package/dist/shims/@zimbra-client/util/redux/index.js +8 -8
  27. package/dist/shims/clipboard-polyfill/index.js +4 -4
  28. package/dist/shims/index.js +2 -2
  29. package/dist/shims/moment/index.js +43 -43
  30. package/dist/shims/preact/compat/index.js +40 -52
  31. package/dist/shims/preact/hooks/index.js +14 -14
  32. package/dist/shims/preact/index.js +15 -15
  33. package/dist/shims/preact-context-provider/index.js +6 -6
  34. package/dist/shims/preact-i18n/index.js +12 -12
  35. package/dist/shims/preact-pwa-install/index.js +3 -3
  36. package/dist/shims/preact-render-to-string/index.js +5 -5
  37. package/dist/shims/preact-router/index.js +9 -9
  38. package/dist/shims/preact-router/match/index.js +4 -4
  39. package/dist/shims/react-redux/index.js +16 -16
  40. package/dist/shims/recompose/index.js +46 -46
  41. package/dist/shims/redux-actions/index.js +9 -9
  42. package/dist/util.js +11 -11
  43. package/dist/zimlet-style-loader.js +8 -4
  44. package/package-lock.json +6399 -6925
  45. package/package.json +41 -44
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
6
+ exports.default = void 0;
7
7
 
8
8
  var _fs = _interopRequireDefault(require("fs"));
9
9
 
@@ -15,13 +15,9 @@ var _util = require("../util");
15
15
 
16
16
  var _asyncCommand = _interopRequireDefault(require("../lib/async-command"));
17
17
 
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
- 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); } }
21
-
22
- 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); }); }; }
23
-
24
- var _default = (0, _asyncCommand["default"])({
20
+ var _default = (0, _asyncCommand.default)({
25
21
  command: 'package',
26
22
  desc: 'Package a zimlet for deployment',
27
23
  builder: {
@@ -51,12 +47,12 @@ var _default = (0, _asyncCommand["default"])({
51
47
  },
52
48
  zimbraXVersion: {
53
49
  description: 'https://semver.org version range of Zimbra X that the Zimlet is compatible with.',
54
- "default": '>=1.0.0',
50
+ default: '>=1.0.0',
55
51
  requiresArg: true
56
52
  },
57
53
  builddir: {
58
54
  alias: 'b',
59
- "default": './build',
55
+ default: './build',
60
56
  description: 'Source directory of built artifacts to publish'
61
57
  },
62
58
  dest: {
@@ -65,88 +61,64 @@ var _default = (0, _asyncCommand["default"])({
65
61
  description: 'Directory for packaged artifacts'
66
62
  }
67
63
  },
68
- handler: function handler(argv) {
69
- return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
70
- var cwd, builddir, dest, xmlFile, zimletXML, files, propertiesFile, zimletProperties, zipFile;
71
- return regeneratorRuntime.wrap(function _callee$(_context) {
72
- while (1) {
73
- switch (_context.prev = _context.next) {
74
- case 0:
75
- // normalize built files source directory and desination package dir
76
- cwd = process.cwd();
77
- builddir = _path["default"].resolve(cwd, argv.builddir || 'build');
78
- dest = _path["default"].resolve(cwd, argv.dest || 'pkg', "".concat(argv.name, ".zip")); // Create the xml descriptor file for the zimlet
79
-
80
- xmlFile = "".concat(argv.name, ".xml");
81
- zimletXML = "<zimlet name=\"".concat(argv.name, "\" version=\"").concat(argv.pkgVersion, "\" description=\"").concat(argv.description, "\" label=\"").concat(argv.label, "\" zimbraXZimletCompatibleSemVer=\"").concat(argv.zimbraXVersion, "\">");
82
- _context.prev = 5;
83
- files = _fs["default"].readdirSync(builddir);
84
- _context.next = 12;
85
- break;
86
-
87
- case 9:
88
- _context.prev = 9;
89
- _context.t0 = _context["catch"](5);
90
- return _context.abrupt("return", (0, _util.error)("Failed to read ".concat(builddir, ": ").concat(_context.t0), 1));
91
-
92
- case 12:
93
- files.forEach(function (file) {
94
- if (file.match(/\.js$/)) {
95
- zimletXML += "\n\t<include>".concat(file, "</include>");
96
- } else if (file.match(/\.css$/)) {
97
- zimletXML += "\n\t<includeCSS>".concat(file, "</includeCSS>");
98
- } else if (file !== xmlFile) {
99
- zimletXML += "\n\t<resource>".concat(file, "</resource>");
100
- }
101
- });
102
- zimletXML += '\n</zimlet>';
103
- _context.prev = 14;
104
-
105
- _fs["default"].writeFileSync(_path["default"].resolve(builddir, xmlFile), zimletXML);
106
-
107
- _context.next = 21;
108
- break;
109
-
110
- case 18:
111
- _context.prev = 18;
112
- _context.t1 = _context["catch"](14);
113
- return _context.abrupt("return", (0, _util.error)("Failed to write XML file: ".concat(_context.t1), 1));
114
-
115
- case 21:
116
- // Add properties file for description and label
117
- // As admin console requires properties file to display label and desciption
118
- propertiesFile = "".concat(argv.name, ".properties");
119
- zimletProperties = '\n';
120
- zimletProperties += "label = ".concat(argv.label, "\n");
121
- zimletProperties += "description = ".concat(argv.description, "\n");
122
- _context.prev = 25;
123
-
124
- _fs["default"].writeFileSync(_path["default"].resolve(builddir, propertiesFile), zimletProperties);
125
-
126
- _context.next = 32;
127
- break;
128
-
129
- case 29:
130
- _context.prev = 29;
131
- _context.t2 = _context["catch"](25);
132
- return _context.abrupt("return", (0, _util.error)("Failed to write properties file: ".concat(_context.t2), 1));
133
-
134
- case 32:
135
- //Zip up the contents of the build dir along with the xml file as the final zimlet deliverable
136
- zipFile = new _admZip["default"]();
137
- zipFile.addLocalFolder(builddir, '');
138
- zipFile.writeZip(dest);
139
- return _context.abrupt("return", "Successfully packaged zimlet to: ".concat(dest, "\n"));
140
-
141
- case 36:
142
- case "end":
143
- return _context.stop();
144
- }
145
- }
146
- }, _callee, null, [[5, 9], [14, 18], [25, 29]]);
147
- }))();
64
+
65
+ async handler(argv) {
66
+ // normalize built files source directory and desination package dir
67
+ let cwd = process.cwd();
68
+
69
+ let builddir = _path.default.resolve(cwd, argv.builddir || 'build');
70
+
71
+ let dest = _path.default.resolve(cwd, argv.dest || 'pkg', `${argv.name}.zip`); // Create the xml descriptor file for the zimlet
72
+
73
+
74
+ let xmlFile = `${argv.name}.xml`;
75
+ let zimletXML = `<zimlet name="${argv.name}" version="${argv.pkgVersion}" description="${argv.description}" label="${argv.label}" zimbraXZimletCompatibleSemVer="${argv.zimbraXVersion}">`;
76
+ let files;
77
+
78
+ try {
79
+ files = _fs.default.readdirSync(builddir);
80
+ } catch (err) {
81
+ return (0, _util.error)(`Failed to read ${builddir}: ${err}`, 1);
82
+ }
83
+
84
+ files.forEach(file => {
85
+ if (file.match(/\.js$/)) {
86
+ zimletXML += `\n\t<include>${file}</include>`;
87
+ } else if (file.match(/\.css$/)) {
88
+ zimletXML += `\n\t<includeCSS>${file}</includeCSS>`;
89
+ } else if (file !== xmlFile) {
90
+ zimletXML += `\n\t<resource>${file}</resource>`;
91
+ }
92
+ });
93
+ zimletXML += '\n</zimlet>';
94
+
95
+ try {
96
+ _fs.default.writeFileSync(_path.default.resolve(builddir, xmlFile), zimletXML);
97
+ } catch (err) {
98
+ return (0, _util.error)(`Failed to write XML file: ${err}`, 1);
99
+ } // Add properties file for description and label
100
+ // As admin console requires properties file to display label and desciption
101
+
102
+
103
+ let propertiesFile = `${argv.name}.properties`;
104
+ let zimletProperties = '\n';
105
+ zimletProperties += `label = ${argv.label}\n`;
106
+ zimletProperties += `description = ${argv.description}\n`;
107
+
108
+ try {
109
+ _fs.default.writeFileSync(_path.default.resolve(builddir, propertiesFile), zimletProperties);
110
+ } catch (err) {
111
+ return (0, _util.error)(`Failed to write properties file: ${err}`, 1);
112
+ } //Zip up the contents of the build dir along with the xml file as the final zimlet deliverable
113
+
114
+
115
+ let zipFile = new _admZip.default();
116
+ zipFile.addLocalFolder(builddir, '');
117
+ zipFile.writeZip(dest);
118
+ return `Successfully packaged zimlet to: ${dest}\n`;
148
119
  }
120
+
149
121
  });
150
122
 
151
- exports["default"] = _default;
123
+ exports.default = _default;
152
124
  module.exports = exports.default;
package/dist/entry.js CHANGED
@@ -3,16 +3,18 @@
3
3
  /** This is the real webpack entry file. It manages setting up the zimlet and HMR.
4
4
  * The user-defined entry file (index.js) is imported here via a `zimlet-cli-entrypoint` alias.
5
5
  */
6
- (function () {
6
+ (() => {
7
7
  function init() {
8
- zimlet(function (context) {
9
- var zimbra = context.zimbra,
10
- config = context.config,
11
- plugins = context.plugins,
12
- shims = context.shims,
13
- components = context.components,
14
- store = context.store,
15
- meta = context.meta; // Add shims to the global scope to expose dependencies to Zimlets
8
+ zimlet(context => {
9
+ let {
10
+ zimbra,
11
+ config,
12
+ plugins,
13
+ shims,
14
+ components,
15
+ store,
16
+ meta
17
+ } = context; // Add shims to the global scope to expose dependencies to Zimlets
16
18
  // Shimmed dependencies include preact, preact-router, react-apollo
17
19
 
18
20
  global.shims = shims;
@@ -24,11 +26,11 @@
24
26
  global.ZIMLET_STYLES = [];
25
27
  global.meta = meta;
26
28
 
27
- var entry = require('zimlet-cli-entrypoint');
29
+ let entry = require('zimlet-cli-entrypoint');
28
30
 
29
- var r = entry && entry["default"] || entry; // If export is a factory, pass it context. Otherwise it's a singleton.
31
+ let r = entry && entry.default || entry; // If export is a factory, pass it context. Otherwise it's a singleton.
30
32
 
31
- var instance = typeof r === 'function' ? r(context) : r;
33
+ let instance = typeof r === 'function' ? r(context) : r;
32
34
  context.styles.set(global.ZIMLET_STYLES.join('\n'));
33
35
  return instance;
34
36
  });
package/dist/index.js CHANGED
@@ -1,13 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
 
4
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
5
-
6
4
  Object.defineProperty(exports, "__esModule", {
7
5
  value: true
8
6
  });
9
- exports["default"] = run;
10
7
  exports.configure = configure;
8
+ exports.default = run;
11
9
 
12
10
  var _fs = _interopRequireDefault(require("fs"));
13
11
 
@@ -37,90 +35,69 @@ var _shims = require("./shims");
37
35
 
38
36
  var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
39
37
 
40
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
41
-
42
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
43
-
44
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
45
-
46
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
47
-
48
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
49
-
50
- 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); }
51
-
52
- 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; }
53
-
54
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
55
-
56
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
38
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
57
39
 
58
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
40
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
59
41
 
60
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
61
-
62
- 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; }
42
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
63
43
 
64
44
  function run(args, callback) {
65
- var config = configure(args);
66
- var compiler = (0, _webpack["default"])(config);
67
- var preferredPort = config.devServer && +config.devServer.port;
68
- compiler.hooks.failed.tap('zimlet-cli', function (err) {
45
+ let config = configure(args);
46
+ let compiler = (0, _webpack.default)(config);
47
+ const preferredPort = config.devServer && +config.devServer.port;
48
+ compiler.hooks.failed.tap('zimlet-cli', err => {
69
49
  console.error(err.stack || err);
70
50
  if (err.details) console.error(err.details);
71
51
  });
72
- compiler.hooks.done.tap('zimlet-cli', function (stats) {
73
- var info = stats.toJson();
52
+ compiler.hooks.done.tap('zimlet-cli', stats => {
53
+ let info = stats.toJson();
74
54
 
75
55
  if (stats.hasErrors()) {
76
- process.stdout.write(_chalk["default"].red('Build failed!\n\n'));
77
- info.errors.forEach(function (err) {
78
- return console.error(err);
79
- });
56
+ process.stdout.write(_chalk.default.red('Build failed!\n\n'));
57
+ info.errors.forEach(err => console.error(err));
80
58
  } else {
81
59
  if (stats.hasWarnings()) {
82
- info.warnings.forEach(function (err) {
83
- return console.warn(err);
84
- });
60
+ info.warnings.forEach(err => console.warn(err));
85
61
  }
86
62
 
87
- process.stdout.write(_chalk["default"].green('Compiled successfully!\n\n'));
63
+ process.stdout.write(_chalk.default.green('Compiled successfully!\n\n'));
88
64
 
89
65
  if (config.devServer) {
90
- var _config$devServer = config.devServer,
91
- https = _config$devServer.https,
92
- host = _config$devServer.host,
93
- port = _config$devServer.port;
94
- var protocol = https ? 'https' : 'http';
66
+ let {
67
+ https,
68
+ host,
69
+ port
70
+ } = config.devServer;
71
+ let protocol = https ? 'https' : 'http';
95
72
  if (host === '0.0.0.0') host = 'localhost';
96
- var serverAddr = "".concat(protocol, "://").concat(host, ":").concat(_chalk["default"].bold(port), "/index.js");
97
- var localIpAddr = "".concat(protocol, "://").concat(_ip["default"].address(), ":").concat(_chalk["default"].bold(port), "/index.js");
73
+ let serverAddr = `${protocol}://${host}:${_chalk.default.bold(port)}/index.js`;
74
+ let localIpAddr = `${protocol}://${_ip.default.address()}:${_chalk.default.bold(port)}/index.js`;
98
75
 
99
76
  if (preferredPort !== config.devServer.port) {
100
- process.stdout.write("NOTE: Port ".concat(preferredPort, " is not available, using ").concat(port, " instead.\n\n"));
77
+ process.stdout.write(`NOTE: Port ${preferredPort} is not available, using ${port} instead.\n\n`);
101
78
  }
102
79
 
103
80
  process.stdout.write('You can view the application in browser.\n\n');
104
- process.stdout.write("".concat(_chalk["default"].bold('Local:'), " ").concat(serverAddr, "\n"));
105
- process.stdout.write("".concat(_chalk["default"].bold('On Your Network:'), " ").concat(localIpAddr, "\n"));
81
+ process.stdout.write(`${_chalk.default.bold('Local:')} ${serverAddr}\n`);
82
+ process.stdout.write(`${_chalk.default.bold('On Your Network:')} ${localIpAddr}\n`);
106
83
  }
107
84
  }
108
85
  });
109
86
 
110
87
  if (config.devServer) {
111
- (0, _getPort["default"])({
88
+ (0, _getPort.default)({
112
89
  port: (0, _getPort.makeRange)(preferredPort, preferredPort + 100)
113
- }).then(function (port) {
90
+ }).then(port => {
114
91
  if (config.devServer.port !== port) {
115
92
  config.devServer.port = port;
116
93
  }
117
94
 
118
- new _webpackDevServer["default"](compiler, config.devServer).listen(config.devServer.port);
95
+ new _webpackDevServer.default(compiler, config.devServer).listen(config.devServer.port);
119
96
  });
120
97
  } else {
121
- compiler.run(function (err, stats) {
98
+ compiler.run((err, stats) => {
122
99
  if (!err && stats.hasErrors()) {
123
- err = "".concat(stats.toJson().errors.length, " errors");
100
+ err = `${stats.toJson().errors.length} errors`;
124
101
  }
125
102
 
126
103
  callback(err, null);
@@ -130,17 +107,17 @@ function run(args, callback) {
130
107
 
131
108
  function configure(env) {
132
109
  env = env || {};
133
- var watch = env.watch || env.w || process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'development';
134
- var PROD = !watch;
135
- var https = !(process.env.HTTPS === 'false' || env.https === false),
110
+ const watch = env.watch || env.w || process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'development';
111
+ const PROD = !watch;
112
+ let https = !(process.env.HTTPS === 'false' || env.https === false),
136
113
  host = process.env.HOST || env.host || 'localhost',
137
114
  port = process.env.PORT || env.port || 8081;
138
- var cwd = env.cwd = process.cwd(),
115
+ let cwd = env.cwd = process.cwd(),
139
116
  context = cwd,
140
117
  pkg;
141
118
 
142
119
  try {
143
- pkg = require(_path["default"].resolve(cwd, 'package.json'));
120
+ pkg = require(_path.default.resolve(cwd, 'package.json'));
144
121
  } catch (e) {}
145
122
 
146
123
  if (!pkg) {
@@ -150,26 +127,25 @@ function configure(env) {
150
127
  } // entry point (initial file to load)
151
128
 
152
129
 
153
- var entry = _path["default"].resolve(cwd, pkg.module || pkg['jsnext:main'] || pkg.main);
130
+ let entry = _path.default.resolve(cwd, pkg.module || pkg['jsnext:main'] || pkg.main);
154
131
 
155
- if (isDir(entry)) entry = _path["default"].resolve(entry, 'index.js'); // attempt to use ./src dir if present:
132
+ if (isDir(entry)) entry = _path.default.resolve(entry, 'index.js'); // attempt to use ./src dir if present:
156
133
 
157
- if (isDir(_path["default"].resolve(cwd, 'src'))) context = _path["default"].resolve(context, 'src'); // normalize desination dir
134
+ if (isDir(_path.default.resolve(cwd, 'src'))) context = _path.default.resolve(context, 'src'); // normalize desination dir
158
135
 
159
- var dest = _path["default"].resolve(cwd, env.dest || 'build'); // use absolute paths
136
+ let dest = _path.default.resolve(cwd, env.dest || 'build'); // use absolute paths
160
137
 
161
138
 
162
- context = _path["default"].resolve(context);
163
- var componentDirs = [_path["default"].resolve(context, 'components'), _path["default"].resolve(context, 'screens'), _path["default"].resolve(context, 'pages')];
164
- var cssLoaderOptions = {
139
+ context = _path.default.resolve(context);
140
+ let componentDirs = [_path.default.resolve(context, 'components'), _path.default.resolve(context, 'screens'), _path.default.resolve(context, 'pages')];
141
+ let cssLoaderOptions = {
165
142
  sourceMap: watch && !PROD
166
143
  };
167
- var postCssLoaderOptions = {
144
+ let postCssLoaderOptions = {
168
145
  sourceMap: true,
169
146
  postcssOptions: {
170
147
  config: false,
171
- plugins: [(0, _postcssPresetEnv["default"])({
172
- browsers: ['last 2 versions', 'not ie > 0', 'iOS >= 8'],
148
+ plugins: [(0, _postcssPresetEnv.default)({
173
149
  stage: 3,
174
150
  autoprefixer: true,
175
151
  features: {
@@ -177,50 +153,46 @@ function configure(env) {
177
153
  // disable customProperties plugin so css variables and :root blocks are preserved
178
154
  'custom-properties': false
179
155
  }
180
- }), (0, _postcssDiscardComments["default"])({
156
+ }), (0, _postcssDiscardComments.default)({
181
157
  removeAll: true
182
158
  })]
183
159
  }
184
160
  };
185
- var cssModulesRegexp = (0, _util.crossPlatformPathRegex)(/(?:([^/@]+?)(?:-(?:pages?|components?|screens?))?\/)?src\/(?:pages|components|screens)\/(.+?)(\/[a-z0-9._-]+[.](less|css))?$/);
186
- var webpackConfig = {
161
+ let cssModulesRegexp = (0, _util.crossPlatformPathRegex)(/(?:([^/@]+?)(?:-(?:pages?|components?|screens?))?\/)?src\/(?:pages|components|screens)\/(.+?)(\/[a-z0-9._-]+[.](less|css))?$/);
162
+ let webpackConfig = {
187
163
  mode: PROD ? 'production' : 'development',
188
- context: context,
189
- entry: _path["default"].resolve(__dirname, 'entry.js'),
164
+ context,
165
+ entry: _path.default.resolve(__dirname, 'entry.js'),
190
166
  output: {
191
167
  path: dest,
192
- filename: "index.js",
168
+ filename: `index.js`,
193
169
  chunkFilename: '[name].[chunkhash:8].chunk.js',
194
170
  // NOTE: Explicit public path is required in order to make HMR work within an sourceless iframe.
195
171
  // This is due to a bug in webpack-dev-server that uses the document protocol for all https pages:
196
172
  // https://github.com/webpack/webpack-dev-server/blob/c490b245ad65f315762e03e51710f7f7177b1e7b/client/index.js#L188-L190
197
- publicPath: watch ? "http".concat(https ? 's' : '', "://").concat(host, ":").concat(port, "/") : env.publicpath || '/'
173
+ publicPath: watch ? `http${https ? 's' : ''}://${host}:${port}/` : env.publicpath || '/'
198
174
  },
199
175
  resolve: {
200
176
  extensions: ['.mjs', '.jsx', '.js', '.json', '.css', '.less'],
201
177
  mainFields: ['browser', 'module', 'jsnext:main', 'main'],
202
- modules: [_path["default"].resolve(cwd, 'node_modules'), 'node_modules'],
203
- alias: _objectSpread(_objectSpread({}, _shims.SHIMMED_MODULES.reduce(function (shimAliases, name) {
204
- if (Array.isArray(name)) {
205
- // If module name is an Array, the first element is the root name of the module
206
- var _name = name;
207
-
208
- var _name2 = _slicedToArray(_name, 1);
209
-
210
- name = _name2[0];
211
- }
212
-
213
- shimAliases[name] = (0, _shims.getShimPath)(name);
214
- return shimAliases;
215
- }, {})), {}, {
178
+ modules: [_path.default.resolve(cwd, 'node_modules'), 'node_modules'],
179
+ alias: { ..._shims.SHIMMED_MODULES.reduce((shimAliases, name) => {
180
+ if (Array.isArray(name)) {
181
+ // If module name is an Array, the first element is the root name of the module
182
+ [name] = name;
183
+ }
184
+
185
+ shimAliases[name] = (0, _shims.getShimPath)(name);
186
+ return shimAliases;
187
+ }, {}),
216
188
  react: (0, _shims.getShimPath)('preact/compat'),
217
189
  'react-dom': (0, _shims.getShimPath)('preact/compat'),
218
- style: _path["default"].resolve(context, 'style'),
219
- 'zimlet-cli-entrypoint': _path["default"].resolve(context, entry)
220
- })
190
+ style: _path.default.resolve(context, 'style'),
191
+ 'zimlet-cli-entrypoint': _path.default.resolve(context, entry)
192
+ }
221
193
  },
222
194
  resolveLoader: {
223
- modules: [_path["default"].resolve(__dirname, 'loaders'), _path["default"].resolve(__dirname, '..', 'node_modules'), _path["default"].resolve(cwd, 'node_modules')]
195
+ modules: [_path.default.resolve(__dirname, 'loaders'), _path.default.resolve(__dirname, '..', 'node_modules'), _path.default.resolve(cwd, 'node_modules')]
224
196
  },
225
197
  module: {
226
198
  rules: [{
@@ -231,7 +203,8 @@ function configure(env) {
231
203
  comments: true,
232
204
  presets: [[require.resolve('@babel/preset-env'), {
233
205
  loose: true,
234
- modules: false
206
+ modules: false,
207
+ bugfixes: true
235
208
  }]],
236
209
  plugins: [require.resolve('@babel/plugin-syntax-dynamic-import'), [require.resolve('@babel/plugin-proposal-decorators'), {
237
210
  legacy: true
@@ -246,16 +219,16 @@ function configure(env) {
246
219
  // include: /(^|\/)src\/(?:components|screens)\//,
247
220
  include: componentDirs,
248
221
  use: [{
249
- loader: _path["default"].resolve(__dirname, 'zimlet-style-loader.js')
222
+ loader: _path.default.resolve(__dirname, 'zimlet-style-loader.js')
250
223
  }, {
251
224
  loader: 'css-loader',
252
- options: _objectSpread(_objectSpread({}, cssLoaderOptions), {}, {
225
+ options: { ...cssLoaderOptions,
253
226
  modules: {
254
227
  localIdentRegExp: cssModulesRegexp,
255
228
  localIdentName: '[1]_[2]_[local]'
256
229
  },
257
230
  importLoaders: 1
258
- })
231
+ }
259
232
  }, {
260
233
  loader: 'postcss-loader',
261
234
  options: postCssLoaderOptions
@@ -267,7 +240,7 @@ function configure(env) {
267
240
  // exclude: /(^|\/)src\/(?:components|screens)\//,
268
241
  exclude: componentDirs,
269
242
  use: [{
270
- loader: _path["default"].resolve(__dirname, 'zimlet-style-loader.js')
243
+ loader: _path.default.resolve(__dirname, 'zimlet-style-loader.js')
271
244
  }, {
272
245
  loader: 'css-loader',
273
246
  options: cssLoaderOptions
@@ -292,23 +265,23 @@ function configure(env) {
292
265
  __dirname: false,
293
266
  setImmediate: false
294
267
  } : {},
295
- plugins: [].concat(PROD ? [new _webpack["default"].HashedModuleIdsPlugin()] : [new _webpack["default"].HotModuleReplacementPlugin()], new _webpack["default"].LoaderOptionsPlugin({
268
+ plugins: [].concat(PROD ? [new _webpack.default.HashedModuleIdsPlugin()] : [new _webpack.default.HotModuleReplacementPlugin()], new _webpack.default.LoaderOptionsPlugin({
296
269
  minimize: PROD,
297
270
  debug: !PROD
298
- }), new _progressBarWebpackPlugin["default"]({
299
- format: "\x1B[90m\x1B[44mBuild\x1B[49m\x1B[39m [:bar] \x1B[32m\x1B[1m:percent\x1B[22m\x1B[39m (:elapseds) \x1B[2m:msg\x1B[22m",
271
+ }), new _progressBarWebpackPlugin.default({
272
+ format: '\u001b[90m\u001b[44mBuild\u001b[49m\u001b[39m [:bar] \u001b[32m\u001b[1m:percent\u001b[22m\u001b[39m (:elapseds) \u001b[2m:msg\u001b[22m',
300
273
  renderThrottle: 100,
301
274
  summary: false
302
- }), new _webpack["default"].DefinePlugin({
275
+ }), new _webpack.default.DefinePlugin({
303
276
  'process.env.NODE_ENV': JSON.stringify(PROD ? 'production' : 'development')
304
- }), isFile(_path["default"].resolve(cwd, 'config_template.xml')) && new _copyWebpackPlugin["default"]({
277
+ }), isFile(_path.default.resolve(cwd, 'config_template.xml')) && new _copyWebpackPlugin.default({
305
278
  patterns: [{
306
- from: _path["default"].join(cwd, 'config_template.xml'),
307
- to: _path["default"].join(dest, 'config_template.xml')
279
+ from: _path.default.join(cwd, 'config_template.xml'),
280
+ to: _path.default.join(dest, 'config_template.xml')
308
281
  }]
309
282
  })).filter(Boolean),
310
283
  watchOptions: {
311
- ignored: ['build', dest, _path["default"].resolve(cwd, 'node_modules')]
284
+ ignored: ['build', dest, _path.default.resolve(cwd, 'node_modules')]
312
285
  },
313
286
  stats: 'errors-only',
314
287
  devtool: watch ? 'cheap-module-eval-source-map' : 'source-map'
@@ -316,21 +289,23 @@ function configure(env) {
316
289
 
317
290
  if (watch) {
318
291
  webpackConfig.devServer = {
319
- host: host,
320
- port: port,
292
+ host,
293
+ port,
321
294
  hot: !process.env.DISABLE_HOT,
322
- https: https,
295
+ https,
323
296
  compress: true,
324
297
  publicPath: '/',
325
298
  contentBase: context,
326
299
  disableHostCheck: true,
327
- before: function before(app) {
300
+
301
+ before(app) {
328
302
  app.use(require('cors')({
329
303
  maxAge: 3600
330
304
  }));
331
305
  },
306
+
332
307
  watchOptions: {
333
- ignored: ['build', dest, _path["default"].resolve(cwd, 'node_modules')]
308
+ ignored: ['build', dest, _path.default.resolve(cwd, 'node_modules')]
334
309
  },
335
310
  overlay: false,
336
311
  noInfo: true,
@@ -339,18 +314,18 @@ function configure(env) {
339
314
  };
340
315
  }
341
316
 
342
- (0, _transformConfig["default"])(env, webpackConfig);
317
+ (0, _transformConfig.default)(env, webpackConfig);
343
318
  return webpackConfig;
344
319
  }
345
320
 
346
321
  function isDir(filepath) {
347
322
  try {
348
- return !!_fs["default"].statSync(filepath).isDirectory();
323
+ return !!_fs.default.statSync(filepath).isDirectory();
349
324
  } catch (err) {}
350
325
  }
351
326
 
352
327
  function isFile(filepath) {
353
328
  try {
354
- return !!_fs["default"].statSync(filepath).isFile();
329
+ return !!_fs.default.statSync(filepath).isFile();
355
330
  } catch (err) {}
356
331
  }