@commercetools-frontend/mc-scripts 0.0.0-FEC-157-preview-releases-20241126230331

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 (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +2 -0
  4. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts.map +1 -0
  5. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
  6. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
  7. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js +7 -0
  8. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
  9. package/application-runtime/package.json +4 -0
  10. package/bin/cli.js +8 -0
  11. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +2 -0
  12. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts.map +1 -0
  13. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +211 -0
  14. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
  15. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +211 -0
  16. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +196 -0
  17. package/cli/package.json +4 -0
  18. package/config/create-webpack-config-for-development.js +8 -0
  19. package/config/create-webpack-config-for-production.js +8 -0
  20. package/config/vendors-to-transpile.js +6 -0
  21. package/dist/build-99744dae.cjs.prod.js +166 -0
  22. package/dist/build-a93715aa.esm.js +152 -0
  23. package/dist/build-f56ce7ec.cjs.dev.js +166 -0
  24. package/dist/build-vite-000f0a2d.cjs.prod.js +193 -0
  25. package/dist/build-vite-722f0dcf.esm.js +182 -0
  26. package/dist/build-vite-838c8e01.cjs.dev.js +193 -0
  27. package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +2 -0
  28. package/dist/commercetools-frontend-mc-scripts.cjs.d.ts.map +1 -0
  29. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +29 -0
  30. package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
  31. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +29 -0
  32. package/dist/commercetools-frontend-mc-scripts.esm.js +21 -0
  33. package/dist/compile-html-025cd493.esm.js +34 -0
  34. package/dist/compile-html-50fd05ec.cjs.prod.js +42 -0
  35. package/dist/compile-html-f4ac88cc.cjs.dev.js +42 -0
  36. package/dist/config-sync-2ff62f08.cjs.dev.js +845 -0
  37. package/dist/config-sync-b57f79e2.cjs.prod.js +839 -0
  38. package/dist/config-sync-cda7662e.esm.js +823 -0
  39. package/dist/create-postcss-config-2f709335.esm.js +75 -0
  40. package/dist/create-postcss-config-3b540c7c.cjs.prod.js +81 -0
  41. package/dist/create-postcss-config-5962fa01.cjs.dev.js +81 -0
  42. package/dist/create-webpack-config-for-development-7d9e4dc4.cjs.prod.js +463 -0
  43. package/dist/create-webpack-config-for-development-86baace3.esm.js +438 -0
  44. package/dist/create-webpack-config-for-development-b379913b.cjs.dev.js +463 -0
  45. package/dist/create-webpack-config-for-production-3a40f56b.cjs.dev.js +518 -0
  46. package/dist/create-webpack-config-for-production-5ec9d0e2.cjs.prod.js +518 -0
  47. package/dist/create-webpack-config-for-production-b6ee3116.esm.js +488 -0
  48. package/dist/credentials-storage-3cea94ea.cjs.dev.js +95 -0
  49. package/dist/credentials-storage-b13e1406.esm.js +83 -0
  50. package/dist/credentials-storage-dc849808.cjs.prod.js +95 -0
  51. package/dist/declarations/src/application-runtime.d.ts +1 -0
  52. package/dist/declarations/src/cli.d.ts +4 -0
  53. package/dist/declarations/src/commands/build-vite.d.ts +2 -0
  54. package/dist/declarations/src/commands/build.d.ts +2 -0
  55. package/dist/declarations/src/commands/compile-html.d.ts +3 -0
  56. package/dist/declarations/src/commands/config-sync.d.ts +3 -0
  57. package/dist/declarations/src/commands/deployment-previews-set.d.ts +3 -0
  58. package/dist/declarations/src/commands/login.d.ts +2 -0
  59. package/dist/declarations/src/commands/serve.d.ts +2 -0
  60. package/dist/declarations/src/commands/start-vite.d.ts +2 -0
  61. package/dist/declarations/src/commands/start.d.ts +2 -0
  62. package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
  63. package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
  64. package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
  65. package/dist/declarations/src/config/has-jsx-runtime.d.ts +2 -0
  66. package/dist/declarations/src/config/moment-locales.d.ts +2 -0
  67. package/dist/declarations/src/config/optimizations.d.ts +2 -0
  68. package/dist/declarations/src/config/paths.d.ts +12 -0
  69. package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
  70. package/dist/declarations/src/config/webpack-dev-server.config.d.ts +6 -0
  71. package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
  72. package/dist/declarations/src/generated/core.d.ts +739 -0
  73. package/dist/declarations/src/generated/settings.d.ts +2116 -0
  74. package/dist/declarations/src/index.d.ts +3 -0
  75. package/dist/declarations/src/postcss.d.ts +1 -0
  76. package/dist/declarations/src/types.d.ts +87 -0
  77. package/dist/declarations/src/utils/auth.d.ts +6 -0
  78. package/dist/declarations/src/utils/credentials-storage.d.ts +11 -0
  79. package/dist/declarations/src/utils/does-file-exist.d.ts +2 -0
  80. package/dist/declarations/src/utils/get-config-diff.d.ts +3 -0
  81. package/dist/declarations/src/utils/graphql-requests.d.ts +172 -0
  82. package/dist/declarations/src/utils/i18n-message-complilation.d.ts +4 -0
  83. package/dist/declarations/src/utils/user-agent.d.ts +2 -0
  84. package/dist/declarations/src/version.d.ts +2 -0
  85. package/dist/declarations/src/vite-plugins/vite-plugin-dynamic-base-assets-globals.d.ts +3 -0
  86. package/dist/declarations/src/vite-plugins/vite-plugin-i18n-message-compilation.d.ts +3 -0
  87. package/dist/declarations/src/vite-plugins/vite-plugin-merchant-center-customization.d.ts +4 -0
  88. package/dist/declarations/src/vite-plugins/vite-plugin-svgr.d.ts +3 -0
  89. package/dist/declarations/src/webpack-loaders/i18n-message-compilation-loader.d.ts +3 -0
  90. package/dist/declarations/src/webpack-plugins/final-stats-writer-plugin.d.ts +12 -0
  91. package/dist/declarations/src/webpack-plugins/local-html-webpack-plugin.d.ts +5 -0
  92. package/dist/declarations/src/webpack.d.ts +2 -0
  93. package/dist/deployment-previews-set-173d8491.cjs.dev.js +203 -0
  94. package/dist/deployment-previews-set-923f79de.esm.js +192 -0
  95. package/dist/deployment-previews-set-f451242a.cjs.prod.js +203 -0
  96. package/dist/does-file-exist-32618334.esm.js +12 -0
  97. package/dist/does-file-exist-be53305d.cjs.prod.js +18 -0
  98. package/dist/does-file-exist-eb86baca.cjs.dev.js +18 -0
  99. package/dist/graphql-requests-0e427050.esm.js +243 -0
  100. package/dist/graphql-requests-733aac06.cjs.dev.js +266 -0
  101. package/dist/graphql-requests-db54706e.cjs.prod.js +266 -0
  102. package/dist/has-jsx-runtime-aa5d21ee.cjs.dev.js +15 -0
  103. package/dist/has-jsx-runtime-c3202df5.cjs.prod.js +15 -0
  104. package/dist/has-jsx-runtime-e3ecb09b.esm.js +13 -0
  105. package/dist/i18n-message-complilation-21d3b0aa.esm.js +15 -0
  106. package/dist/i18n-message-complilation-7311cb29.cjs.dev.js +23 -0
  107. package/dist/i18n-message-complilation-7762da61.cjs.prod.js +23 -0
  108. package/dist/login-35f578e3.esm.js +86 -0
  109. package/dist/login-65c78b83.cjs.dev.js +103 -0
  110. package/dist/login-c616d769.cjs.prod.js +103 -0
  111. package/dist/optimizations-7789145e.cjs.dev.js +85 -0
  112. package/dist/optimizations-bf991634.esm.js +67 -0
  113. package/dist/optimizations-fb93514f.cjs.prod.js +85 -0
  114. package/dist/package-436331e6.cjs.dev.js +151 -0
  115. package/dist/package-a7096308.cjs.prod.js +151 -0
  116. package/dist/package-b2f2b4e5.esm.js +149 -0
  117. package/dist/paths-39f22b8b.esm.js +36 -0
  118. package/dist/paths-7768b440.cjs.prod.js +44 -0
  119. package/dist/paths-b76fc753.cjs.dev.js +44 -0
  120. package/dist/serve-5666b16a.cjs.prod.js +48 -0
  121. package/dist/serve-6a951584.esm.js +41 -0
  122. package/dist/serve-f898c45e.cjs.dev.js +48 -0
  123. package/dist/start-4e79e08f.esm.js +164 -0
  124. package/dist/start-569eb0f9.cjs.dev.js +177 -0
  125. package/dist/start-b0765c9a.cjs.prod.js +177 -0
  126. package/dist/start-vite-45bfc42f.esm.js +110 -0
  127. package/dist/start-vite-a68e1b9f.cjs.prod.js +122 -0
  128. package/dist/start-vite-a787f80d.cjs.dev.js +122 -0
  129. package/dist/vendors-to-transpile-04a49d40.cjs.prod.js +5 -0
  130. package/dist/vendors-to-transpile-6ab4ea06.cjs.dev.js +5 -0
  131. package/dist/vendors-to-transpile-7dc84a72.esm.js +3 -0
  132. package/dist/vite-plugin-svgr-069f402d.esm.js +83 -0
  133. package/dist/vite-plugin-svgr-7fb42bbf.cjs.dev.js +108 -0
  134. package/dist/vite-plugin-svgr-b080c510.cjs.prod.js +108 -0
  135. package/package.json +147 -0
  136. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +2 -0
  137. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts.map +1 -0
  138. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +12 -0
  139. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
  140. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +12 -0
  141. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +4 -0
  142. package/postcss/package.json +4 -0
  143. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +2 -0
  144. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts.map +1 -0
  145. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +57 -0
  146. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
  147. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +57 -0
  148. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +48 -0
  149. package/webpack/package.json +4 -0
  150. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.d.ts +3 -0
  151. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.d.ts.map +1 -0
  152. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +30 -0
  153. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.js +7 -0
  154. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +30 -0
  155. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +26 -0
  156. package/webpack-loaders/i18n-message-compilation-loader/package.json +4 -0
@@ -0,0 +1,518 @@
1
+ 'use strict';
2
+
3
+ var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
4
+ var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
5
+ var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
6
+ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
7
+ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
8
+ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
9
+ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
10
+ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
11
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
12
+ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
13
+ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
14
+ var _endsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/ends-with');
15
+ var _Number$isInteger = require('@babel/runtime-corejs3/core-js-stable/number/is-integer');
16
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
17
+ var crypto = require('crypto');
18
+ var CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
19
+ var HtmlWebpackPlugin = require('html-webpack-plugin');
20
+ var MiniCssExtractPlugin = require('mini-css-extract-plugin');
21
+ var MomentLocalesPlugin = require('moment-locales-webpack-plugin');
22
+ var TerserPlugin = require('terser-webpack-plugin');
23
+ var webpack = require('webpack');
24
+ var webpackBundleAnalyzer = require('webpack-bundle-analyzer');
25
+ var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
26
+ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
27
+ var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
28
+ var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
29
+ var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
30
+ var fs = require('fs');
31
+ var path = require('path');
32
+ var createPostcssConfig = require('./create-postcss-config-5962fa01.cjs.dev.js');
33
+ var hasJsxRuntime = require('./has-jsx-runtime-aa5d21ee.cjs.dev.js');
34
+ var optimizations = require('./optimizations-7789145e.cjs.dev.js');
35
+ var paths = require('./paths-b76fc753.cjs.dev.js');
36
+ var vendorsToTranspile = require('./vendors-to-transpile-6ab4ea06.cjs.dev.js');
37
+
38
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
39
+
40
+ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
41
+ var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
42
+ var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
43
+ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
44
+ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
45
+ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
46
+ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
47
+ var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
48
+ var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
49
+ var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
50
+ var _endsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_endsWithInstanceProperty);
51
+ var _Number$isInteger__default = /*#__PURE__*/_interopDefault(_Number$isInteger);
52
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
53
+ var crypto__default = /*#__PURE__*/_interopDefault(crypto);
54
+ var CssMinimizerPlugin__default = /*#__PURE__*/_interopDefault(CssMinimizerPlugin);
55
+ var HtmlWebpackPlugin__default = /*#__PURE__*/_interopDefault(HtmlWebpackPlugin);
56
+ var MiniCssExtractPlugin__default = /*#__PURE__*/_interopDefault(MiniCssExtractPlugin);
57
+ var MomentLocalesPlugin__default = /*#__PURE__*/_interopDefault(MomentLocalesPlugin);
58
+ var TerserPlugin__default = /*#__PURE__*/_interopDefault(TerserPlugin);
59
+ var webpack__default = /*#__PURE__*/_interopDefault(webpack);
60
+ var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
61
+ var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
62
+ var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
63
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
64
+ var path__default = /*#__PURE__*/_interopDefault(path);
65
+
66
+ let FinalStatsWriterPlugin = /*#__PURE__*/function () {
67
+ // Expected options:
68
+ // - `outputPath`
69
+ // - `includeFields`
70
+ function FinalStatsWriterPlugin(config) {
71
+ _classCallCheck(this, FinalStatsWriterPlugin);
72
+ this.config = void 0;
73
+ if (!config) throw new Error('Missing config options');
74
+ this.config = config;
75
+ }
76
+ _createClass(FinalStatsWriterPlugin, [{
77
+ key: "apply",
78
+ value: function apply(compiler) {
79
+ // This is the only hook that return the `stats` plugin
80
+ // with the `time` info. It also contains all the stats that
81
+ // we would get from the original `emit` hook.
82
+ // https://webpack.js.org/api/compiler-hooks/#done
83
+ // https://webpack.js.org/api/plugins/#plugin-types
84
+ if (compiler.hooks) {
85
+ var _context;
86
+ compiler.hooks.done.tap('custom-stats-writer-plugin', _bindInstanceProperty__default["default"](_context = this.writeStats).call(_context, this));
87
+ } else {
88
+ var _context2;
89
+ // @ts-ignore
90
+ compiler.plugin('done', _bindInstanceProperty__default["default"](_context2 = this.writeStats).call(_context2, this));
91
+ }
92
+ }
93
+ }, {
94
+ key: "writeStats",
95
+ value: function writeStats(stats) {
96
+ let finalStats = stats.toJson();
97
+
98
+ // Filter only included fields
99
+ if (this.config.includeFields) {
100
+ var _context3;
101
+ finalStats = _reduceInstanceProperty__default["default"](_context3 = this.config.includeFields).call(_context3, (aggregatedStats, key) =>
102
+ // eslint-disable-next-line
103
+ _Object$assign__default["default"]({}, aggregatedStats, {
104
+ [key]: finalStats[key]
105
+ }), {});
106
+ }
107
+ try {
108
+ fs__default["default"].accessSync(this.config.outputPath, fs__default["default"].constants.F_OK);
109
+ fs__default["default"].writeFileSync(path__default["default"].join(this.config.outputPath, 'stats.json'), _JSON$stringify__default["default"](finalStats, null, 2));
110
+ } catch (error) {
111
+ // eslint-disable-next-line no-console
112
+ console.warn(`[FinalStatsWriterPlugin] The dist folder could not be found at ${this.config.outputPath}. Check the console for errors during the webpack compilation.`);
113
+ }
114
+ }
115
+ }]);
116
+ return FinalStatsWriterPlugin;
117
+ }();
118
+
119
+ function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
120
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context8 = ownKeys(Object(t))).call(_context8, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
121
+ // https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
122
+ 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", "pt-br"];
123
+ const defaultToggleFlags = {
124
+ // Allow to disable CSS extraction in case it's not necessary (e.g. for Storybook)
125
+ enableExtractCss: true,
126
+ // Allow to disable index.html generation in case it's not necessary (e.g. for Storybook)
127
+ generateIndexHtml: true,
128
+ // Some plugins spawn workers to speed up the build. However this can cause trouble on
129
+ // certain machines local and CI. This flag set to limit or disable any parallelism.
130
+ // Options:
131
+ // `true` to default to the machines number of CPUs
132
+ // `false` to disable any paralelism
133
+ // `int` for a specific number of CPUs
134
+ parallelism: true,
135
+ // Some environemnts do not require `core-js` and can hence disable
136
+ // it explicitely. This will disable `core-js` for `preset-env` and the
137
+ // `plugin-transform-runtime`.
138
+ disableCoreJs: false
139
+ };
140
+ const defaultOptions = {
141
+ entryPoint: paths.paths.entryPoint,
142
+ sourceFolders: paths.paths.sourceFolders,
143
+ postcssOptions: {},
144
+ toggleFlags: defaultToggleFlags
145
+ };
146
+
147
+ /**
148
+ * This is a factory function to create the default webpack config
149
+ * for a MC Application in `production` mode.
150
+ * The function requires the file path to the related application
151
+ * "entry point".
152
+ */
153
+ function createWebpackConfigForProduction() {
154
+ var _context, _context2, _context3, _context4, _context5, _context6;
155
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
156
+ const mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, defaultOptions), options), {}, {
157
+ toggleFlags: _objectSpread(_objectSpread({}, defaultToggleFlags), options.toggleFlags)
158
+ });
159
+ const appDependencies = require(paths.paths.appPackageJson).dependencies;
160
+ return {
161
+ // Don't attempt to continue if there are any errors.
162
+ bail: true,
163
+ // https://webpack.js.org/concepts/#mode
164
+ mode: 'production',
165
+ // We generate sourcemaps in production. This is slow but gives good results.
166
+ // Sourcemaps are pushed to Google Storage and Sentry.
167
+ // https://webpack.js.org/configuration/devtool/#devtool
168
+ devtool: 'source-map',
169
+ // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
170
+ // https://medium.com/webpack/webpack-4-mode-and-optimization-5423a6bc597a
171
+ optimization: {
172
+ minimizer: _filterInstanceProperty__default["default"](_context = [new TerserPlugin__default["default"]({
173
+ terserOptions: {
174
+ parse: {
175
+ // we want terser to parse ecma 8 code. However, we don't want it
176
+ // to apply any minification steps that turns valid ecma 5 code
177
+ // into invalid ecma 5 code. This is why the 'compress' and 'output'
178
+ // sections only apply transformations that are ecma 5 safe
179
+ // https://github.com/facebook/create-react-app/pull/4234
180
+ ecma: 2018
181
+ },
182
+ compress: {
183
+ ecma: 5,
184
+ // Disabled because of an issue with Uglify breaking seemingly valid code:
185
+ // https://github.com/facebook/create-react-app/issues/2376
186
+ // Pending further investigation:
187
+ // https://github.com/mishoo/UglifyJS2/issues/2011
188
+ comparisons: false,
189
+ // Disabled because of an issue with Terser breaking valid code:
190
+ // https://github.com/facebook/create-react-app/issues/5250
191
+ // Pending futher investigation:
192
+ // https://github.com/terser-js/terser/issues/120
193
+ inline: 2
194
+ },
195
+ mangle: {
196
+ safari10: true
197
+ },
198
+ // Added for profiling in devtools
199
+ keep_classnames: true,
200
+ keep_fnames: true,
201
+ output: {
202
+ ecma: 5,
203
+ comments: false,
204
+ // Turned on because emoji and regex is not minified properly using default
205
+ // https://github.com/facebook/create-react-app/issues/2488
206
+ ascii_only: true
207
+ }
208
+ },
209
+ // Use multi-process parallel running to improve the build speed
210
+ // Default number of concurrent runs: os.cpus().length - 1
211
+ parallel: mergedOptions.toggleFlags.parallelism
212
+ }), mergedOptions.toggleFlags.enableExtractCss && new CssMinimizerPlugin__default["default"]()]).call(_context, Boolean),
213
+ // Keep the runtime chunk separated to enable long term caching
214
+ runtimeChunk: {
215
+ name: 'runtime'
216
+ },
217
+ splitChunks: {
218
+ cacheGroups: optimizations.getWepbackCacheGroups(appDependencies)
219
+ },
220
+ moduleIds: 'named',
221
+ chunkIds: 'deterministic'
222
+ },
223
+ resolve: {
224
+ // These are the reasonable defaults supported by the Node ecosystem.
225
+ // We also include JSX as a common component filename extension to support
226
+ // some tools, although we do not recommend using it, see:
227
+ // https://github.com/facebook/create-react-app/issues/290
228
+ // `web` extension prefixes have been added for better support
229
+ // for React Native Web.
230
+ extensions: _mapInstanceProperty__default["default"](_context2 = ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx']).call(_context2, ext => `.${ext}`),
231
+ // NOTE: this is meant to be a temporary list of fallback/polyfills for certain
232
+ // nodejs modules. With Webpack <5 these polyfills were included by default in Webpack,
233
+ // however now it's not the case anymore.
234
+ // See also related work in CRA: https://github.com/facebook/create-react-app/pull/11764
235
+ fallback: {
236
+ querystring: require.resolve('querystring-es3')
237
+ }
238
+ },
239
+ // In production, we only want to load the polyfills and the app code.
240
+ entry: {
241
+ app: _filterInstanceProperty__default["default"](_context3 = [require.resolve('@commercetools-frontend/mc-scripts/application-runtime'), !mergedOptions.toggleFlags.disableCoreJs && require.resolve('core-js/stable'), mergedOptions.entryPoint]).call(_context3, Boolean)
242
+ },
243
+ output: {
244
+ // Generated JS file names (with nested folders).
245
+ // There will be one main bundle, and one file per asynchronous chunk.
246
+ filename: '[name].[chunkhash].js',
247
+ chunkFilename: '[id].[name].[chunkhash].js',
248
+ // The build folder.
249
+ path: paths.paths.appBuild,
250
+ pathinfo: false,
251
+ // Will be injected on runtime. See `packages/application-shell/src/public-path.js`
252
+ publicPath: ''
253
+ },
254
+ plugins: _filterInstanceProperty__default["default"](_context4 = [
255
+ // Allows to "assign" custom options to the `webpack` object.
256
+ // At the moment, this is used to share some props with `postcss.config`.
257
+ new webpack__default["default"].LoaderOptionsPlugin({
258
+ options: {
259
+ sourceFolders: mergedOptions.sourceFolders,
260
+ context: __dirname
261
+ }
262
+ }),
263
+ // Makes some environment variables available to the JS code, for example:
264
+ // if (process.env.NODE_ENV === 'production') { ... }.
265
+ new webpack__default["default"].DefinePlugin({
266
+ __DEV__: 'false',
267
+ 'process.env': {
268
+ NODE_ENV: _JSON$stringify__default["default"]('production')
269
+ }
270
+ }),
271
+ // Only keep locales that are available in the Merchant Center.
272
+ new MomentLocalesPlugin__default["default"]({
273
+ localesToKeep: momentLocalesToKeep
274
+ }),
275
+ // Generate a `stats.json` file containing information and paths to
276
+ // the assets that webpack created.
277
+ // This is necessary to programmatically refer to the correct bundle path
278
+ // in the `index.html`.
279
+ new FinalStatsWriterPlugin({
280
+ outputPath: paths.paths.appBuild,
281
+ includeFields: ['entrypoints', 'assets', 'publicPath', 'time']
282
+ }), mergedOptions.toggleFlags.generateIndexHtml && new HtmlWebpackPlugin__default["default"]({
283
+ inject: false,
284
+ filename: 'index.html.template',
285
+ template: require.resolve('@commercetools-frontend/mc-html-template/webpack')
286
+ }), mergedOptions.toggleFlags.enableExtractCss &&
287
+ // Extracts CSS into one CSS file to mimic CSS order in dev
288
+ new MiniCssExtractPlugin__default["default"]({
289
+ filename: '[name].[chunkhash].css',
290
+ chunkFilename: '[id].[name].[chunkhash].css'
291
+ }), process.env.ANALYZE_BUNDLE === 'true' && new webpackBundleAnalyzer.BundleAnalyzerPlugin({
292
+ defaultSizes: 'gzip'
293
+ })]).call(_context4, Boolean),
294
+ module: {
295
+ // Makes missing exports an error instead of warning.
296
+ strictExportPresence: true,
297
+ rules: _filterInstanceProperty__default["default"](_context5 = [
298
+ // For svg icons, we want to get them transformed into React components
299
+ // when we import them.
300
+ {
301
+ test: /\.react\.svg$/,
302
+ use: [{
303
+ loader: require.resolve('babel-loader'),
304
+ options: {
305
+ babelrc: false,
306
+ presets: [[require.resolve('@commercetools-frontend/babel-preset-mc-app'), {
307
+ runtime: hasJsxRuntime.hasJsxRuntime() ? 'automatic' : 'classic',
308
+ disableCoreJs: mergedOptions.toggleFlags.disableCoreJs
309
+ }]],
310
+ // This is a feature of `babel-loader` for webpack (not Babel itself).
311
+ // It enables caching results in ./node_modules/.cache/babel-loader/
312
+ // directory for faster rebuilds.
313
+ cacheDirectory: true,
314
+ highlightCode: true
315
+ }
316
+ }, {
317
+ loader: require.resolve('@svgr/webpack'),
318
+ options: {
319
+ icon: false,
320
+ svgoConfig: {
321
+ plugins: [{
322
+ // https://github.com/svg/svgo#default-preset
323
+ name: 'preset-default',
324
+ params: {
325
+ overrides: {
326
+ removeViewBox: false
327
+ }
328
+ }
329
+ },
330
+ // Avoid collisions with ids in other SVGs,
331
+ // which was causing incorrect masking, gradient directions, etc
332
+ // this is an ongoing issue with both SVGR and SVGO,
333
+ // https://github.com/svg/svgo/issues/913#issuecomment-369373572
334
+ // see SVGR issues:
335
+ // https://github.com/gregberge/svgr/issues/322
336
+ // https://github.com/gregberge/svgr/issues/210
337
+ // see SVGO issues:
338
+ // https://github.com/svg/svgo/issues/674
339
+ // https://github.com/svg/svgo/issues/1746
340
+ //
341
+ // Initially, a naive counter was implemented based on this github comment:
342
+ // https://github.com/svg/svgo/issues/1746#issuecomment-1803600573
343
+ // But while that implementation insured id’s that are unique,
344
+ // it did not work in cases where the id is both declared and referenced in the same file,
345
+ // because the refernce gets a separate unique ID (a different number from the counter).
346
+ //
347
+ // The current implementation is based on this github comment:
348
+ // https://github.com/svg/svgo/issues/913#issuecomment-369373572
349
+ // Generates a hash of the filepath of the svg file, resulting in a prefix which is:
350
+ // - Short,
351
+ // - With characters valid for IDs,
352
+ // - The same within a file,
353
+ // - And different in different files.
354
+ {
355
+ name: 'prefixIds',
356
+ params: {
357
+ delim: '',
358
+ prefix: (_, info) => `svg${crypto__default["default"].createHash('shake256', {
359
+ outputLength: 6
360
+ }).update(info.path || '').digest('hex')}`
361
+ }
362
+ }]
363
+ }
364
+ }
365
+ }]
366
+ },
367
+ // For normal svg files (not icons) we should load the file normally
368
+ // and simply use it as a `<img src/>`.
369
+ {
370
+ test: function testForNormalSvgFiles(fileName) {
371
+ return (
372
+ // Use this only for plain SVG.
373
+ // For SVG as React components, see loader above.
374
+ _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.svg') && !_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.react.svg')
375
+ );
376
+ },
377
+ use: [{
378
+ loader: require.resolve('svg-url-loader')
379
+ }]
380
+ }, {
381
+ test: /\.png$/,
382
+ type: 'asset/resource'
383
+ },
384
+ // "postcss" loader applies autoprefixer to our CSS
385
+ // "css" loader resolves paths in CSS and adds assets as dependencies.
386
+ // "style" loader turns CSS into JS modules that inject <style> tags.
387
+ // In production, we use MiniCSSExtractPlugin to extract that CSS
388
+ // to a file, but in development "style" loader enables hot editing
389
+ // of CSS.
390
+ // By default we support CSS Modules with the extension `.mod.css` and `.module.css`.
391
+ {
392
+ test: /\.(mod|module)\.css$/,
393
+ include: mergedOptions.sourceFolders,
394
+ use: [mergedOptions.toggleFlags.enableExtractCss ? MiniCssExtractPlugin__default["default"].loader : require.resolve('style-loader'), {
395
+ loader: require.resolve('css-loader'),
396
+ options: {
397
+ modules: {
398
+ mode: 'local',
399
+ localIdentName: '[name]__[local]___[hash:base64:5]',
400
+ localIdentHashSalt: 'ct'
401
+ },
402
+ importLoaders: 1
403
+ }
404
+ }, {
405
+ loader: require.resolve('postcss-loader'),
406
+ options: {
407
+ postcssOptions: createPostcssConfig.createPostcssConfig(mergedOptions.postcssOptions)
408
+ }
409
+ }]
410
+ }, {
411
+ test: function testForNormalCssFiles(fileName) {
412
+ return (
413
+ // Use this only for plain CSS.
414
+ // For css-modules, see loader above.
415
+ _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.css') && !(_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.mod.css') || _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.module.css'))
416
+ );
417
+ },
418
+ // "postcss" loader applies autoprefixer to our CSS.
419
+ // "css" loader resolves paths in CSS and adds assets as dependencies.
420
+ // "MiniCssExtractPlugin" or "style" loader extracts css to one file per css file.
421
+ oneOf: [{
422
+ // Use "postcss" for all the included source folders.
423
+ include: mergedOptions.sourceFolders,
424
+ use: [mergedOptions.toggleFlags.enableExtractCss ? MiniCssExtractPlugin__default["default"].loader : require.resolve('style-loader'), {
425
+ loader: require.resolve('css-loader'),
426
+ options: {
427
+ modules: {
428
+ mode: 'icss'
429
+ },
430
+ importLoaders: 1
431
+ }
432
+ }, {
433
+ loader: require.resolve('postcss-loader'),
434
+ options: {
435
+ postcssOptions: createPostcssConfig.createPostcssConfig(mergedOptions.postcssOptions)
436
+ }
437
+ }]
438
+ }, {
439
+ // For all other vendor CSS, do not use "postcss" loader.
440
+ // But still use MiniCssExtractPlugin :)
441
+ include: /node_modules/,
442
+ use: [mergedOptions.toggleFlags.enableExtractCss ? MiniCssExtractPlugin__default["default"].loader : require.resolve('style-loader'), {
443
+ loader: require.resolve('css-loader'),
444
+ options: {
445
+ modules: {
446
+ mode: 'icss'
447
+ },
448
+ importLoaders: 1
449
+ }
450
+ }],
451
+ // Don't consider CSS imports dead code even if the
452
+ // containing package claims to have no side effects.
453
+ // Remove this when webpack adds a warning or an error for this.
454
+ // See https://github.com/webpack/webpack/issues/6571
455
+ sideEffects: true
456
+ }]
457
+ },
458
+ // Fix for react-intl
459
+ // https://github.com/formatjs/formatjs/issues/143#issuecomment-518774786
460
+ {
461
+ test: /\.mjs$/,
462
+ type: 'javascript/auto',
463
+ resolve: {
464
+ // https://webpack.js.org/configuration/module/#resolvefullyspecified
465
+ fullySpecified: false
466
+ }
467
+ },
468
+ // Process application JavaScript with Babel.
469
+ {
470
+ test: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
471
+ use: [
472
+ // This loader parallelizes code compilation, it is optional but
473
+ // improves compile time on larger projects
474
+ {
475
+ loader: require.resolve('thread-loader'),
476
+ options: _objectSpread({}, _Number$isInteger__default["default"](mergedOptions.toggleFlags.parallelism) ? {
477
+ workers: mergedOptions.toggleFlags.parallelism
478
+ } : {})
479
+ }, {
480
+ loader: require.resolve('babel-loader'),
481
+ options: {
482
+ babelrc: false,
483
+ configFile: false,
484
+ compact: false,
485
+ presets: [[require.resolve('@commercetools-frontend/babel-preset-mc-app'), {
486
+ runtime: hasJsxRuntime.hasJsxRuntime() ? 'automatic' : 'classic'
487
+ }]],
488
+ // This is a feature of `babel-loader` for webpack (not Babel itself).
489
+ // It enables caching results in ./node_modules/.cache/babel-loader/
490
+ // directory for faster rebuilds.
491
+ cacheDirectory: true,
492
+ highlightCode: true
493
+ }
494
+ }],
495
+ include: _concatInstanceProperty__default["default"](_context6 = mergedOptions.sourceFolders).call(_context6, vendorsToTranspile.vendorsToTranspile),
496
+ // Disable require.ensure as it's not a standard language feature.
497
+ parser: {
498
+ requireEnsure: false
499
+ }
500
+ },
501
+ // Allow to import `*.graphql` SDL files.
502
+ {
503
+ test: /\.graphql$/,
504
+ include: mergedOptions.sourceFolders,
505
+ exclude: /node_modules/,
506
+ use: [require.resolve('graphql-tag/loader')]
507
+ }, !(process.env.DISABLE_I18N_MESSAGE_COMPILATION === 'true') && {
508
+ test: /i18n\/data\/.*\.json$/,
509
+ use: [require.resolve('@commercetools-frontend/mc-scripts/webpack-loaders/i18n-message-compilation-loader')]
510
+ }]).call(_context5, Boolean)
511
+ },
512
+ // Turn off performance processing because we utilize
513
+ // our own hints via the FileSizeReporter
514
+ performance: false
515
+ };
516
+ }
517
+
518
+ exports.createWebpackConfigForProduction = createWebpackConfigForProduction;