@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,166 @@
1
+ 'use strict';
2
+
3
+ var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
4
+ var path = require('path');
5
+ var chalk = require('chalk');
6
+ var fs = require('fs-extra');
7
+ var checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
8
+ var FileSizeReporter = require('react-dev-utils/FileSizeReporter');
9
+ var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
10
+ var printBuildError = require('react-dev-utils/printBuildError');
11
+ var webpack = require('webpack');
12
+ var assets = require('@commercetools-frontend/assets');
13
+ var createWebpackConfigForProduction = require('./create-webpack-config-for-production-3a40f56b.cjs.dev.js');
14
+ var paths = require('./paths-b76fc753.cjs.dev.js');
15
+ var doesFileExist = require('./does-file-exist-eb86baca.cjs.dev.js');
16
+ require('@babel/runtime-corejs3/core-js-stable/object/keys');
17
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
18
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
19
+ require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
20
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
21
+ require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
22
+ require('@babel/runtime-corejs3/core-js-stable/object/define-property');
23
+ require('@babel/runtime-corejs3/helpers/defineProperty');
24
+ require('@babel/runtime-corejs3/core-js-stable/instance/filter');
25
+ require('@babel/runtime-corejs3/core-js-stable/instance/map');
26
+ require('@babel/runtime-corejs3/core-js-stable/json/stringify');
27
+ require('@babel/runtime-corejs3/core-js-stable/instance/ends-with');
28
+ require('@babel/runtime-corejs3/core-js-stable/number/is-integer');
29
+ require('@babel/runtime-corejs3/core-js-stable/instance/concat');
30
+ require('crypto');
31
+ require('css-minimizer-webpack-plugin');
32
+ require('html-webpack-plugin');
33
+ require('mini-css-extract-plugin');
34
+ require('moment-locales-webpack-plugin');
35
+ require('terser-webpack-plugin');
36
+ require('webpack-bundle-analyzer');
37
+ require('@babel/runtime-corejs3/helpers/classCallCheck');
38
+ require('@babel/runtime-corejs3/helpers/createClass');
39
+ require('@babel/runtime-corejs3/core-js-stable/instance/bind');
40
+ require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
41
+ require('@babel/runtime-corejs3/core-js-stable/object/assign');
42
+ require('fs');
43
+ require('./create-postcss-config-5962fa01.cjs.dev.js');
44
+ require('@babel/runtime-corejs3/helpers/slicedToArray');
45
+ require('./package-436331e6.cjs.dev.js');
46
+ require('./has-jsx-runtime-aa5d21ee.cjs.dev.js');
47
+ require('./optimizations-7789145e.cjs.dev.js');
48
+ require('@babel/runtime-corejs3/core-js-stable/object/entries');
49
+ require('@babel/runtime-corejs3/core-js-stable/instance/includes');
50
+ require('./vendors-to-transpile-6ab4ea06.cjs.dev.js');
51
+ require('@babel/runtime-corejs3/core-js-stable/instance/find');
52
+ require('node:fs');
53
+
54
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
55
+
56
+ var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
57
+ var path__default = /*#__PURE__*/_interopDefault(path);
58
+ var chalk__default = /*#__PURE__*/_interopDefault(chalk);
59
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
60
+ var checkRequiredFiles__default = /*#__PURE__*/_interopDefault(checkRequiredFiles);
61
+ var FileSizeReporter__default = /*#__PURE__*/_interopDefault(FileSizeReporter);
62
+ var formatWebpackMessages__default = /*#__PURE__*/_interopDefault(formatWebpackMessages);
63
+ var printBuildError__default = /*#__PURE__*/_interopDefault(printBuildError);
64
+ var webpack__default = /*#__PURE__*/_interopDefault(webpack);
65
+
66
+ const measureFileSizesBeforeBuild = FileSizeReporter__default["default"].measureFileSizesBeforeBuild;
67
+ const printFileSizesAfterBuild = FileSizeReporter__default["default"].printFileSizesAfterBuild;
68
+
69
+ // These sizes are pretty large. We'll warn for bundles exceeding them.
70
+ const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
71
+ const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
72
+ async function run() {
73
+ const hasWebpackConfig = doesFileExist.doesFileExist(paths.paths.appWebpackConfig);
74
+
75
+ // Warn and crash if required files are missing
76
+ if (!checkRequiredFiles__default["default"]([])) {
77
+ process.exit(1);
78
+ }
79
+
80
+ // First, read the current file sizes in build directory.
81
+ // This lets us display how much they changed later.
82
+ const previousFileSizes = await measureFileSizesBeforeBuild(paths.paths.appBuild);
83
+
84
+ // Remove all content but keep the directory so that
85
+ // if you're in it, you don't end up in Trash
86
+ fs__default["default"].emptyDirSync(paths.paths.appBuild);
87
+ // Copy default files
88
+ copyDefaultFiles();
89
+ try {
90
+ // Start the webpack build
91
+ const result = await build();
92
+ if (result.warnings.length) {
93
+ console.log(chalk__default["default"].yellow('Compiled with warnings.\n'));
94
+ console.log(result.warnings.join('\n\n'));
95
+ console.log('\n');
96
+ } else {
97
+ console.log(chalk__default["default"].green('Compiled successfully.\n'));
98
+ }
99
+ console.log('File sizes after gzip:\n');
100
+ printFileSizesAfterBuild(result.stats, previousFileSizes, paths.paths.appBuild, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
101
+ console.log();
102
+ } catch (error) {
103
+ if (error instanceof Error) {
104
+ printBuildError__default["default"](error);
105
+ }
106
+ throw new Error(`Failed to compile`);
107
+ }
108
+
109
+ // Create the production build and print the deployment instructions.
110
+ async function build() {
111
+ console.log('Creating an optimized production build...');
112
+ const config = hasWebpackConfig ? require(paths.paths.appWebpackConfig) : createWebpackConfigForProduction.createWebpackConfigForProduction();
113
+ const compiler = webpack__default["default"](config);
114
+ return new _Promise__default["default"]((resolve, reject) => {
115
+ compiler.run((err, stats) => {
116
+ let messages;
117
+ if (err) {
118
+ if (!err.message) {
119
+ return reject(err);
120
+ }
121
+ let errMessage = err.message;
122
+ // Add additional information for postcss errors
123
+ if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
124
+ errMessage += '\nCompileError: Begins at CSS selector ' +
125
+ // @ts-ignore
126
+ err['postcssNode'].selector;
127
+ }
128
+ messages = formatWebpackMessages__default["default"]({
129
+ // @ts-ignore
130
+ errors: [errMessage],
131
+ warnings: []
132
+ });
133
+ } else {
134
+ messages = formatWebpackMessages__default["default"](stats?.toJson({
135
+ all: false,
136
+ warnings: true,
137
+ errors: true
138
+ }));
139
+ }
140
+ if (messages.errors.length) {
141
+ // Only keep the first error. Others are often indicative
142
+ // of the same problem, but confuse the reader with noise.
143
+ if (messages.errors.length > 1) {
144
+ messages.errors.length = 1;
145
+ }
146
+ return reject(new Error(messages.errors.join('\n\n')));
147
+ }
148
+ if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
149
+ console.log(chalk__default["default"].yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
150
+ return reject(new Error(messages.warnings.join('\n\n')));
151
+ }
152
+ return resolve({
153
+ stats: stats,
154
+ warnings: messages.warnings
155
+ });
156
+ });
157
+ });
158
+ }
159
+ function copyDefaultFiles() {
160
+ fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
161
+ dereference: true
162
+ });
163
+ }
164
+ }
165
+
166
+ exports["default"] = run;
@@ -0,0 +1,193 @@
1
+ 'use strict';
2
+
3
+ var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
4
+ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
5
+ var path = require('path');
6
+ var pluginGraphql = require('@rollup/plugin-graphql');
7
+ var pluginReact = require('@vitejs/plugin-react');
8
+ var fs = require('fs-extra');
9
+ var rollupPluginVisualizer = require('rollup-plugin-visualizer');
10
+ var vite = require('vite');
11
+ var viteBundleAnalyzer = require('vite-bundle-analyzer');
12
+ var assets = require('@commercetools-frontend/assets');
13
+ var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
14
+ var optimizations = require('./optimizations-fb93514f.cjs.prod.js');
15
+ var paths = require('./paths-7768b440.cjs.prod.js');
16
+ var cliLib = require('@formatjs/cli-lib');
17
+ var pluginutils = require('@rollup/pluginutils');
18
+ var i18nMessageComplilation = require('./i18n-message-complilation-7762da61.cjs.prod.js');
19
+ var vitePluginSvgr = require('./vite-plugin-svgr-b080c510.cjs.prod.js');
20
+ require('@babel/runtime-corejs3/helpers/defineProperty');
21
+ require('@babel/runtime-corejs3/helpers/slicedToArray');
22
+ require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
23
+ require('@babel/runtime-corejs3/core-js-stable/object/entries');
24
+ require('@babel/runtime-corejs3/core-js-stable/instance/filter');
25
+ require('@babel/runtime-corejs3/core-js-stable/instance/includes');
26
+ require('@babel/runtime-corejs3/core-js-stable/object/keys');
27
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
28
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
29
+ require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
30
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
31
+ require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
32
+ require('@babel/runtime-corejs3/core-js-stable/object/define-property');
33
+ require('chalk');
34
+ require('@babel/runtime-corejs3/core-js-stable/instance/find');
35
+ require('fs');
36
+ require('./does-file-exist-be53305d.cjs.prod.js');
37
+ require('node:fs');
38
+ require('@babel/runtime-corejs3/core-js-stable/object/values');
39
+ require('crypto');
40
+
41
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
42
+
43
+ var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
44
+ var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
45
+ var path__default = /*#__PURE__*/_interopDefault(path);
46
+ var pluginGraphql__default = /*#__PURE__*/_interopDefault(pluginGraphql);
47
+ var pluginReact__default = /*#__PURE__*/_interopDefault(pluginReact);
48
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
49
+
50
+ // This script/function is injected into the `index.html` and used by Vite
51
+ // on runtime to build the assets URL (for example when using a separate CDN for the assets).
52
+ // Inspired by https://github.com/vitejs/vite/blob/main/playground/assets/vite.config-runtime-base.js
53
+ const dynamicBaseAssetsCode = `globalThis.__toCdnUrl = filePath => window.app.cdnUrl.replace(/\\/$/, '') + '/' + filePath;`;
54
+ function vitePluginDynamicBaseAssetsGlobals() {
55
+ return {
56
+ name: 'dynamic-base-assets-globals',
57
+ transformIndexHtml(html, ctx) {
58
+ if (ctx.bundle) {
59
+ // Only inject during build
60
+ return [{
61
+ tag: 'script',
62
+ attrs: {
63
+ type: 'module'
64
+ },
65
+ children: dynamicBaseAssetsCode
66
+ }];
67
+ }
68
+ return html;
69
+ }
70
+ };
71
+ }
72
+
73
+ function vitePluginI18nMessageCompilation() {
74
+ const filter = pluginutils.createFilter('**/i18n/data/*.json');
75
+ return {
76
+ name: 'vite-plugin-i18n-message-compilation',
77
+ enforce: 'pre',
78
+ async transform(code, id) {
79
+ if (!process.env.DISABLE_I18N_MESSAGE_COMPILATION && filter(id)) {
80
+ try {
81
+ const format = i18nMessageComplilation.getI18nMessageFormat(code);
82
+ const res = await cliLib.compile([id], {
83
+ ast: true,
84
+ format
85
+ });
86
+ return {
87
+ code: res,
88
+ map: null
89
+ };
90
+ } catch (error) {
91
+ i18nMessageComplilation.handleMessageCompilationError(id, error, this.warn);
92
+ }
93
+ }
94
+ return null;
95
+ }
96
+ };
97
+ }
98
+
99
+ async function run() {
100
+ const DEFAULT_PORT = _parseInt__default["default"](String(process.env.HTTP_PORT), 10) || 3001;
101
+
102
+ // Ensure the `/public` folder exists.
103
+ fs__default["default"].mkdirSync(paths.paths.appBuild, {
104
+ recursive: true
105
+ });
106
+
107
+ // Generate `index.html` (template).
108
+ const appEntryPoint = path__default["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
109
+ const html = mcHtmlTemplate.generateTemplate({
110
+ // Define the module entry point (path relative from the `/public` folder).
111
+ // NOTE: that this is different from the development configuration.
112
+ scriptImports: [`<script type="module" src="/${appEntryPoint}" defer></script>`]
113
+ });
114
+ // Write `index.html` (template) into the `/public` folder.
115
+ fs__default["default"].writeFileSync(paths.paths.appIndexHtml, html, {
116
+ encoding: 'utf8'
117
+ });
118
+ const appDependencies = require(paths.paths.appPackageJson).dependencies;
119
+ await vite.build({
120
+ root: paths.paths.appRoot,
121
+ base: './',
122
+ // <-- Important to allow configuring the runtime base path.
123
+ define: {
124
+ 'process.env.DEBUG': _JSON$stringify__default["default"](false),
125
+ 'process.env.NODE_ENV': _JSON$stringify__default["default"]('production')
126
+ },
127
+ build: {
128
+ outDir: 'public',
129
+ rollupOptions: {
130
+ // This is necessary to instruct Vite that the `index.html` (template)
131
+ // is located in the `/public` folder.
132
+ // NOTE that after the build, Vite will write the `index.html` (template)
133
+ // at the `/public/public/index.html` location. See `fs.renameSync` below.
134
+ input: paths.paths.appIndexHtml,
135
+ output: {
136
+ manualChunks: optimizations.getViteCacheGroups(appDependencies)
137
+ },
138
+ // Reduce the memory footprint when building sourcemaps.
139
+ // https://github.com/vitejs/vite/issues/2433#issuecomment-1361094727
140
+ cache: false
141
+ },
142
+ sourcemap:
143
+ // Generating sourcemaps can increase the memory footprint of the build process,
144
+ // therefore it's an opt-in option.
145
+ // TODO: make it a CLI option when Vite support becomes stable.
146
+ process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER_SOURCEMAP === 'true'
147
+ },
148
+ server: {
149
+ port: DEFAULT_PORT
150
+ },
151
+ experimental: {
152
+ // https://vitejs.dev/guide/build.html#advanced-base-options
153
+ renderBuiltUrl(filename, _ref) {
154
+ let hostType = _ref.hostType;
155
+ if (hostType === 'html') {
156
+ return `__CDN_URL__${filename}`;
157
+ }
158
+ return {
159
+ runtime: `window.__toCdnUrl(${_JSON$stringify__default["default"](filename)})`
160
+ };
161
+ }
162
+ },
163
+ plugins: [pluginGraphql__default["default"](), pluginReact__default["default"]({
164
+ jsxImportSource: '@emotion/react',
165
+ babel: {
166
+ plugins: ['@emotion/babel-plugin', '@babel/plugin-proposal-do-expressions']
167
+ }
168
+ }), vitePluginSvgr.vitePluginSvgr(), vitePluginDynamicBaseAssetsGlobals(), vitePluginI18nMessageCompilation(), process.env.ANALYZE_BUNDLE === 'true' && viteBundleAnalyzer.analyzer({
169
+ defaultSizes: 'parsed',
170
+ openAnalyzer: true
171
+ }), process.env.ANALYZE_BUNDLE_TREE === 'true' && rollupPluginVisualizer.visualizer({
172
+ open: true,
173
+ template: 'network'
174
+ })]
175
+ });
176
+
177
+ // Rename `/public/public/index.html` to `/public/index.html.template`
178
+ fs__default["default"].renameSync(
179
+ // Because of our custom entry point path (`/public/index.html`),
180
+ // Vite will write the `index.html` to `/public/public/index.html`.
181
+ // We need to move this file to the `/public` folder and rename it
182
+ // to `index.html.template` (as expected by the `compile-html` command).
183
+ path__default["default"].join(paths.paths.appBuild, 'public/index.html'), paths.paths.appIndexHtmlTemplate);
184
+ // Clean up nested folder
185
+ fs__default["default"].rmdirSync(path__default["default"].join(paths.paths.appBuild, 'public'));
186
+
187
+ // Copy public assets
188
+ fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
189
+ dereference: true
190
+ });
191
+ }
192
+
193
+ exports["default"] = run;
@@ -0,0 +1,182 @@
1
+ import _parseInt from '@babel/runtime-corejs3/core-js-stable/parse-int';
2
+ import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
3
+ import path from 'path';
4
+ import pluginGraphql from '@rollup/plugin-graphql';
5
+ import pluginReact from '@vitejs/plugin-react';
6
+ import fs from 'fs-extra';
7
+ import { visualizer } from 'rollup-plugin-visualizer';
8
+ import { build } from 'vite';
9
+ import { analyzer } from 'vite-bundle-analyzer';
10
+ import { packageLocation } from '@commercetools-frontend/assets';
11
+ import { generateTemplate } from '@commercetools-frontend/mc-html-template';
12
+ import { a as getViteCacheGroups } from './optimizations-bf991634.esm.js';
13
+ import { p as paths } from './paths-39f22b8b.esm.js';
14
+ import { compile } from '@formatjs/cli-lib';
15
+ import { createFilter } from '@rollup/pluginutils';
16
+ import { g as getI18nMessageFormat, h as handleMessageCompilationError } from './i18n-message-complilation-21d3b0aa.esm.js';
17
+ import { v as vitePluginSvgr } from './vite-plugin-svgr-069f402d.esm.js';
18
+ import '@babel/runtime-corejs3/helpers/defineProperty';
19
+ import '@babel/runtime-corejs3/helpers/slicedToArray';
20
+ import '@babel/runtime-corejs3/core-js-stable/instance/reduce';
21
+ import '@babel/runtime-corejs3/core-js-stable/object/entries';
22
+ import '@babel/runtime-corejs3/core-js-stable/instance/filter';
23
+ import '@babel/runtime-corejs3/core-js-stable/instance/includes';
24
+ import '@babel/runtime-corejs3/core-js-stable/object/keys';
25
+ import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
26
+ import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
27
+ import '@babel/runtime-corejs3/core-js-stable/instance/for-each';
28
+ import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
29
+ import '@babel/runtime-corejs3/core-js-stable/object/define-properties';
30
+ import '@babel/runtime-corejs3/core-js-stable/object/define-property';
31
+ import 'chalk';
32
+ import '@babel/runtime-corejs3/core-js-stable/instance/find';
33
+ import 'fs';
34
+ import './does-file-exist-32618334.esm.js';
35
+ import 'node:fs';
36
+ import '@babel/runtime-corejs3/core-js-stable/object/values';
37
+ import 'crypto';
38
+
39
+ // This script/function is injected into the `index.html` and used by Vite
40
+ // on runtime to build the assets URL (for example when using a separate CDN for the assets).
41
+ // Inspired by https://github.com/vitejs/vite/blob/main/playground/assets/vite.config-runtime-base.js
42
+ const dynamicBaseAssetsCode = `globalThis.__toCdnUrl = filePath => window.app.cdnUrl.replace(/\\/$/, '') + '/' + filePath;`;
43
+ function vitePluginDynamicBaseAssetsGlobals() {
44
+ return {
45
+ name: 'dynamic-base-assets-globals',
46
+ transformIndexHtml(html, ctx) {
47
+ if (ctx.bundle) {
48
+ // Only inject during build
49
+ return [{
50
+ tag: 'script',
51
+ attrs: {
52
+ type: 'module'
53
+ },
54
+ children: dynamicBaseAssetsCode
55
+ }];
56
+ }
57
+ return html;
58
+ }
59
+ };
60
+ }
61
+
62
+ function vitePluginI18nMessageCompilation() {
63
+ const filter = createFilter('**/i18n/data/*.json');
64
+ return {
65
+ name: 'vite-plugin-i18n-message-compilation',
66
+ enforce: 'pre',
67
+ async transform(code, id) {
68
+ if (!process.env.DISABLE_I18N_MESSAGE_COMPILATION && filter(id)) {
69
+ try {
70
+ const format = getI18nMessageFormat(code);
71
+ const res = await compile([id], {
72
+ ast: true,
73
+ format
74
+ });
75
+ return {
76
+ code: res,
77
+ map: null
78
+ };
79
+ } catch (error) {
80
+ handleMessageCompilationError(id, error, this.warn);
81
+ }
82
+ }
83
+ return null;
84
+ }
85
+ };
86
+ }
87
+
88
+ async function run() {
89
+ const DEFAULT_PORT = _parseInt(String(process.env.HTTP_PORT), 10) || 3001;
90
+
91
+ // Ensure the `/public` folder exists.
92
+ fs.mkdirSync(paths.appBuild, {
93
+ recursive: true
94
+ });
95
+
96
+ // Generate `index.html` (template).
97
+ const appEntryPoint = path.relative(paths.appRoot, paths.entryPoint);
98
+ const html = generateTemplate({
99
+ // Define the module entry point (path relative from the `/public` folder).
100
+ // NOTE: that this is different from the development configuration.
101
+ scriptImports: [`<script type="module" src="/${appEntryPoint}" defer></script>`]
102
+ });
103
+ // Write `index.html` (template) into the `/public` folder.
104
+ fs.writeFileSync(paths.appIndexHtml, html, {
105
+ encoding: 'utf8'
106
+ });
107
+ const appDependencies = require(paths.appPackageJson).dependencies;
108
+ await build({
109
+ root: paths.appRoot,
110
+ base: './',
111
+ // <-- Important to allow configuring the runtime base path.
112
+ define: {
113
+ 'process.env.DEBUG': _JSON$stringify(false),
114
+ 'process.env.NODE_ENV': _JSON$stringify('production')
115
+ },
116
+ build: {
117
+ outDir: 'public',
118
+ rollupOptions: {
119
+ // This is necessary to instruct Vite that the `index.html` (template)
120
+ // is located in the `/public` folder.
121
+ // NOTE that after the build, Vite will write the `index.html` (template)
122
+ // at the `/public/public/index.html` location. See `fs.renameSync` below.
123
+ input: paths.appIndexHtml,
124
+ output: {
125
+ manualChunks: getViteCacheGroups(appDependencies)
126
+ },
127
+ // Reduce the memory footprint when building sourcemaps.
128
+ // https://github.com/vitejs/vite/issues/2433#issuecomment-1361094727
129
+ cache: false
130
+ },
131
+ sourcemap:
132
+ // Generating sourcemaps can increase the memory footprint of the build process,
133
+ // therefore it's an opt-in option.
134
+ // TODO: make it a CLI option when Vite support becomes stable.
135
+ process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER_SOURCEMAP === 'true'
136
+ },
137
+ server: {
138
+ port: DEFAULT_PORT
139
+ },
140
+ experimental: {
141
+ // https://vitejs.dev/guide/build.html#advanced-base-options
142
+ renderBuiltUrl(filename, _ref) {
143
+ let hostType = _ref.hostType;
144
+ if (hostType === 'html') {
145
+ return `__CDN_URL__${filename}`;
146
+ }
147
+ return {
148
+ runtime: `window.__toCdnUrl(${_JSON$stringify(filename)})`
149
+ };
150
+ }
151
+ },
152
+ plugins: [pluginGraphql(), pluginReact({
153
+ jsxImportSource: '@emotion/react',
154
+ babel: {
155
+ plugins: ['@emotion/babel-plugin', '@babel/plugin-proposal-do-expressions']
156
+ }
157
+ }), vitePluginSvgr(), vitePluginDynamicBaseAssetsGlobals(), vitePluginI18nMessageCompilation(), process.env.ANALYZE_BUNDLE === 'true' && analyzer({
158
+ defaultSizes: 'parsed',
159
+ openAnalyzer: true
160
+ }), process.env.ANALYZE_BUNDLE_TREE === 'true' && visualizer({
161
+ open: true,
162
+ template: 'network'
163
+ })]
164
+ });
165
+
166
+ // Rename `/public/public/index.html` to `/public/index.html.template`
167
+ fs.renameSync(
168
+ // Because of our custom entry point path (`/public/index.html`),
169
+ // Vite will write the `index.html` to `/public/public/index.html`.
170
+ // We need to move this file to the `/public` folder and rename it
171
+ // to `index.html.template` (as expected by the `compile-html` command).
172
+ path.join(paths.appBuild, 'public/index.html'), paths.appIndexHtmlTemplate);
173
+ // Clean up nested folder
174
+ fs.rmdirSync(path.join(paths.appBuild, 'public'));
175
+
176
+ // Copy public assets
177
+ fs.copySync(path.join(packageLocation, 'html-page'), paths.appBuild, {
178
+ dereference: true
179
+ });
180
+ }
181
+
182
+ export { run as default };