@commercetools-frontend/mc-scripts 21.7.0 → 21.8.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 (145) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -42
  3. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +1 -0
  4. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
  5. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
  6. package/{build/config/application-runtime.js → application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js} +2 -2
  7. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
  8. package/application-runtime/package.json +4 -0
  9. package/bin/cli.js +1 -1
  10. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +1 -0
  11. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +354 -0
  12. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
  13. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +354 -0
  14. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +338 -0
  15. package/cli/package.json +4 -0
  16. package/config/create-webpack-config-for-development.js +7 -1
  17. package/config/create-webpack-config-for-production.js +7 -1
  18. package/config/vendors-to-transpile.js +5 -1
  19. package/dist/build-8582b673.esm.js +209 -0
  20. package/dist/build-9395925a.cjs.prod.js +224 -0
  21. package/dist/build-97278377.cjs.dev.js +224 -0
  22. package/dist/build-vite-6c987a60.cjs.dev.js +109 -0
  23. package/dist/build-vite-76d44332.cjs.prod.js +109 -0
  24. package/dist/build-vite-a9602b19.esm.js +97 -0
  25. package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +1 -0
  26. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +30 -0
  27. package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
  28. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +30 -0
  29. package/dist/commercetools-frontend-mc-scripts.esm.js +22 -0
  30. package/dist/compile-html-0c588a89.cjs.dev.js +93 -0
  31. package/dist/compile-html-4832f8c5.esm.js +83 -0
  32. package/dist/compile-html-7654b5e6.cjs.prod.js +93 -0
  33. package/dist/config-sync-20bc05e8.esm.js +868 -0
  34. package/dist/config-sync-62824317.cjs.prod.js +887 -0
  35. package/dist/config-sync-d52e73f6.cjs.dev.js +892 -0
  36. package/dist/create-postcss-config-4cbe10ab.cjs.dev.js +90 -0
  37. package/dist/create-postcss-config-8ea16440.cjs.prod.js +90 -0
  38. package/{build/config/create-postcss-config.js → dist/create-postcss-config-c1aa3525.esm.js} +27 -25
  39. package/{build/config/create-webpack-config-for-development.js → dist/create-webpack-config-for-development-8a8b84d6.esm.js} +92 -56
  40. package/dist/create-webpack-config-for-development-a5e73092.cjs.prod.js +418 -0
  41. package/dist/create-webpack-config-for-development-e2735e02.cjs.dev.js +418 -0
  42. package/dist/create-webpack-config-for-production-4e7b56c0.cjs.prod.js +468 -0
  43. package/{build/config/create-webpack-config-for-production.js → dist/create-webpack-config-for-production-7dc669e5.esm.js} +117 -52
  44. package/dist/create-webpack-config-for-production-d9bf281c.cjs.dev.js +468 -0
  45. package/dist/declarations/src/application-runtime.d.ts +1 -0
  46. package/dist/declarations/src/cli.d.ts +4 -0
  47. package/dist/declarations/src/commands/build-vite.d.ts +2 -0
  48. package/dist/declarations/src/commands/build.d.ts +2 -0
  49. package/dist/declarations/src/commands/compile-html.d.ts +3 -0
  50. package/dist/declarations/src/commands/config-sync.d.ts +3 -0
  51. package/dist/declarations/src/commands/login.d.ts +2 -0
  52. package/dist/declarations/src/commands/serve.d.ts +2 -0
  53. package/dist/declarations/src/commands/start-vite.d.ts +2 -0
  54. package/dist/declarations/src/commands/start.d.ts +2 -0
  55. package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
  56. package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
  57. package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
  58. package/dist/declarations/src/config/has-jsx-runtime.d.ts +2 -0
  59. package/dist/declarations/src/config/paths.d.ts +12 -0
  60. package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
  61. package/dist/declarations/src/config/webpack-dev-server.config.d.ts +6 -0
  62. package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
  63. package/dist/declarations/src/generated/core.d.ts +710 -0
  64. package/dist/declarations/src/generated/settings.d.ts +2383 -0
  65. package/dist/declarations/src/index.d.ts +3 -0
  66. package/dist/declarations/src/postcss.d.ts +1 -0
  67. package/dist/declarations/src/types.d.ts +82 -0
  68. package/dist/declarations/src/utils/auth.d.ts +6 -0
  69. package/dist/declarations/src/utils/credentials-storage.d.ts +11 -0
  70. package/dist/declarations/src/utils/get-config-diff.d.ts +3 -0
  71. package/dist/declarations/src/utils/graphql-requests.d.ts +80 -0
  72. package/dist/declarations/src/utils/user-agent.d.ts +2 -0
  73. package/dist/declarations/src/version.d.ts +2 -0
  74. package/dist/declarations/src/webpack-plugins/final-stats-writer-plugin.d.ts +12 -0
  75. package/dist/declarations/src/webpack-plugins/local-html-webpack-plugin.d.ts +5 -0
  76. package/dist/declarations/src/webpack.d.ts +2 -0
  77. package/dist/has-jsx-runtime-0b03b72e.cjs.prod.js +17 -0
  78. package/dist/has-jsx-runtime-3d4bb633.cjs.dev.js +17 -0
  79. package/{build/config/has-jsx-runtime.js → dist/has-jsx-runtime-8314226e.esm.js} +1 -3
  80. package/dist/login-706ccc9a.cjs.prod.js +165 -0
  81. package/dist/login-779552b7.cjs.dev.js +165 -0
  82. package/dist/login-7d94659e.esm.js +155 -0
  83. package/dist/package-a98de907.esm.js +133 -0
  84. package/dist/package-aaf61bf0.cjs.dev.js +135 -0
  85. package/dist/package-b5c040f3.cjs.prod.js +135 -0
  86. package/dist/paths-16823f56.cjs.dev.js +55 -0
  87. package/dist/paths-76b66e74.cjs.prod.js +55 -0
  88. package/dist/paths-ed23d5a1.esm.js +46 -0
  89. package/dist/serve-12de323b.cjs.dev.js +70 -0
  90. package/dist/serve-784f4fcd.cjs.prod.js +70 -0
  91. package/dist/serve-d6b437b1.esm.js +62 -0
  92. package/dist/start-2b953ab0.cjs.dev.js +209 -0
  93. package/dist/start-e3ccd672.cjs.prod.js +209 -0
  94. package/dist/start-e924bd5d.esm.js +194 -0
  95. package/dist/start-vite-737bacca.cjs.dev.js +149 -0
  96. package/dist/start-vite-b0f58ae4.cjs.prod.js +149 -0
  97. package/dist/start-vite-ec5d40b5.esm.js +136 -0
  98. package/dist/user-agent-5da1830b.cjs.dev.js +106 -0
  99. package/dist/user-agent-8044acd6.esm.js +94 -0
  100. package/dist/user-agent-d18809af.cjs.prod.js +106 -0
  101. package/dist/vendors-to-transpile-367e0ba8.cjs.prod.js +5 -0
  102. package/dist/vendors-to-transpile-68e03526.esm.js +3 -0
  103. package/dist/vendors-to-transpile-b51af5d3.cjs.dev.js +5 -0
  104. package/package.json +41 -39
  105. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +1 -0
  106. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +14 -0
  107. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
  108. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +14 -0
  109. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +6 -0
  110. package/postcss/package.json +4 -0
  111. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +1 -0
  112. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +51 -0
  113. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
  114. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +51 -0
  115. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +42 -0
  116. package/webpack/package.json +4 -0
  117. package/build/bin/cli.js +0 -264
  118. package/build/commands/build-vite.js +0 -91
  119. package/build/commands/build.js +0 -140
  120. package/build/commands/compile-html.js +0 -53
  121. package/build/commands/config-sync.js +0 -176
  122. package/build/commands/login.js +0 -60
  123. package/build/commands/serve.js +0 -37
  124. package/build/commands/start-vite.js +0 -138
  125. package/build/commands/start.js +0 -108
  126. package/build/config/paths.js +0 -38
  127. package/build/config/vendors-to-transpile.js +0 -3
  128. package/build/config/webpack-dev-server.config.js +0 -69
  129. package/build/index.js +0 -16
  130. package/build/utils/auth.js +0 -34
  131. package/build/utils/auth.spec.js +0 -61
  132. package/build/utils/create-custom-application.settings.graphql +0 -8
  133. package/build/utils/credentials-storage.js +0 -72
  134. package/build/utils/credentials-storage.spec.js +0 -69
  135. package/build/utils/fetch-custom-application.settings.graphql +0 -36
  136. package/build/utils/fetch-user-organizations.core.graphql +0 -9
  137. package/build/utils/get-config-diff.js +0 -308
  138. package/build/utils/get-config-diff.spec.js +0 -285
  139. package/build/utils/graphql-requests.js +0 -105
  140. package/build/utils/graphql-requests.spec.js +0 -159
  141. package/build/utils/require-graphql.js +0 -15
  142. package/build/utils/update-custom-application.settings.graphql +0 -13
  143. package/build/utils/user-agent.js +0 -15
  144. package/build/webpack-plugins/final-stats-writer-plugin.js +0 -50
  145. package/build/webpack-plugins/local-html-webpack-plugin.js +0 -38
