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