@commercetools-frontend/mc-scripts 22.2.1 → 22.3.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 (62) hide show
  1. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +51 -41
  2. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +51 -41
  3. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +51 -41
  4. package/dist/{build-72d9896f.esm.js → build-8227e71d.esm.js} +22 -31
  5. package/dist/{build-4773d61a.cjs.dev.js → build-a888cacd.cjs.dev.js} +22 -31
  6. package/dist/{build-0ef080b9.cjs.prod.js → build-a9f085a0.cjs.prod.js} +22 -31
  7. package/dist/{build-vite-2dc2b366.cjs.prod.js → build-vite-1ba28dd8.cjs.prod.js} +18 -19
  8. package/dist/{build-vite-290aaf04.esm.js → build-vite-9de4820c.esm.js} +18 -19
  9. package/dist/{build-vite-b5c7ac91.cjs.dev.js → build-vite-e7a6315c.cjs.dev.js} +18 -19
  10. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +2 -3
  11. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +2 -3
  12. package/dist/commercetools-frontend-mc-scripts.esm.js +2 -3
  13. package/dist/{compile-html-41195e35.cjs.dev.js → compile-html-079067bd.cjs.prod.js} +1 -7
  14. package/dist/{compile-html-5abd78aa.cjs.prod.js → compile-html-3ff2fed0.cjs.dev.js} +1 -7
  15. package/dist/{compile-html-f9de842c.esm.js → compile-html-606b302e.esm.js} +1 -7
  16. package/dist/{config-sync-8e8e18a9.cjs.prod.js → config-sync-058dca05.cjs.prod.js} +81 -193
  17. package/dist/{config-sync-c914ca7a.cjs.dev.js → config-sync-866d8c22.cjs.dev.js} +83 -194
  18. package/dist/{config-sync-54299066.esm.js → config-sync-dc5a68ed.esm.js} +83 -194
  19. package/dist/{create-postcss-config-f39f54b5.esm.js → create-postcss-config-9d266de4.esm.js} +9 -13
  20. package/dist/{create-postcss-config-a0659cf5.cjs.dev.js → create-postcss-config-a29e83fc.cjs.dev.js} +9 -13
  21. package/dist/{create-postcss-config-6277233e.cjs.prod.js → create-postcss-config-d4f8ca51.cjs.prod.js} +9 -13
  22. package/dist/{create-webpack-config-for-development-629a8982.cjs.prod.js → create-webpack-config-for-development-02fa9041.cjs.prod.js} +46 -37
  23. package/dist/{create-webpack-config-for-development-9539f804.esm.js → create-webpack-config-for-development-17376d1f.esm.js} +46 -37
  24. package/dist/{create-webpack-config-for-development-9aa85081.cjs.dev.js → create-webpack-config-for-development-ac4ad0b2.cjs.dev.js} +46 -37
  25. package/dist/{create-webpack-config-for-production-84e2db7d.cjs.prod.js → create-webpack-config-for-production-190c7797.cjs.prod.js} +37 -32
  26. package/dist/{create-webpack-config-for-production-4476fc5f.esm.js → create-webpack-config-for-production-25d7c593.esm.js} +37 -32
  27. package/dist/{create-webpack-config-for-production-0fac47e1.cjs.dev.js → create-webpack-config-for-production-c1ec1058.cjs.dev.js} +37 -32
  28. package/dist/{credentials-storage-5939dd35.esm.js → credentials-storage-5a3b88be.esm.js} +3 -15
  29. package/dist/{credentials-storage-da0754c9.cjs.dev.js → credentials-storage-5d3da1c0.cjs.prod.js} +3 -15
  30. package/dist/{credentials-storage-fc0c59c3.cjs.prod.js → credentials-storage-6c51d561.cjs.dev.js} +3 -15
  31. package/dist/declarations/src/generated/settings.d.ts +90 -1172
  32. package/dist/{has-jsx-runtime-0b03b72e.cjs.prod.js → has-jsx-runtime-aa5d21ee.cjs.dev.js} +0 -2
  33. package/dist/{has-jsx-runtime-3d4bb633.cjs.dev.js → has-jsx-runtime-c3202df5.cjs.prod.js} +0 -2
  34. package/dist/{has-jsx-runtime-8314226e.esm.js → has-jsx-runtime-e3ecb09b.esm.js} +0 -2
  35. package/dist/{login-9f821336.cjs.dev.js → login-0dc4f62a.cjs.prod.js} +12 -23
  36. package/dist/{login-d1c2268a.esm.js → login-1b051481.esm.js} +12 -23
  37. package/dist/{login-f747390f.cjs.prod.js → login-9f35d543.cjs.dev.js} +12 -23
  38. package/dist/{package-83202e32.cjs.prod.js → package-46d27f5f.cjs.dev.js} +15 -13
  39. package/dist/{package-e6713e98.esm.js → package-4fcd2667.esm.js} +15 -13
  40. package/dist/{package-cc5b8665.cjs.dev.js → package-6ee0354d.cjs.prod.js} +15 -13
  41. package/dist/{paths-284c77fb.cjs.prod.js → paths-854af5ef.cjs.prod.js} +8 -12
  42. package/dist/{paths-db35ac0f.cjs.dev.js → paths-d1febc82.cjs.dev.js} +8 -12
  43. package/dist/{paths-55c5d5a2.esm.js → paths-ded20ae1.esm.js} +8 -12
  44. package/dist/{serve-b8063204.cjs.dev.js → serve-12571b42.cjs.prod.js} +1 -2
  45. package/dist/{serve-660e2ee0.esm.js → serve-65b5a149.esm.js} +1 -2
  46. package/dist/{serve-41077dad.cjs.prod.js → serve-7339c495.cjs.dev.js} +1 -2
  47. package/dist/{start-33fd6d70.cjs.dev.js → start-216f84b7.cjs.dev.js} +26 -34
  48. package/dist/{start-93205b87.esm.js → start-4a922c4f.esm.js} +26 -34
  49. package/dist/{start-f93c62f9.cjs.prod.js → start-b2e2dab7.cjs.prod.js} +26 -34
  50. package/dist/{start-vite-8f03b0df.cjs.dev.js → start-vite-3966d625.cjs.dev.js} +18 -17
  51. package/dist/{start-vite-324af14d.cjs.prod.js → start-vite-5c78605b.cjs.prod.js} +18 -17
  52. package/dist/{start-vite-7d10ae71.esm.js → start-vite-cf0213a1.esm.js} +18 -17
  53. package/dist/{vite-plugin-svgr-f17db78a.esm.js → vite-plugin-svgr-5c953fe7.esm.js} +1 -6
  54. package/dist/{vite-plugin-svgr-fdb37ccf.cjs.dev.js → vite-plugin-svgr-5eb1c511.cjs.dev.js} +1 -6
  55. package/dist/{vite-plugin-svgr-9a4e7f77.cjs.prod.js → vite-plugin-svgr-a732f8df.cjs.prod.js} +1 -6
  56. package/package.json +31 -17
  57. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -2
  58. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -2
  59. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -2
  60. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +6 -6
  61. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +6 -6
  62. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +6 -6
