@commercetools-frontend/mc-scripts 0.0.0-CRAFT-1791-20251006162610

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