@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,438 @@
1
+ import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
2
+ import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
3
+ import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
4
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
5
+ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
6
+ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
7
+ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
8
+ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
9
+ import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
10
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
11
+ import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
12
+ import _endsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/ends-with';
13
+ import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
14
+ import crypto from 'crypto';
15
+ import path from 'path';
16
+ import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
17
+ import HtmlWebpackPlugin from 'html-webpack-plugin';
18
+ import MomentLocalesPlugin from 'moment-locales-webpack-plugin';
19
+ import webpack from 'webpack';
20
+ import WebpackBar from 'webpackbar';
21
+ import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
22
+ import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
23
+ import _Object$assign from '@babel/runtime-corejs3/core-js-stable/object/assign';
24
+ import { processConfig } from '@commercetools-frontend/application-config';
25
+ import { replaceHtmlPlaceholders } from '@commercetools-frontend/mc-html-template';
26
+ import { c as createPostcssConfig } from './create-postcss-config-2f709335.esm.js';
27
+ import { h as hasJsxRuntime } from './has-jsx-runtime-e3ecb09b.esm.js';
28
+ import { g as getWepbackCacheGroups } from './optimizations-bf991634.esm.js';
29
+ import { p as paths } from './paths-39f22b8b.esm.js';
30
+ import { v as vendorsToTranspile } from './vendors-to-transpile-7dc84a72.esm.js';
31
+
32
+ let LocalHtmlWebpackPlugin = /*#__PURE__*/function () {
33
+ function LocalHtmlWebpackPlugin() {
34
+ _classCallCheck(this, LocalHtmlWebpackPlugin);
35
+ }
36
+ _createClass(LocalHtmlWebpackPlugin, [{
37
+ key: "apply",
38
+ value: function apply(compiler) {
39
+ compiler.hooks.compilation.tap('LocalHtmlWebpackPlugin', compilation => {
40
+ HtmlWebpackPlugin.getHooks(compilation).beforeEmit.tapAsync('LocalHtmlWebpackPlugin', (data, cb) => {
41
+ const applicationConfig = processConfig();
42
+ const enhancedLocalEnv = _Object$assign({}, applicationConfig.env,
43
+ // Now that the app config is defined as a `env.json`, when we start the FE app
44
+ // to point to the local backend API by passing the `MC_API_URL` env does not
45
+ // work anymore). To make it work again, we can override the `env.json` config
46
+ // with the env variable before injecting the values into the index.html.
47
+ // NOTE: this is only necessary for development.
48
+ process.env.MC_API_URL ? {
49
+ mcApiUrl: process.env.MC_API_URL
50
+ } : {});
51
+ data.html = replaceHtmlPlaceholders(data.html, {
52
+ env: enhancedLocalEnv,
53
+ headers: {}
54
+ });
55
+ cb(null, data);
56
+ });
57
+ });
58
+ }
59
+ }]);
60
+ return LocalHtmlWebpackPlugin;
61
+ }();
62
+
63
+ function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
64
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
65
+ // https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
66
+ 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"];
67
+ const defaultToggleFlags = {
68
+ generateIndexHtml: true,
69
+ disableCoreJs: false
70
+ };
71
+ const defaultOptions = {
72
+ entryPoint: paths.entryPoint,
73
+ sourceFolders: paths.sourceFolders,
74
+ postcssOptions: {},
75
+ toggleFlags: defaultToggleFlags
76
+ };
77
+
78
+ // Whether or not `react-refresh` is enabled, `react-refresh` is not 100% stable at this time,
79
+ // which is why it's disabled by default.
80
+ const hasReactRefresh = process.env.FAST_REFRESH === 'true';
81
+ const webpackDevClientEntry = require.resolve('react-dev-utils/webpackHotDevClient');
82
+ const reactRefreshOverlayEntry = require.resolve('react-dev-utils/refreshOverlayInterop');
83
+
84
+ /**
85
+ * This is a factory function to create the default webpack config
86
+ * for a MC Application in `development` mode.
87
+ * The function requires the file path to the related application
88
+ * "entry point".
89
+ */
90
+ function createWebpackConfigForDevelopment() {
91
+ var _context, _context2, _context3, _context4, _context5;
92
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
93
+ const mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, defaultOptions), options), {}, {
94
+ toggleFlags: _objectSpread(_objectSpread({}, defaultToggleFlags), options.toggleFlags)
95
+ });
96
+ const appDependencies = require(paths.appPackageJson).dependencies;
97
+ return {
98
+ // https://webpack.js.org/concepts/#mode
99
+ mode: 'development',
100
+ // Using `cheap-module-source-map` doesn't provide the original source when
101
+ // errors happen but it is still recommended as using `eval-source-map` leads
102
+ // to CORS errors when an error happens
103
+ // https://webpack.js.org/configuration/devtool/#devtool
104
+ // https://reactjs.org/docs/cross-origin-errors.html#source-maps
105
+ devtool: 'cheap-module-source-map',
106
+ // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
107
+ // https://medium.com/webpack/webpack-4-mode-and-optimization-5423a6bc597a
108
+ optimization: {
109
+ // Keep the runtime chunk separated to enable long term caching
110
+ // https://twitter.com/wSokra/status/969679223278505985
111
+ // https://github.com/facebook/create-react-app/issues/5358
112
+ runtimeChunk: {
113
+ name: 'runtime'
114
+ },
115
+ splitChunks: {
116
+ cacheGroups: getWepbackCacheGroups(appDependencies)
117
+ },
118
+ moduleIds: 'named',
119
+ chunkIds: 'deterministic'
120
+ },
121
+ resolve: {
122
+ // These are the reasonable defaults supported by the Node ecosystem.
123
+ // We also include JSX as a common component filename extension to support
124
+ // some tools, although we do not recommend using it, see:
125
+ // https://github.com/facebook/create-react-app/issues/290
126
+ // `web` extension prefixes have been added for better support
127
+ // for React Native Web.
128
+ extensions: _mapInstanceProperty(_context = ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx']).call(_context, ext => `.${ext}`),
129
+ // NOTE: this is meant to be a temporary list of fallback/polyfills for certain
130
+ // nodejs modules. With Webpack <5 these polyfills were included by default in Webpack,
131
+ // however now it's not the case anymore.
132
+ // See also related work in CRA: https://github.com/facebook/create-react-app/pull/11764
133
+ fallback: {
134
+ url: require.resolve('url/'),
135
+ querystring: require.resolve('querystring-es3')
136
+ }
137
+ },
138
+ entry: {
139
+ app: _filterInstanceProperty(_context2 = [require.resolve('@commercetools-frontend/mc-scripts/application-runtime'), !mergedOptions.toggleFlags.disableCoreJs && require.resolve('core-js/stable'),
140
+ // When using the experimental `react-refresh` integration,
141
+ // the webpack plugin takes care of injecting the dev client for us.
142
+ !hasReactRefresh &&
143
+ // Include an alternative client for WebpackDevServer. A client's job is to
144
+ // connect to WebpackDevServer by a socket and get notified about changes.
145
+ // When you save a file, the client will either apply hot updates (in case
146
+ // of CSS changes), or refresh the page (in case of JS changes). When you
147
+ // make a syntax error, this client will display a syntax error overlay.
148
+ // Note: instead of the default WebpackDevServer client, we use a custom one
149
+ // to bring better experience for Create React App users. You can replace
150
+ // the line below with these two lines if you prefer the stock client:
151
+ //
152
+ // require.resolve('webpack-dev-server/client') + '?/',
153
+ // require.resolve('webpack/hot/dev-server'),
154
+ webpackDevClientEntry,
155
+ // Finally, this is your app's code
156
+ mergedOptions.entryPoint
157
+ // We include the app code last so that if there is a runtime error during
158
+ // initialization, it doesn't blow up the WebpackDevServer client, and
159
+ // changing JS code would still trigger a refresh.
160
+ ]).call(_context2, Boolean)
161
+ },
162
+ output: {
163
+ // This does not produce a real file. It's just the virtual path that is
164
+ // served by WebpackDevServer in development. This is the JS bundle
165
+ // containing code from all our entry points, and the Webpack runtime.
166
+ filename: '[name].js',
167
+ // There are also additional JS chunk files when using code splitting.
168
+ chunkFilename: '[name].chunk.js',
169
+ // The build folder.
170
+ path: paths.appBuild,
171
+ // Add /* filename */ comments to generated require()s in the output.
172
+ pathinfo: true,
173
+ // This is the URL that app is served from. We use "/" in development.
174
+ publicPath: '/',
175
+ // Point sourcemap entries to the original disk location (format as URL on Windows)
176
+ devtoolModuleFilenameTemplate: info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')
177
+ },
178
+ plugins: _filterInstanceProperty(_context3 = [new WebpackBar(),
179
+ // Allows to "assign" custom options to the `webpack` object.
180
+ // At the moment, this is used to share some props with `postcss.config`.
181
+ new webpack.LoaderOptionsPlugin({
182
+ options: {
183
+ sourceFolders: mergedOptions.sourceFolders,
184
+ context: __dirname
185
+ }
186
+ }),
187
+ // Makes some environment variables available to the JS code, for example:
188
+ // if (process.env.NODE_ENV === 'development') { ... }.
189
+ new webpack.DefinePlugin({
190
+ __DEV__: 'true',
191
+ 'process.env': {
192
+ NODE_ENV: _JSON$stringify('development')
193
+ }
194
+ }), mergedOptions.toggleFlags.generateIndexHtml && new HtmlWebpackPlugin({
195
+ inject: false,
196
+ filename: paths.appIndexHtml,
197
+ template: require.resolve('@commercetools-frontend/mc-html-template/webpack')
198
+ }), mergedOptions.toggleFlags.generateIndexHtml && new LocalHtmlWebpackPlugin(),
199
+ // Only keep locales that are available in the Merchant Center.
200
+ new MomentLocalesPlugin({
201
+ localesToKeep: momentLocalesToKeep
202
+ }),
203
+ // This is necessary to emit hot updates (CSS and Fast Refresh):
204
+ new webpack.HotModuleReplacementPlugin(),
205
+ // Experimental hot reloading for React .
206
+ // https://github.com/facebook/react/tree/master/packages/react-refresh
207
+ hasReactRefresh && new ReactRefreshWebpackPlugin({
208
+ overlay: {
209
+ entry: webpackDevClientEntry,
210
+ // The expected exports are slightly different from what the overlay exports,
211
+ // so an interop is included here to enable feedback on module-level errors.
212
+ module: reactRefreshOverlayEntry,
213
+ // Since we ship a custom dev client and overlay integration,
214
+ // the bundled socket handling logic can be eliminated.
215
+ sockIntegration: false
216
+ }
217
+ })]).call(_context3, Boolean),
218
+ module: {
219
+ // Makes missing exports an error instead of warning.
220
+ strictExportPresence: true,
221
+ rules: [
222
+ // For svg icons, we want to get them transformed into React components
223
+ // when we import them.
224
+ {
225
+ test: /\.react\.svg$/,
226
+ use: [{
227
+ loader: require.resolve('babel-loader'),
228
+ options: {
229
+ babelrc: false,
230
+ presets: [[require.resolve('@commercetools-frontend/babel-preset-mc-app'), {
231
+ runtime: hasJsxRuntime() ? 'automatic' : 'classic',
232
+ disableCoreJs: mergedOptions.toggleFlags.disableCoreJs
233
+ }]],
234
+ // This is a feature of `babel-loader` for webpack (not Babel itself).
235
+ // It enables caching results in ./node_modules/.cache/babel-loader/
236
+ // directory for faster rebuilds.
237
+ cacheDirectory: true,
238
+ highlightCode: true
239
+ }
240
+ }, {
241
+ loader: require.resolve('@svgr/webpack'),
242
+ options: {
243
+ icon: false,
244
+ svgoConfig: {
245
+ plugins: [{
246
+ // https://github.com/svg/svgo#default-preset
247
+ name: 'preset-default',
248
+ params: {
249
+ overrides: {
250
+ removeViewBox: false
251
+ }
252
+ }
253
+ },
254
+ // Avoid collisions with ids in other SVGs,
255
+ // which was causing incorrect masking, gradient directions, etc
256
+ // this is an ongoing issue with both SVGR and SVGO,
257
+ // https://github.com/svg/svgo/issues/913#issuecomment-369373572
258
+ // see SVGR issues:
259
+ // https://github.com/gregberge/svgr/issues/322
260
+ // https://github.com/gregberge/svgr/issues/210
261
+ // see SVGO issues:
262
+ // https://github.com/svg/svgo/issues/674
263
+ // https://github.com/svg/svgo/issues/1746
264
+ //
265
+ // Initially, a naive counter was implemented based on this github comment:
266
+ // https://github.com/svg/svgo/issues/1746#issuecomment-1803600573
267
+ // But while that implementation insured id’s that are unique,
268
+ // it did not work in cases where the id is both declared and referenced in the same file,
269
+ // because the refernce gets a separate unique ID (a different number from the counter).
270
+ //
271
+ // The current implementation is based on this github comment:
272
+ // https://github.com/svg/svgo/issues/913#issuecomment-369373572
273
+ // Generates a hash of the filepath of the svg file, resulting in a prefix which is:
274
+ // - Short,
275
+ // - With characters valid for IDs,
276
+ // - The same within a file,
277
+ // - And different in different files.
278
+ {
279
+ name: 'prefixIds',
280
+ params: {
281
+ delim: '',
282
+ prefix: (_, info) => `svg${crypto.createHash('shake256', {
283
+ outputLength: 6
284
+ }).update(info.path || '').digest('hex')}`
285
+ }
286
+ }]
287
+ }
288
+ }
289
+ }]
290
+ },
291
+ // For normal svg files (not icons) we should load the file normally
292
+ // and simply use it as a `<img src/>`.
293
+ {
294
+ test: function testForNormalSvgFiles(fileName) {
295
+ return (
296
+ // Use this only for plain SVG.
297
+ // For SVG as React components, see loader above.
298
+ _endsWithInstanceProperty(fileName).call(fileName, '.svg') && !_endsWithInstanceProperty(fileName).call(fileName, '.react.svg')
299
+ );
300
+ },
301
+ use: [{
302
+ loader: require.resolve('svg-url-loader')
303
+ }]
304
+ }, {
305
+ test: /\.png$/,
306
+ type: 'asset/resource'
307
+ },
308
+ // "postcss" loader applies autoprefixer to our CSS
309
+ // "css" loader resolves paths in CSS and adds assets as dependencies.
310
+ // "style" loader turns CSS into JS modules that inject <style> tags.
311
+ {
312
+ test: /\.(mod|module)\.css$/,
313
+ include: mergedOptions.sourceFolders,
314
+ use: [require.resolve('style-loader'), {
315
+ loader: require.resolve('css-loader'),
316
+ options: {
317
+ modules: {
318
+ mode: 'local',
319
+ localIdentName: '[name]__[local]___[hash:base64:5]',
320
+ localIdentHashSalt: 'ct'
321
+ },
322
+ importLoaders: 1
323
+ }
324
+ }, {
325
+ loader: require.resolve('postcss-loader'),
326
+ options: {
327
+ postcssOptions: createPostcssConfig(mergedOptions.postcssOptions)
328
+ }
329
+ }]
330
+ }, {
331
+ test: function testForNormalCssFiles(fileName) {
332
+ return (
333
+ // Use this only for plain CSS.
334
+ // For css-modules, see loader above.
335
+ _endsWithInstanceProperty(fileName).call(fileName, '.css') && !(_endsWithInstanceProperty(fileName).call(fileName, '.mod.css') || _endsWithInstanceProperty(fileName).call(fileName, '.module.css'))
336
+ );
337
+ },
338
+ // "postcss" loader applies autoprefixer to our CSS.
339
+ // "css" loader resolves paths in CSS and adds assets as dependencies.
340
+ // "style" loader turns CSS into JS modules that inject <style> tags.
341
+ oneOf: [{
342
+ // Use "postcss" for all the included source folders.
343
+ include: mergedOptions.sourceFolders,
344
+ use: [require.resolve('style-loader'), {
345
+ loader: require.resolve('css-loader'),
346
+ options: {
347
+ modules: {
348
+ mode: 'icss'
349
+ },
350
+ importLoaders: 1
351
+ }
352
+ }, {
353
+ loader: require.resolve('postcss-loader'),
354
+ options: {
355
+ postcssOptions: createPostcssConfig(mergedOptions.postcssOptions)
356
+ }
357
+ }]
358
+ }, {
359
+ // For all other vendor CSS, do not use "postcss" loader.
360
+ include: /node_modules/,
361
+ use: [require.resolve('style-loader'), {
362
+ loader: require.resolve('css-loader'),
363
+ options: {
364
+ modules: {
365
+ mode: 'icss'
366
+ },
367
+ importLoaders: 1
368
+ }
369
+ }],
370
+ // Don't consider CSS imports dead code even if the
371
+ // containing package claims to have no side effects.
372
+ // Remove this when webpack adds a warning or an error for this.
373
+ // See https://github.com/webpack/webpack/issues/6571
374
+ sideEffects: true
375
+ }]
376
+ },
377
+ // Fix for react-intl
378
+ // https://github.com/formatjs/formatjs/issues/143#issuecomment-518774786
379
+ {
380
+ test: /\.mjs$/,
381
+ type: 'javascript/auto',
382
+ resolve: {
383
+ // https://webpack.js.org/configuration/module/#resolvefullyspecified
384
+ fullySpecified: false
385
+ }
386
+ },
387
+ // Process JS with Babel.
388
+ {
389
+ test: /\.(js|mjs|cjs|jsx|ts|tsx)$/,
390
+ use: [
391
+ // This loader parallelizes code compilation, it is optional but
392
+ // improves compile time on larger projects
393
+ {
394
+ loader: require.resolve('thread-loader'),
395
+ options: {
396
+ poolTimeout: Infinity // keep workers alive for more effective watch mode
397
+ }
398
+ }, {
399
+ loader: require.resolve('babel-loader'),
400
+ options: {
401
+ babelrc: false,
402
+ configFile: false,
403
+ compact: false,
404
+ presets: [[require.resolve('@commercetools-frontend/babel-preset-mc-app'), {
405
+ runtime: hasJsxRuntime() ? 'automatic' : 'classic'
406
+ }]],
407
+ plugins: _filterInstanceProperty(_context4 = [hasReactRefresh && require.resolve('react-refresh/babel')]).call(_context4, Boolean),
408
+ // This is a feature of `babel-loader` for webpack (not Babel itself).
409
+ // It enables caching results in ./node_modules/.cache/babel-loader/
410
+ // directory for faster rebuilds.
411
+ cacheDirectory: true,
412
+ highlightCode: true
413
+ }
414
+ }],
415
+ include: _concatInstanceProperty(_context5 = mergedOptions.sourceFolders).call(_context5, vendorsToTranspile),
416
+ // Disable require.ensure as it's not a standard language feature.
417
+ parser: {
418
+ requireEnsure: false
419
+ }
420
+ },
421
+ // Allow to import `*.graphql` SDL files.
422
+ {
423
+ test: /\.graphql$/,
424
+ include: mergedOptions.sourceFolders,
425
+ use: [require.resolve('graphql-tag/loader')]
426
+ }]
427
+ },
428
+ // Turn off performance processing because we utilize
429
+ // our own hints via the FileSizeReporter
430
+ performance: false,
431
+ // For dev server
432
+ infrastructureLogging: {
433
+ level: 'none'
434
+ }
435
+ };
436
+ }
437
+
438
+ export { createWebpackConfigForDevelopment as c };