@@ -24,9 +24,9 @@ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
24
24
  var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
25
25
  var applicationConfig = require('@commercetools-frontend/application-config');
26
26
  var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
27
- var createPostcssConfig = require('./create-postcss-config-a0659cf5.cjs.dev.js');
28
- var hasJsxRuntime = require('./has-jsx-runtime-3d4bb633.cjs.dev.js');
29
- var paths = require('./paths-db35ac0f.cjs.dev.js');
27
+ var createPostcssConfig = require('./create-postcss-config-a29e83fc.cjs.dev.js');
28
+ var hasJsxRuntime = require('./has-jsx-runtime-aa5d21ee.cjs.dev.js');
29
+ var paths = require('./paths-d1febc82.cjs.dev.js');
30
30
  var vendorsToTranspile = require('./vendors-to-transpile-6ab4ea06.cjs.dev.js');
31
31
 
32
32
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -55,15 +55,14 @@ let LocalHtmlWebpackPlugin = /*#__PURE__*/function () {
55
55
  function LocalHtmlWebpackPlugin() {
56
56
  _classCallCheck(this, LocalHtmlWebpackPlugin);
57
57
  }
58
-
59
58
  _createClass(LocalHtmlWebpackPlugin, [{
60
59
  key: "apply",
61
60
  value: function apply(compiler) {
62
61
  compiler.hooks.compilation.tap('LocalHtmlWebpackPlugin', compilation => {
63
62
  HtmlWebpackPlugin__default["default"].getHooks(compilation).beforeEmit.tapAsync('LocalHtmlWebpackPlugin', (data, cb) => {
64
63
  const applicationConfig$1 = applicationConfig.processConfig();
65
-
66
- const enhancedLocalEnv = _Object$assign__default["default"]({}, applicationConfig$1.env, // Now that the app config is defined as a `env.json`, when we start the FE app
64
+ const enhancedLocalEnv = _Object$assign__default["default"]({}, applicationConfig$1.env,
65
+ // Now that the app config is defined as a `env.json`, when we start the FE app
67
66
  // to point to the local backend API by passing the `MC_API_URL` env does not
68
67
  // work anymore). To make it work again, we can override the `env.json` config
69
68
  // with the env variable before injecting the values into the index.html.
@@ -71,7 +70,6 @@ let LocalHtmlWebpackPlugin = /*#__PURE__*/function () {
71
70
  process.env.MC_API_URL ? {
72
71
  mcApiUrl: process.env.MC_API_URL
73
72
  } : {});
74
-
75
73
  data.html = mcHtmlTemplate.replaceHtmlPlaceholders(data.html, {
76
74
  env: enhancedLocalEnv,
77
75
  headers: {}
@@ -81,14 +79,13 @@ let LocalHtmlWebpackPlugin = /*#__PURE__*/function () {
81
79
  });
82
80
  }
83
81
  }]);
84
-
85
82
  return LocalHtmlWebpackPlugin;
86
83
  }();
87
84
 
88
85
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
89
-
90
86
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context6, _context7; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(source), !0)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(source))).call(_context7, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
91
87
  const momentLocalesToKeep = ["de", "de-at", "de-ch", "en-au", "en-ca", "en-gb", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "zh-cn"];
88
+ // https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
92
89
 
93
90
  const defaultToggleFlags = {
94
91
  generateIndexHtml: true,
@@ -99,31 +96,26 @@ const defaultOptions = {
99
96
  sourceFolders: paths.paths.sourceFolders,
100
97
  postcssOptions: {},
101
98
  toggleFlags: defaultToggleFlags
102
- }; // Whether or not `react-refresh` is enabled, `react-refresh` is not 100% stable at this time,
103
- // which is why it's disabled by default.
99
+ };
104
100
 
101
+ // Whether or not `react-refresh` is enabled, `react-refresh` is not 100% stable at this time,
102
+ // which is why it's disabled by default.
105
103
  const hasReactRefresh = process.env.FAST_REFRESH === 'true';
106
-
107
104
  const webpackDevClientEntry = require.resolve('react-dev-utils/webpackHotDevClient');
108
-
109
105
  const reactRefreshOverlayEntry = require.resolve('react-dev-utils/refreshOverlayInterop');
106
+
110
107
  /**
111
108
  * This is a factory function to create the default webpack config
112
109
  * for a MC Application in `development` mode.
113
110
  * The function requires the file path to the related application
114
111
  * "entry point".
115
112
  */
116
-
117
-
118
113
  function createWebpackConfigForDevelopment() {
119
114
  var _context, _context2, _context3, _context4, _context5;
120
-
121
115
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
122
-
123
116
  const mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, defaultOptions), options), {}, {
124
117
  toggleFlags: _objectSpread(_objectSpread({}, defaultToggleFlags), options.toggleFlags)
125
118
  });
126
-
127
119
  return {
128
120
  // https://webpack.js.org/concepts/#mode
129
121
  mode: 'development',
@@ -168,9 +160,11 @@ function createWebpackConfigForDevelopment() {
168
160
  }
169
161
  },
170
162
  entry: {
171
- app: _filterInstanceProperty__default["default"](_context2 = [require.resolve('@commercetools-frontend/mc-scripts/application-runtime'), !mergedOptions.toggleFlags.disableCoreJs && require.resolve('core-js/stable'), // When using the experimental `react-refresh` integration,
163
+ app: _filterInstanceProperty__default["default"](_context2 = [require.resolve('@commercetools-frontend/mc-scripts/application-runtime'), !mergedOptions.toggleFlags.disableCoreJs && require.resolve('core-js/stable'),
164
+ // When using the experimental `react-refresh` integration,
172
165
  // the webpack plugin takes care of injecting the dev client for us.
173
- !hasReactRefresh && // Include an alternative client for WebpackDevServer. A client's job is to
166
+ !hasReactRefresh &&
167
+ // Include an alternative client for WebpackDevServer. A client's job is to
174
168
  // connect to WebpackDevServer by a socket and get notified about changes.
175
169
  // When you save a file, the client will either apply hot updates (in case
176
170
  // of CSS changes), or refresh the page (in case of JS changes). When you
@@ -181,8 +175,10 @@ function createWebpackConfigForDevelopment() {
181
175
  //
182
176
  // require.resolve('webpack-dev-server/client') + '?/',
183
177
  // require.resolve('webpack/hot/dev-server'),
184
- webpackDevClientEntry, // Finally, this is your app's code
185
- mergedOptions.entryPoint // We include the app code last so that if there is a runtime error during
178
+ webpackDevClientEntry,
179
+ // Finally, this is your app's code
180
+ mergedOptions.entryPoint
181
+ // We include the app code last so that if there is a runtime error during
186
182
  // initialization, it doesn't blow up the WebpackDevServer client, and
187
183
  // changing JS code would still trigger a refresh.
188
184
  ]).call(_context2, Boolean)
@@ -203,14 +199,16 @@ function createWebpackConfigForDevelopment() {
203
199
  // Point sourcemap entries to the original disk location (format as URL on Windows)
204
200
  devtoolModuleFilenameTemplate: info => path__default["default"].resolve(info.absoluteResourcePath).replace(/\\/g, '/')
205
201
  },
206
- plugins: _filterInstanceProperty__default["default"](_context3 = [new WebpackBar__default["default"](), // Allows to "assign" custom options to the `webpack` object.
202
+ plugins: _filterInstanceProperty__default["default"](_context3 = [new WebpackBar__default["default"](),
203
+ // Allows to "assign" custom options to the `webpack` object.
207
204
  // At the moment, this is used to share some props with `postcss.config`.
208
205
  new webpack__default["default"].LoaderOptionsPlugin({
209
206
  options: {
210
207
  sourceFolders: mergedOptions.sourceFolders,
211
208
  context: __dirname
212
209
  }
213
- }), // Makes some environment variables available to the JS code, for example:
210
+ }),
211
+ // Makes some environment variables available to the JS code, for example:
214
212
  // if (process.env.NODE_ENV === 'development') { ... }.
215
213
  new webpack__default["default"].DefinePlugin({
216
214
  __DEV__: 'true',
@@ -221,11 +219,14 @@ function createWebpackConfigForDevelopment() {
221
219
  inject: false,
222
220
  filename: paths.paths.appIndexHtml,
223
221
  template: require.resolve('@commercetools-frontend/mc-html-template/webpack')
224
- }), mergedOptions.toggleFlags.generateIndexHtml && new LocalHtmlWebpackPlugin(), // Only keep locales that are available in the Merchant Center.
222
+ }), mergedOptions.toggleFlags.generateIndexHtml && new LocalHtmlWebpackPlugin(),
223
+ // Only keep locales that are available in the Merchant Center.
225
224
  new MomentLocalesPlugin__default["default"]({
226
225
  localesToKeep: momentLocalesToKeep
227
- }), // This is necessary to emit hot updates (CSS and Fast Refresh):
228
- new webpack__default["default"].HotModuleReplacementPlugin(), // Experimental hot reloading for React .
226
+ }),
227
+ // This is necessary to emit hot updates (CSS and Fast Refresh):
228
+ new webpack__default["default"].HotModuleReplacementPlugin(),
229
+ // Experimental hot reloading for React .
229
230
  // https://github.com/facebook/react/tree/master/packages/react-refresh
230
231
  hasReactRefresh && new ReactRefreshWebpackPlugin__default["default"]({
231
232
  overlay: {
@@ -241,7 +242,8 @@ function createWebpackConfigForDevelopment() {
241
242
  module: {
242
243
  // Makes missing exports an error instead of warning.
243
244
  strictExportPresence: true,
244
- rules: [// For svg icons, we want to get them transformed into React components
245
+ rules: [
246
+ // For svg icons, we want to get them transformed into React components
245
247
  // when we import them.
246
248
  {
247
249
  test: /\.react\.svg$/,
@@ -276,11 +278,13 @@ function createWebpackConfigForDevelopment() {
276
278
  }
277
279
  }
278
280
  }]
279
- }, // For normal svg files (not icons) we should load the file normally
281
+ },
282
+ // For normal svg files (not icons) we should load the file normally
280
283
  // and simply use it as a `<img src/>`.
281
284
  {
282
285
  test: function testForNormalSvgFiles(fileName) {
283
- return (// Use this only for plain SVG.
286
+ return (
287
+ // Use this only for plain SVG.
284
288
  // For SVG as React components, see loader above.
285
289
  _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.svg') && !_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.react.svg')
286
290
  );
@@ -291,7 +295,8 @@ function createWebpackConfigForDevelopment() {
291
295
  }, {
292
296
  test: /\.png$/,
293
297
  type: 'asset/resource'
294
- }, // "postcss" loader applies autoprefixer to our CSS
298
+ },
299
+ // "postcss" loader applies autoprefixer to our CSS
295
300
  // "css" loader resolves paths in CSS and adds assets as dependencies.
296
301
  // "style" loader turns CSS into JS modules that inject <style> tags.
297
302
  {
@@ -315,7 +320,8 @@ function createWebpackConfigForDevelopment() {
315
320
  }]
316
321
  }, {
317
322
  test: function testForNormalCssFiles(fileName) {
318
- return (// Use this only for plain CSS.
323
+ return (
324
+ // Use this only for plain CSS.
319
325
  // For css-modules, see loader above.
320
326
  _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.css') && !(_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.mod.css') || _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.module.css'))
321
327
  );
@@ -358,7 +364,8 @@ function createWebpackConfigForDevelopment() {
358
364
  // See https://github.com/webpack/webpack/issues/6571
359
365
  sideEffects: true
360
366
  }]
361
- }, // Fix for react-intl
367
+ },
368
+ // Fix for react-intl
362
369
  // https://github.com/formatjs/formatjs/issues/143#issuecomment-518774786
363
370
  {
364
371
  test: /\.mjs$/,
@@ -367,16 +374,17 @@ function createWebpackConfigForDevelopment() {
367
374
  // https://webpack.js.org/configuration/module/#resolvefullyspecified
368
375
  fullySpecified: false
369
376
  }
370
- }, // Process JS with Babel.
377
+ },
378
+ // Process JS with Babel.
371
379
  {
372
380
  test: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
373
- use: [// This loader parallelizes code compilation, it is optional but
381
+ use: [
382
+ // This loader parallelizes code compilation, it is optional but
374
383
  // improves compile time on larger projects
375
384
  {
376
385
  loader: require.resolve('thread-loader'),
377
386
  options: {
378
387
  poolTimeout: Infinity // keep workers alive for more effective watch mode
379
-
380
388
  }
381
389
  }, {
382
390
  loader: require.resolve('babel-loader'),
@@ -400,7 +408,8 @@ function createWebpackConfigForDevelopment() {
400
408
  parser: {
401
409
  requireEnsure: false
402
410
  }
403
- }, // Allow to import `*.graphql` SDL files.
411
+ },
412
+ // Allow to import `*.graphql` SDL files.
404
413
  {
405
414
  test: /\.graphql$/,
406
415
  include: mergedOptions.sourceFolders,
@@ -28,9 +28,9 @@ var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/ins
28
28
  var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
29
29
  var fs = require('fs');
30
30
  var path = require('path');
31
- var createPostcssConfig = require('./create-postcss-config-6277233e.cjs.prod.js');
32
- var hasJsxRuntime = require('./has-jsx-runtime-0b03b72e.cjs.prod.js');
33
- var paths = require('./paths-284c77fb.cjs.prod.js');
31
+ var createPostcssConfig = require('./create-postcss-config-d4f8ca51.cjs.prod.js');
32
+ var hasJsxRuntime = require('./has-jsx-runtime-c3202df5.cjs.prod.js');
33
+ var paths = require('./paths-854af5ef.cjs.prod.js');
34
34
  var vendorsToTranspile = require('./vendors-to-transpile-04a49d40.cjs.prod.js');
35
35
 
36
36
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -66,12 +66,10 @@ let FinalStatsWriterPlugin = /*#__PURE__*/function () {
66
66
  // - `includeFields`
67
67
  function FinalStatsWriterPlugin(config) {
68
68
  _classCallCheck(this, FinalStatsWriterPlugin);
69
-
70
69
  this.config = void 0;
71
70
  if (!config) throw new Error('Missing config options');
72
71
  this.config = config;
73
72
  }
74
-
75
73
  _createClass(FinalStatsWriterPlugin, [{
76
74
  key: "apply",
77
75
  value: function apply(compiler) {
@@ -82,11 +80,9 @@ let FinalStatsWriterPlugin = /*#__PURE__*/function () {
82
80
  // https://webpack.js.org/api/plugins/#plugin-types
83
81
  if (compiler.hooks) {
84
82
  var _context;
85
-
86
83
  compiler.hooks.done.tap('custom-stats-writer-plugin', _bindInstanceProperty__default["default"](_context = this.writeStats).call(_context, this));
87
84
  } else {
88
85
  var _context2;
89
-
90
86
  // @ts-ignore
91
87
  compiler.plugin('done', _bindInstanceProperty__default["default"](_context2 = this.writeStats).call(_context2, this));
92
88
  }
@@ -94,17 +90,17 @@ let FinalStatsWriterPlugin = /*#__PURE__*/function () {
94
90
  }, {
95
91
  key: "writeStats",
96
92
  value: function writeStats(stats) {
97
- let finalStats = stats.toJson(); // Filter only included fields
93
+ let finalStats = stats.toJson();
98
94
 
95
+ // Filter only included fields
99
96
  if (this.config.includeFields) {
100
97
  var _context3;
101
-
102
- finalStats = _reduceInstanceProperty__default["default"](_context3 = this.config.includeFields).call(_context3, (aggregatedStats, key) => // eslint-disable-next-line
98
+ finalStats = _reduceInstanceProperty__default["default"](_context3 = this.config.includeFields).call(_context3, (aggregatedStats, key) =>
99
+ // eslint-disable-next-line
103
100
  _Object$assign__default["default"]({}, aggregatedStats, {
104
101
  [key]: finalStats[key]
105
102
  }), {});
106
103
  }
107
-
108
104
  try {
109
105
  fs__default["default"].accessSync(this.config.outputPath, fs__default["default"].constants.F_OK);
110
106
  fs__default["default"].writeFileSync(path__default["default"].join(this.config.outputPath, 'stats.json'), _JSON$stringify__default["default"](finalStats, null, 2));
@@ -114,14 +110,12 @@ let FinalStatsWriterPlugin = /*#__PURE__*/function () {
114
110
  }
115
111
  }
116
112
  }]);
117
-
118
113
  return FinalStatsWriterPlugin;
119
114
  }();
120
115
 
121
116
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
122
-
123
117
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context7, _context8; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(source), !0)).call(_context7, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context8 = ownKeys(Object(source))).call(_context8, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
124
-
118
+ // https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
125
119
  const momentLocalesToKeep = ["de", "de-at", "de-ch", "en-au", "en-ca", "en-gb", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "zh-cn"];
126
120
  const defaultToggleFlags = {
127
121
  // Allow to disable CSS extraction in case it's not necessary (e.g. for Storybook)
@@ -146,22 +140,19 @@ const defaultOptions = {
146
140
  postcssOptions: {},
147
141
  toggleFlags: defaultToggleFlags
148
142
  };
143
+
149
144
  /**
150
145
  * This is a factory function to create the default webpack config
151
146
  * for a MC Application in `production` mode.
152
147
  * The function requires the file path to the related application
153
148
  * "entry point".
154
149
  */
155
-
156
150
  function createWebpackConfigForProduction() {
157
151
  var _context, _context2, _context3, _context4, _context5, _context6;
158
-
159
152
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
160
-
161
153
  const mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, defaultOptions), options), {}, {
162
154
  toggleFlags: _objectSpread(_objectSpread({}, defaultToggleFlags), options.toggleFlags)
163
155
  });
164
-
165
156
  return {
166
157
  // Don't attempt to continue if there are any errors.
167
158
  bail: true,
@@ -253,24 +244,28 @@ function createWebpackConfigForProduction() {
253
244
  // Will be injected on runtime. See `packages/application-shell/src/public-path.js`
254
245
  publicPath: ''
255
246
  },
256
- plugins: _filterInstanceProperty__default["default"](_context4 = [// Allows to "assign" custom options to the `webpack` object.
247
+ plugins: _filterInstanceProperty__default["default"](_context4 = [
248
+ // Allows to "assign" custom options to the `webpack` object.
257
249
  // At the moment, this is used to share some props with `postcss.config`.
258
250
  new webpack__default["default"].LoaderOptionsPlugin({
259
251
  options: {
260
252
  sourceFolders: mergedOptions.sourceFolders,
261
253
  context: __dirname
262
254
  }
263
- }), // Makes some environment variables available to the JS code, for example:
255
+ }),
256
+ // Makes some environment variables available to the JS code, for example:
264
257
  // if (process.env.NODE_ENV === 'production') { ... }.
265
258
  new webpack__default["default"].DefinePlugin({
266
259
  __DEV__: 'false',
267
260
  'process.env': {
268
261
  NODE_ENV: _JSON$stringify__default["default"]('production')
269
262
  }
270
- }), // Only keep locales that are available in the Merchant Center.
263
+ }),
264
+ // Only keep locales that are available in the Merchant Center.
271
265
  new MomentLocalesPlugin__default["default"]({
272
266
  localesToKeep: momentLocalesToKeep
273
- }), // Generate a `stats.json` file containing information and paths to
267
+ }),
268
+ // Generate a `stats.json` file containing information and paths to
274
269
  // the assets that webpack created.
275
270
  // This is necessary to programmatically refer to the correct bundle path
276
271
  // in the `index.html`.
@@ -281,7 +276,8 @@ function createWebpackConfigForProduction() {
281
276
  inject: false,
282
277
  filename: 'index.html.template',
283
278
  template: require.resolve('@commercetools-frontend/mc-html-template/webpack')
284
- }), mergedOptions.toggleFlags.enableExtractCss && // Extracts CSS into one CSS file to mimic CSS order in dev
279
+ }), mergedOptions.toggleFlags.enableExtractCss &&
280
+ // Extracts CSS into one CSS file to mimic CSS order in dev
285
281
  new MiniCssExtractPlugin__default["default"]({
286
282
  filename: '[name].[chunkhash].css',
287
283
  chunkFilename: '[id].[name].[chunkhash].css'
@@ -291,7 +287,8 @@ function createWebpackConfigForProduction() {
291
287
  module: {
292
288
  // Makes missing exports an error instead of warning.
293
289
  strictExportPresence: true,
294
- rules: _filterInstanceProperty__default["default"](_context5 = [// For svg icons, we want to get them transformed into React components
290
+ rules: _filterInstanceProperty__default["default"](_context5 = [
291
+ // For svg icons, we want to get them transformed into React components
295
292
  // when we import them.
296
293
  {
297
294
  test: /\.react\.svg$/,
@@ -326,11 +323,13 @@ function createWebpackConfigForProduction() {
326
323
  }
327
324
  }
328
325
  }]
329
- }, // For normal svg files (not icons) we should load the file normally
326
+ },
327
+ // For normal svg files (not icons) we should load the file normally
330
328
  // and simply use it as a `<img src/>`.
331
329
  {
332
330
  test: function testForNormalSvgFiles(fileName) {
333
- return (// Use this only for plain SVG.
331
+ return (
332
+ // Use this only for plain SVG.
334
333
  // For SVG as React components, see loader above.
335
334
  _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.svg') && !_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.react.svg')
336
335
  );
@@ -341,7 +340,8 @@ function createWebpackConfigForProduction() {
341
340
  }, {
342
341
  test: /\.png$/,
343
342
  type: 'asset/resource'
344
- }, // "postcss" loader applies autoprefixer to our CSS
343
+ },
344
+ // "postcss" loader applies autoprefixer to our CSS
345
345
  // "css" loader resolves paths in CSS and adds assets as dependencies.
346
346
  // "style" loader turns CSS into JS modules that inject <style> tags.
347
347
  // In production, we use MiniCSSExtractPlugin to extract that CSS
@@ -369,7 +369,8 @@ function createWebpackConfigForProduction() {
369
369
  }]
370
370
  }, {
371
371
  test: function testForNormalCssFiles(fileName) {
372
- return (// Use this only for plain CSS.
372
+ return (
373
+ // Use this only for plain CSS.
373
374
  // For css-modules, see loader above.
374
375
  _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.css') && !(_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.mod.css') || _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.module.css'))
375
376
  );
@@ -413,7 +414,8 @@ function createWebpackConfigForProduction() {
413
414
  // See https://github.com/webpack/webpack/issues/6571
414
415
  sideEffects: true
415
416
  }]
416
- }, // Fix for react-intl
417
+ },
418
+ // Fix for react-intl
417
419
  // https://github.com/formatjs/formatjs/issues/143#issuecomment-518774786
418
420
  {
419
421
  test: /\.mjs$/,
@@ -422,10 +424,12 @@ function createWebpackConfigForProduction() {
422
424
  // https://webpack.js.org/configuration/module/#resolvefullyspecified
423
425
  fullySpecified: false
424
426
  }
425
- }, // Process application JavaScript with Babel.
427
+ },
428
+ // Process application JavaScript with Babel.
426
429
  {
427
430
  test: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
428
- use: [// This loader parallelizes code compilation, it is optional but
431
+ use: [
432
+ // This loader parallelizes code compilation, it is optional but
429
433
  // improves compile time on larger projects
430
434
  {
431
435
  loader: require.resolve('thread-loader'),
@@ -453,7 +457,8 @@ function createWebpackConfigForProduction() {
453
457
  parser: {
454
458
  requireEnsure: false
455
459
  }
456
- }, // Allow to import `*.graphql` SDL files.
460
+ },
461
+ // Allow to import `*.graphql` SDL files.
457
462
  {
458
463
  test: /\.graphql$/,
459
464
  include: mergedOptions.sourceFolders,