@@ -0,0 +1,468 @@
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 webpack = require('webpack');
18
+ var HtmlWebpackPlugin = require('html-webpack-plugin');
19
+ var webpackBundleAnalyzer = require('webpack-bundle-analyzer');
20
+ var CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
21
+ var MiniCssExtractPlugin = require('mini-css-extract-plugin');
22
+ var MomentLocalesPlugin = require('moment-locales-webpack-plugin');
23
+ var TerserPlugin = require('terser-webpack-plugin');
24
+ var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
25
+ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
26
+ var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
27
+ var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
28
+ var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
29
+ var fs = require('fs');
30
+ var path = require('path');
31
+ var paths = require('./paths-16823f56.cjs.dev.js');
32
+ var vendorsToTranspile = require('./vendors-to-transpile-b51af5d3.cjs.dev.js');
33
+ var createPostcssConfig = require('./create-postcss-config-4cbe10ab.cjs.dev.js');
34
+ var hasJsxRuntime = require('./has-jsx-runtime-3d4bb633.cjs.dev.js');
35
+
36
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
37
+
38
+ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
39
+ var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
40
+ var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
41
+ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
42
+ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
43
+ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
44
+ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
45
+ var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
46
+ var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
47
+ var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
48
+ var _endsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_endsWithInstanceProperty);
49
+ var _Number$isInteger__default = /*#__PURE__*/_interopDefault(_Number$isInteger);
50
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
51
+ var webpack__default = /*#__PURE__*/_interopDefault(webpack);
52
+ var HtmlWebpackPlugin__default = /*#__PURE__*/_interopDefault(HtmlWebpackPlugin);
53
+ var CssMinimizerPlugin__default = /*#__PURE__*/_interopDefault(CssMinimizerPlugin);
54
+ var MiniCssExtractPlugin__default = /*#__PURE__*/_interopDefault(MiniCssExtractPlugin);
55
+ var MomentLocalesPlugin__default = /*#__PURE__*/_interopDefault(MomentLocalesPlugin);
56
+ var TerserPlugin__default = /*#__PURE__*/_interopDefault(TerserPlugin);
57
+ var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
58
+ var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
59
+ var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
60
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
61
+ var path__default = /*#__PURE__*/_interopDefault(path);
62
+
63
+ var FinalStatsWriterPlugin = /*#__PURE__*/function () {
64
+ // Expected options:
65
+ // - `outputPath`
66
+ // - `includeFields`
67
+ function FinalStatsWriterPlugin(config) {
68
+ _classCallCheck(this, FinalStatsWriterPlugin);
69
+
70
+ this.config = void 0;
71
+ if (!config) throw new Error('Missing config options');
72
+ this.config = config;
73
+ }
74
+
75
+ _createClass(FinalStatsWriterPlugin, [{
76
+ key: "apply",
77
+ value: function apply(compiler) {
78
+ // This is the only hook that return the `stats` plugin
79
+ // with the `time` info. It also contains all the stats that
80
+ // we would get from the original `emit` hook.
81
+ // https://webpack.js.org/api/compiler-hooks/#done
82
+ // https://webpack.js.org/api/plugins/#plugin-types
83
+ if (compiler.hooks) {
84
+ var _context;
85
+
86
+ compiler.hooks.done.tap('custom-stats-writer-plugin', _bindInstanceProperty__default["default"](_context = this.writeStats).call(_context, this));
87
+ } else {
88
+ var _context2;
89
+
90
+ // @ts-ignore
91
+ compiler.plugin('done', _bindInstanceProperty__default["default"](_context2 = this.writeStats).call(_context2, this));
92
+ }
93
+ }
94
+ }, {
95
+ key: "writeStats",
96
+ value: function writeStats(stats) {
97
+ var finalStats = stats.toJson(); // Filter only included fields
98
+
99
+ if (this.config.includeFields) {
100
+ var _context3;
101
+
102
+ finalStats = _reduceInstanceProperty__default["default"](_context3 = this.config.includeFields).call(_context3, function (aggregatedStats, key) {
103
+ return (// eslint-disable-next-line
104
+ _Object$assign__default["default"]({}, aggregatedStats, _defineProperty({}, key, finalStats[key]))
105
+ );
106
+ }, {});
107
+ }
108
+
109
+ try {
110
+ fs__default["default"].accessSync(this.config.outputPath, fs__default["default"].constants.F_OK);
111
+ fs__default["default"].writeFileSync(path__default["default"].join(this.config.outputPath, 'stats.json'), _JSON$stringify__default["default"](finalStats, null, 2));
112
+ } catch (error) {
113
+ // eslint-disable-next-line no-console
114
+ console.warn("[FinalStatsWriterPlugin] The dist folder could not be found at ".concat(this.config.outputPath, ". Check the console for errors during the webpack compilation."));
115
+ }
116
+ }
117
+ }]);
118
+
119
+ return FinalStatsWriterPlugin;
120
+ }();
121
+
122
+ 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; }
123
+
124
+ 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; }
125
+ var defaultToggleFlags = {
126
+ // Allow to disable CSS extraction in case it's not necessary (e.g. for Storybook)
127
+ enableExtractCss: true,
128
+ // Allow to disable index.html generation in case it's not necessary (e.g. for Storybook)
129
+ generateIndexHtml: true,
130
+ // Some plugins spawn workers to speed up the build. However this can cause trouble on
131
+ // certain machines local and CI. This flag set to limit or disable any parallelism.
132
+ // Options:
133
+ // `true` to default to the machines number of CPUs
134
+ // `false` to disable any paralelism
135
+ // `int` for a specific number of CPUs
136
+ parallelism: true,
137
+ // Some environemnts do not require `core-js` and can hence disable
138
+ // it explicitely. This will disable `core-js` for `preset-env` and the
139
+ // `plugin-transform-runtime`.
140
+ disableCoreJs: false
141
+ };
142
+ var defaultOptions = {
143
+ entryPoint: paths.paths.entryPoint,
144
+ sourceFolders: paths.paths.sourceFolders,
145
+ postcssOptions: {},
146
+ toggleFlags: defaultToggleFlags
147
+ };
148
+ /**
149
+ * This is a factory function to create the default webpack config
150
+ * for a MC Application in `production` mode.
151
+ * The function requires the file path to the related application
152
+ * "entry point".
153
+ */
154
+
155
+ function createWebpackConfigForProduction() {
156
+ var _context, _context2, _context3, _context4, _context5, _context6;
157
+
158
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
159
+
160
+ var mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, defaultOptions), options), {}, {
161
+ toggleFlags: _objectSpread(_objectSpread({}, defaultToggleFlags), options.toggleFlags)
162
+ });
163
+
164
+ return {
165
+ // Don't attempt to continue if there are any errors.
166
+ bail: true,
167
+ // https://webpack.js.org/concepts/#mode
168
+ mode: 'production',
169
+ // We generate sourcemaps in production. This is slow but gives good results.
170
+ // Sourcemaps are pushed to Google Storage and Sentry.
171
+ // https://webpack.js.org/configuration/devtool/#devtool
172
+ devtool: 'source-map',
173
+ // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
174
+ // https://medium.com/webpack/webpack-4-mode-and-optimization-5423a6bc597a
175
+ optimization: {
176
+ minimizer: _filterInstanceProperty__default["default"](_context = [new TerserPlugin__default["default"]({
177
+ terserOptions: {
178
+ parse: {
179
+ // we want terser to parse ecma 8 code. However, we don't want it
180
+ // to apply any minification steps that turns valid ecma 5 code
181
+ // into invalid ecma 5 code. This is why the 'compress' and 'output'
182
+ // sections only apply transformations that are ecma 5 safe
183
+ // https://github.com/facebook/create-react-app/pull/4234
184
+ ecma: 2018
185
+ },
186
+ compress: {
187
+ ecma: 5,
188
+ warnings: false,
189
+ // Disabled because of an issue with Uglify breaking seemingly valid code:
190
+ // https://github.com/facebook/create-react-app/issues/2376
191
+ // Pending further investigation:
192
+ // https://github.com/mishoo/UglifyJS2/issues/2011
193
+ comparisons: false,
194
+ // Disabled because of an issue with Terser breaking valid code:
195
+ // https://github.com/facebook/create-react-app/issues/5250
196
+ // Pending futher investigation:
197
+ // https://github.com/terser-js/terser/issues/120
198
+ inline: 2
199
+ },
200
+ mangle: {
201
+ safari10: true
202
+ },
203
+ // Added for profiling in devtools
204
+ keep_classnames: true,
205
+ keep_fnames: true,
206
+ output: {
207
+ ecma: 5,
208
+ comments: false,
209
+ // Turned on because emoji and regex is not minified properly using default
210
+ // https://github.com/facebook/create-react-app/issues/2488
211
+ ascii_only: true
212
+ }
213
+ },
214
+ // Use multi-process parallel running to improve the build speed
215
+ // Default number of concurrent runs: os.cpus().length - 1
216
+ parallel: mergedOptions.toggleFlags.parallelism
217
+ }), mergedOptions.toggleFlags.enableExtractCss && new CssMinimizerPlugin__default["default"]()]).call(_context, Boolean),
218
+ // Keep the runtime chunk separated to enable long term caching
219
+ runtimeChunk: {
220
+ name: 'runtime'
221
+ },
222
+ moduleIds: 'named',
223
+ chunkIds: 'deterministic'
224
+ },
225
+ resolve: {
226
+ // These are the reasonable defaults supported by the Node ecosystem.
227
+ // We also include JSX as a common component filename extension to support
228
+ // some tools, although we do not recommend using it, see:
229
+ // https://github.com/facebook/create-react-app/issues/290
230
+ // `web` extension prefixes have been added for better support
231
+ // for React Native Web.
232
+ extensions: _mapInstanceProperty__default["default"](_context2 = ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx']).call(_context2, function (ext) {
233
+ return ".".concat(ext);
234
+ }),
235
+ // NOTE: this is meant to be a temporary list of fallback/polyfills for certain
236
+ // nodejs modules. With Webpack <5 these polyfills were included by default in Webpack,
237
+ // however now it's not the case anymore.
238
+ // See also related work in CRA: https://github.com/facebook/create-react-app/pull/11764
239
+ fallback: {
240
+ querystring: require.resolve('querystring-es3')
241
+ }
242
+ },
243
+ // In production, we only want to load the polyfills and the app code.
244
+ entry: {
245
+ 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)
246
+ },
247
+ output: {
248
+ // Generated JS file names (with nested folders).
249
+ // There will be one main bundle, and one file per asynchronous chunk.
250
+ filename: '[name].[chunkhash].js',
251
+ chunkFilename: '[id].[name].[chunkhash].js',
252
+ // The build folder.
253
+ path: paths.paths.appBuild,
254
+ pathinfo: false,
255
+ // Will be injected on runtime. See `packages/application-shell/src/public-path.js`
256
+ publicPath: ''
257
+ },
258
+ plugins: _filterInstanceProperty__default["default"](_context4 = [// Allows to "assign" custom options to the `webpack` object.
259
+ // At the moment, this is used to share some props with `postcss.config`.
260
+ new webpack__default["default"].LoaderOptionsPlugin({
261
+ options: {
262
+ sourceFolders: mergedOptions.sourceFolders,
263
+ context: __dirname
264
+ }
265
+ }), // Makes some environment variables available to the JS code, for example:
266
+ // if (process.env.NODE_ENV === 'production') { ... }.
267
+ new webpack__default["default"].DefinePlugin({
268
+ __DEV__: 'false',
269
+ 'process.env': {
270
+ NODE_ENV: _JSON$stringify__default["default"]('production')
271
+ }
272
+ }), // Strip all locales except `en`, `de`
273
+ // (`en` is built into Moment and can't be removed)
274
+ new MomentLocalesPlugin__default["default"]({
275
+ localesToKeep: ['de', 'es', 'fr', 'zh-cn', 'ja']
276
+ }), // Generate a `stats.json` file containing information and paths to
277
+ // the assets that webpack created.
278
+ // This is necessary to programmatically refer to the correct bundle path
279
+ // in the `index.html`.
280
+ new FinalStatsWriterPlugin({
281
+ outputPath: paths.paths.appBuild,
282
+ includeFields: ['entrypoints', 'assets', 'publicPath', 'time']
283
+ }), mergedOptions.toggleFlags.generateIndexHtml && new HtmlWebpackPlugin__default["default"]({
284
+ inject: false,
285
+ filename: 'index.html.template',
286
+ template: require.resolve('@commercetools-frontend/mc-html-template/webpack')
287
+ }), mergedOptions.toggleFlags.enableExtractCss && // 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 = [// For svg icons, we want to get them transformed into React components
298
+ // when we import them.
299
+ {
300
+ test: /\.react\.svg$/,
301
+ use: [{
302
+ loader: require.resolve('babel-loader'),
303
+ options: {
304
+ babelrc: false,
305
+ presets: [[require.resolve('@commercetools-frontend/babel-preset-mc-app'), {
306
+ runtime: hasJsxRuntime.hasJsxRuntime() ? 'automatic' : 'classic',
307
+ disableCoreJs: mergedOptions.toggleFlags.disableCoreJs
308
+ }]],
309
+ // This is a feature of `babel-loader` for webpack (not Babel itself).
310
+ // It enables caching results in ./node_modules/.cache/babel-loader/
311
+ // directory for faster rebuilds.
312
+ cacheDirectory: true,
313
+ highlightCode: true
314
+ }
315
+ }, {
316
+ loader: require.resolve('@svgr/webpack'),
317
+ options: {
318
+ icon: false,
319
+ svgoConfig: {
320
+ plugins: [{
321
+ // https://github.com/svg/svgo#default-preset
322
+ name: 'preset-default',
323
+ params: {
324
+ overrides: {
325
+ removeViewBox: false
326
+ }
327
+ }
328
+ }]
329
+ }
330
+ }
331
+ }]
332
+ }, // For normal svg files (not icons) we should load the file normally
333
+ // and simply use it as a `<img src/>`.
334
+ {
335
+ test: function testForNormalSvgFiles(fileName) {
336
+ return (// Use this only for plain SVG.
337
+ // For SVG as React components, see loader above.
338
+ _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.svg') && !_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.react.svg')
339
+ );
340
+ },
341
+ use: [{
342
+ loader: require.resolve('svg-url-loader')
343
+ }]
344
+ }, {
345
+ test: /\.png$/,
346
+ type: 'asset/resource'
347
+ }, // "postcss" loader applies autoprefixer to our CSS
348
+ // "css" loader resolves paths in CSS and adds assets as dependencies.
349
+ // "style" loader turns CSS into JS modules that inject <style> tags.
350
+ // In production, we use MiniCSSExtractPlugin to extract that CSS
351
+ // to a file, but in development "style" loader enables hot editing
352
+ // of CSS.
353
+ // By default we support CSS Modules with the extension `.mod.css` and `.module.css`.
354
+ {
355
+ test: /\.(mod|module)\.css$/,
356
+ include: mergedOptions.sourceFolders,
357
+ use: [mergedOptions.toggleFlags.enableExtractCss ? MiniCssExtractPlugin__default["default"].loader : require.resolve('style-loader'), {
358
+ loader: require.resolve('css-loader'),
359
+ options: {
360
+ modules: {
361
+ mode: 'local',
362
+ localIdentName: '[name]__[local]___[hash:base64:5]',
363
+ localIdentHashSalt: 'ct'
364
+ },
365
+ importLoaders: 1
366
+ }
367
+ }, {
368
+ loader: require.resolve('postcss-loader'),
369
+ options: {
370
+ postcssOptions: createPostcssConfig.createPostcssConfig(mergedOptions.postcssOptions)
371
+ }
372
+ }]
373
+ }, {
374
+ test: function testForNormalCssFiles(fileName) {
375
+ return (// Use this only for plain CSS.
376
+ // For css-modules, see loader above.
377
+ _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.css') && !(_endsWithInstanceProperty__default["default"](fileName).call(fileName, '.mod.css') || _endsWithInstanceProperty__default["default"](fileName).call(fileName, '.module.css'))
378
+ );
379
+ },
380
+ // "postcss" loader applies autoprefixer to our CSS.
381
+ // "css" loader resolves paths in CSS and adds assets as dependencies.
382
+ // "MiniCssExtractPlugin" or "style" loader extracts css to one file per css file.
383
+ oneOf: [{
384
+ // Use "postcss" for all the included source folders.
385
+ include: mergedOptions.sourceFolders,
386
+ use: [mergedOptions.toggleFlags.enableExtractCss ? MiniCssExtractPlugin__default["default"].loader : require.resolve('style-loader'), {
387
+ loader: require.resolve('css-loader'),
388
+ options: {
389
+ modules: {
390
+ mode: 'icss'
391
+ },
392
+ importLoaders: 1
393
+ }
394
+ }, {
395
+ loader: require.resolve('postcss-loader'),
396
+ options: {
397
+ postcssOptions: createPostcssConfig.createPostcssConfig(mergedOptions.postcssOptions)
398
+ }
399
+ }]
400
+ }, {
401
+ // For all other vendor CSS, do not use "postcss" loader.
402
+ // But still use MiniCssExtractPlugin :)
403
+ include: /node_modules/,
404
+ use: [mergedOptions.toggleFlags.enableExtractCss ? MiniCssExtractPlugin__default["default"].loader : require.resolve('style-loader'), {
405
+ loader: require.resolve('css-loader'),
406
+ options: {
407
+ modules: {
408
+ mode: 'icss'
409
+ },
410
+ importLoaders: 1
411
+ }
412
+ }]
413
+ }]
414
+ }, // Fix for react-intl
415
+ // https://github.com/formatjs/formatjs/issues/143#issuecomment-518774786
416
+ {
417
+ test: /\.mjs$/,
418
+ type: 'javascript/auto',
419
+ resolve: {
420
+ // https://webpack.js.org/configuration/module/#resolvefullyspecified
421
+ fullySpecified: false
422
+ }
423
+ }, // Process application JavaScript with Babel.
424
+ {
425
+ test: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
426
+ use: [// This loader parallelizes code compilation, it is optional but
427
+ // improves compile time on larger projects
428
+ {
429
+ loader: require.resolve('thread-loader'),
430
+ options: _objectSpread({}, _Number$isInteger__default["default"](mergedOptions.toggleFlags.parallelism) ? {
431
+ workers: mergedOptions.toggleFlags.parallelism
432
+ } : {})
433
+ }, {
434
+ loader: require.resolve('babel-loader'),
435
+ options: {
436
+ babelrc: false,
437
+ configFile: false,
438
+ compact: false,
439
+ presets: [[require.resolve('@commercetools-frontend/babel-preset-mc-app'), {
440
+ runtime: hasJsxRuntime.hasJsxRuntime() ? 'automatic' : 'classic'
441
+ }]],
442
+ // This is a feature of `babel-loader` for webpack (not Babel itself).
443
+ // It enables caching results in ./node_modules/.cache/babel-loader/
444
+ // directory for faster rebuilds.
445
+ cacheDirectory: true,
446
+ highlightCode: true
447
+ }
448
+ }],
449
+ include: _concatInstanceProperty__default["default"](_context6 = mergedOptions.sourceFolders).call(_context6, vendorsToTranspile.vendorsToTranspile),
450
+ // Disable require.ensure as it's not a standard language feature.
451
+ parser: {
452
+ requireEnsure: false
453
+ }
454
+ }, // Allow to import `*.graphql` SDL files.
455
+ {
456
+ test: /\.graphql$/,
457
+ include: mergedOptions.sourceFolders,
458
+ exclude: /node_modules/,
459
+ use: [require.resolve('graphql-tag/loader')]
460
+ }]).call(_context5, Boolean)
461
+ },
462
+ // Turn off performance processing because we utilize
463
+ // our own hints via the FileSizeReporter
464
+ performance: false
465
+ };
466
+ }
467
+
468
+ exports.createWebpackConfigForProduction = createWebpackConfigForProduction;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { TCliGlobalOptions } from './types';
2
+ declare const run: () => void;
3
+ declare function loadDotEnvFiles(globalOptions: TCliGlobalOptions): void;
4
+ export { run, loadDotEnvFiles };
@@ -0,0 +1,2 @@
1
+ declare function run(): Promise<void>;
2
+ export default run;
@@ -0,0 +1,2 @@
1
+ declare function run(): Promise<void>;
2
+ export default run;
@@ -0,0 +1,3 @@
1
+ import type { TCliCommandCompileHtmlOptions } from '../types';
2
+ declare function run(options?: TCliCommandCompileHtmlOptions): Promise<void>;
3
+ export default run;
@@ -0,0 +1,3 @@
1
+ import type { TCliCommandConfigSyncOptions } from '../types';
2
+ declare function run(options?: TCliCommandConfigSyncOptions): Promise<void>;
3
+ export default run;
@@ -0,0 +1,2 @@
1
+ declare function run(): Promise<void>;
2
+ export default run;
@@ -0,0 +1,2 @@
1
+ declare function run(): Promise<void>;
2
+ export default run;
@@ -0,0 +1,2 @@
1
+ declare function run(): Promise<void>;
2
+ export default run;
@@ -0,0 +1,2 @@
1
+ declare function run(): Promise<void>;
2
+ export default run;
@@ -0,0 +1,4 @@
1
+ import type { Config } from 'postcss-load-config';
2
+ import type { TPostcssConfigOptions } from '../types';
3
+ declare function createPostcssConfig({ postcssImportPaths, postcssCustomMediaPaths, postcssCustomPropertiesPaths, }?: TPostcssConfigOptions): Config;
4
+ export default createPostcssConfig;
@@ -0,0 +1,10 @@
1
+ import { type Configuration } from 'webpack';
2
+ import type { TWebpackConfigOptions } from '../types';
3
+ /**
4
+ * This is a factory function to create the default webpack config
5
+ * for a MC Application in `development` mode.
6
+ * The function requires the file path to the related application
7
+ * "entry point".
8
+ */
9
+ declare function createWebpackConfigForDevelopment(options?: TWebpackConfigOptions<'development'>): Configuration;
10
+ export default createWebpackConfigForDevelopment;
@@ -0,0 +1,10 @@
1
+ import { type Configuration } from 'webpack';
2
+ import type { TWebpackConfigOptions } from '../types';
3
+ /**
4
+ * This is a factory function to create the default webpack config
5
+ * for a MC Application in `production` mode.
6
+ * The function requires the file path to the related application
7
+ * "entry point".
8
+ */
9
+ declare function createWebpackConfigForProduction(options?: TWebpackConfigOptions<'production'>): Configuration;
10
+ export default createWebpackConfigForProduction;
@@ -0,0 +1,2 @@
1
+ declare function hasJsxRuntime(): boolean;
2
+ export default hasJsxRuntime;
@@ -0,0 +1,12 @@
1
+ declare const paths: {
2
+ appPackageJson: string;
3
+ appBuild: string;
4
+ appIndexHtmlTemplate: string;
5
+ appIndexHtml: string;
6
+ appWebpackConfig: string;
7
+ yarnLockFile: string;
8
+ appRoot: string;
9
+ entryPoint: string;
10
+ sourceFolders: string[];
11
+ };
12
+ export default paths;
@@ -0,0 +1,2 @@
1
+ declare const vendorsToTranspile: string[];
2
+ export default vendorsToTranspile;
@@ -0,0 +1,6 @@
1
+ import type { Configuration } from 'webpack-dev-server';
2
+ declare const createWebpackDevServerConfig: ({ port, publicPath, }: {
3
+ port: number;
4
+ publicPath?: string | undefined;
5
+ }) => Configuration;
6
+ export default createWebpackDevServerConfig;
@@ -0,0 +1,7 @@
1
+ import type { Configuration } from 'webpack';
2
+ import type { Config } from 'postcss-load-config';
3
+ import type { TWebpackConfigOptions, TPostcssConfigOptions } from './types';
4
+ declare function createWebpackConfigForDevelopment(options?: TWebpackConfigOptions<'development'>): Configuration;
5
+ declare function createWebpackConfigForProduction(options?: TWebpackConfigOptions<'production'>): Configuration;
6
+ declare function createPostcssConfig(options?: TPostcssConfigOptions): Config;
7
+ export { createWebpackConfigForDevelopment, createWebpackConfigForProduction, createPostcssConfig, };