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