@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,122 @@
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-swc');
8
+ var fs = require('fs-extra');
9
+ var vite = require('vite');
10
+ var applicationConfig = require('@commercetools-frontend/application-config');
11
+ var assets = require('@commercetools-frontend/assets');
12
+ var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
13
+ var paths = require('./paths-b76fc753.cjs.dev.js');
14
+ var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
15
+ var mcDevAuthentication = require('@commercetools-frontend/mc-dev-authentication');
16
+ var vitePluginSvgr = require('./vite-plugin-svgr-7fb42bbf.cjs.dev.js');
17
+ require('@babel/runtime-corejs3/core-js-stable/instance/find');
18
+ require('fs');
19
+ require('./does-file-exist-eb86baca.cjs.dev.js');
20
+ require('node:fs');
21
+ require('crypto');
22
+ require('@rollup/pluginutils');
23
+
24
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
25
+
26
+ var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
27
+ var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
28
+ var path__default = /*#__PURE__*/_interopDefault(path);
29
+ var pluginGraphql__default = /*#__PURE__*/_interopDefault(pluginGraphql);
30
+ var pluginReact__default = /*#__PURE__*/_interopDefault(pluginReact);
31
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
32
+ var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
33
+
34
+ const vitePluginCustomApplication = applicationConfig => {
35
+ return {
36
+ name: 'custom-application',
37
+ configureServer(server) {
38
+ return () => {
39
+ // Users do not need to have/maintain the `index.html` (as expected by Vite)
40
+ // as it's generated and maintained by the Merchant Center customization CLI.
41
+ // Therefore, the generated `index.html` (template) is written into the `/public`
42
+ // folder so that it's gitignored.
43
+ // As a result, we need to make sure to point the URI path to the correct location.
44
+ server.middlewares.use((req, _res, next) => {
45
+ if (req.url === '/index.html') {
46
+ req.url = '/public/index.html';
47
+ }
48
+ next();
49
+ });
50
+
51
+ // Handle auth routes for internal local development.
52
+ server.middlewares.use(mcDevAuthentication.createMcDevAuthenticationMiddleware(applicationConfig));
53
+ };
54
+ },
55
+ /**
56
+ * @type {import('vite').IndexHtmlTransformHook}
57
+ */
58
+ transformIndexHtml(rawHtml, _ctx) {
59
+ const compiledHeaders = mcHtmlTemplate.processHeaders(applicationConfig);
60
+ const enhancedLocalEnv = _Object$assign__default["default"]({}, applicationConfig.env,
61
+ // Now that the app config is defined as a `env.json`, when we start the FE app
62
+ // to point to the local backend API by passing the `MC_API_URL` env does not
63
+ // work anymore). To make it work again, we can override the `env.json` config
64
+ // with the env variable before injecting the values into the index.html.
65
+ // NOTE: this is only necessary for development.
66
+ process.env.MC_API_URL ? {
67
+ mcApiUrl: process.env.MC_API_URL
68
+ } : {});
69
+
70
+ // Resolve the placeholders of the `index.html` (template) file, before serving it.
71
+ const html = mcHtmlTemplate.replaceHtmlPlaceholders(rawHtml, {
72
+ env: enhancedLocalEnv,
73
+ headers: compiledHeaders
74
+ });
75
+ return html;
76
+ }
77
+ };
78
+ };
79
+
80
+ async function run() {
81
+ const DEFAULT_PORT = _parseInt__default["default"](String(process.env.HTTP_PORT), 10) || 3001;
82
+
83
+ // Load the Merchant Center customization config file first.
84
+ const applicationConfig$1 = applicationConfig.processConfig();
85
+
86
+ // Ensure the `/public` folder exists.
87
+ fs__default["default"].mkdirSync(paths.paths.appBuild, {
88
+ recursive: true
89
+ });
90
+
91
+ // Generate `index.html` (template).
92
+ const appEntryPoint = path__default["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
93
+ const html = mcHtmlTemplate.generateTemplate({
94
+ // Define the module entry point (path relative to the `/public` folder).
95
+ // NOTE: that this is different from the production configuration.
96
+ scriptImports: [`<script type="module" src="/../${appEntryPoint}" defer></script>`]
97
+ });
98
+ // Write `index.html` (template) into the `/public` folder.
99
+ fs__default["default"].writeFileSync(paths.paths.appIndexHtml, html, {
100
+ encoding: 'utf8'
101
+ });
102
+ const server = await vite.createServer({
103
+ root: paths.paths.appRoot,
104
+ define: {
105
+ 'process.env.DEBUG': _JSON$stringify__default["default"](false),
106
+ 'process.env.NODE_ENV': _JSON$stringify__default["default"]('development')
107
+ },
108
+ server: {
109
+ port: DEFAULT_PORT
110
+ },
111
+ plugins: [pluginGraphql__default["default"](), pluginReact__default["default"](), vitePluginSvgr.vitePluginSvgr(), vitePluginCustomApplication(applicationConfig$1)]
112
+ });
113
+ await server.listen();
114
+
115
+ // Copy public assets to `/public` folder (even in development).
116
+ fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
117
+ dereference: true
118
+ });
119
+ server.printUrls();
120
+ }
121
+
122
+ exports["default"] = run;
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const vendorsToTranspile = [];
4
+
5
+ exports.vendorsToTranspile = vendorsToTranspile;
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const vendorsToTranspile = [];
4
+
5
+ exports.vendorsToTranspile = vendorsToTranspile;
@@ -0,0 +1,3 @@
1
+ const vendorsToTranspile = [];
2
+
3
+ export { vendorsToTranspile as v };
@@ -0,0 +1,83 @@
1
+ import crypto from 'crypto';
2
+ import fs from 'fs';
3
+ import { createFilter } from '@rollup/pluginutils';
4
+ import { transformWithEsbuild } from 'vite';
5
+
6
+ /**
7
+ * COPIED FROM https://github.com/pd4d10/vite-plugin-svgr
8
+ */
9
+ function vitePluginSvgr() {
10
+ const filter = createFilter('**/*.react.svg');
11
+ return {
12
+ name: 'vite-plugin-svgr',
13
+ async transform(_code, id) {
14
+ if (filter(id)) {
15
+ const _await$import = await import('@svgr/core'),
16
+ transform = _await$import.transform;
17
+ const svgCode = await fs.promises.readFile(id, 'utf8');
18
+ const componentCode = await transform(svgCode, {
19
+ icon: false,
20
+ svgoConfig: {
21
+ plugins: [{
22
+ // https://github.com/svg/svgo#default-preset
23
+ name: 'preset-default',
24
+ params: {
25
+ overrides: {
26
+ removeViewBox: false
27
+ }
28
+ }
29
+ },
30
+ // Avoid collisions with ids in other SVGs,
31
+ // which was causing incorrect masking, gradient directions, etc
32
+ // this is an ongoing issue with both SVGR and SVGO,
33
+ // https://github.com/svg/svgo/issues/913#issuecomment-369373572
34
+ // see SVGR issues:
35
+ // https://github.com/gregberge/svgr/issues/322
36
+ // https://github.com/gregberge/svgr/issues/210
37
+ // see SVGO issues:
38
+ // https://github.com/svg/svgo/issues/674
39
+ // https://github.com/svg/svgo/issues/1746
40
+ //
41
+ // Initially, a naive counter was implemented based on this github comment:
42
+ // https://github.com/svg/svgo/issues/1746#issuecomment-1803600573
43
+ // But while that implementation insured id’s that are unique,
44
+ // it did not work in cases where the id is both declared and referenced in the same file,
45
+ // because the refernce gets a separate unique ID (a different number from the counter).
46
+ //
47
+ // The current implementation is based on this github comment:
48
+ // https://github.com/svg/svgo/issues/913#issuecomment-369373572
49
+ // Generates a hash of the filepath of the svg file, resulting in a prefix which is:
50
+ // - Short,
51
+ // - With characters valid for IDs,
52
+ // - The same within a file,
53
+ // - And different in different files.
54
+ {
55
+ name: 'prefixIds',
56
+ params: {
57
+ delim: '',
58
+ prefix: (_, info) => `svg${crypto.createHash('shake256', {
59
+ outputLength: 6
60
+ }).update(info.path || '').digest('hex')}`
61
+ }
62
+ }]
63
+ }
64
+ }, {
65
+ filePath: id,
66
+ caller: {
67
+ previousExport: null
68
+ }
69
+ });
70
+ const res = await transformWithEsbuild(componentCode, id, {
71
+ loader: 'jsx'
72
+ });
73
+ return {
74
+ code: res.code,
75
+ map: null // TODO:
76
+ };
77
+ }
78
+ return null;
79
+ }
80
+ };
81
+ }
82
+
83
+ export { vitePluginSvgr as v };
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+
3
+ var crypto = require('crypto');
4
+ var fs = require('fs');
5
+ var pluginutils = require('@rollup/pluginutils');
6
+ var vite = require('vite');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
9
+
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
22
+ });
23
+ }
24
+ n["default"] = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ var crypto__default = /*#__PURE__*/_interopDefault(crypto);
29
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
30
+
31
+ /**
32
+ * COPIED FROM https://github.com/pd4d10/vite-plugin-svgr
33
+ */
34
+ function vitePluginSvgr() {
35
+ const filter = pluginutils.createFilter('**/*.react.svg');
36
+ return {
37
+ name: 'vite-plugin-svgr',
38
+ async transform(_code, id) {
39
+ if (filter(id)) {
40
+ const _await$import = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@svgr/core')); }),
41
+ transform = _await$import.transform;
42
+ const svgCode = await fs__default["default"].promises.readFile(id, 'utf8');
43
+ const componentCode = await transform(svgCode, {
44
+ icon: false,
45
+ svgoConfig: {
46
+ plugins: [{
47
+ // https://github.com/svg/svgo#default-preset
48
+ name: 'preset-default',
49
+ params: {
50
+ overrides: {
51
+ removeViewBox: false
52
+ }
53
+ }
54
+ },
55
+ // Avoid collisions with ids in other SVGs,
56
+ // which was causing incorrect masking, gradient directions, etc
57
+ // this is an ongoing issue with both SVGR and SVGO,
58
+ // https://github.com/svg/svgo/issues/913#issuecomment-369373572
59
+ // see SVGR issues:
60
+ // https://github.com/gregberge/svgr/issues/322
61
+ // https://github.com/gregberge/svgr/issues/210
62
+ // see SVGO issues:
63
+ // https://github.com/svg/svgo/issues/674
64
+ // https://github.com/svg/svgo/issues/1746
65
+ //
66
+ // Initially, a naive counter was implemented based on this github comment:
67
+ // https://github.com/svg/svgo/issues/1746#issuecomment-1803600573
68
+ // But while that implementation insured id’s that are unique,
69
+ // it did not work in cases where the id is both declared and referenced in the same file,
70
+ // because the refernce gets a separate unique ID (a different number from the counter).
71
+ //
72
+ // The current implementation is based on this github comment:
73
+ // https://github.com/svg/svgo/issues/913#issuecomment-369373572
74
+ // Generates a hash of the filepath of the svg file, resulting in a prefix which is:
75
+ // - Short,
76
+ // - With characters valid for IDs,
77
+ // - The same within a file,
78
+ // - And different in different files.
79
+ {
80
+ name: 'prefixIds',
81
+ params: {
82
+ delim: '',
83
+ prefix: (_, info) => `svg${crypto__default["default"].createHash('shake256', {
84
+ outputLength: 6
85
+ }).update(info.path || '').digest('hex')}`
86
+ }
87
+ }]
88
+ }
89
+ }, {
90
+ filePath: id,
91
+ caller: {
92
+ previousExport: null
93
+ }
94
+ });
95
+ const res = await vite.transformWithEsbuild(componentCode, id, {
96
+ loader: 'jsx'
97
+ });
98
+ return {
99
+ code: res.code,
100
+ map: null // TODO:
101
+ };
102
+ }
103
+ return null;
104
+ }
105
+ };
106
+ }
107
+
108
+ exports.vitePluginSvgr = vitePluginSvgr;
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+
3
+ var crypto = require('crypto');
4
+ var fs = require('fs');
5
+ var pluginutils = require('@rollup/pluginutils');
6
+ var vite = require('vite');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
9
+
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
22
+ });
23
+ }
24
+ n["default"] = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ var crypto__default = /*#__PURE__*/_interopDefault(crypto);
29
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
30
+
31
+ /**
32
+ * COPIED FROM https://github.com/pd4d10/vite-plugin-svgr
33
+ */
34
+ function vitePluginSvgr() {
35
+ const filter = pluginutils.createFilter('**/*.react.svg');
36
+ return {
37
+ name: 'vite-plugin-svgr',
38
+ async transform(_code, id) {
39
+ if (filter(id)) {
40
+ const _await$import = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@svgr/core')); }),
41
+ transform = _await$import.transform;
42
+ const svgCode = await fs__default["default"].promises.readFile(id, 'utf8');
43
+ const componentCode = await transform(svgCode, {
44
+ icon: false,
45
+ svgoConfig: {
46
+ plugins: [{
47
+ // https://github.com/svg/svgo#default-preset
48
+ name: 'preset-default',
49
+ params: {
50
+ overrides: {
51
+ removeViewBox: false
52
+ }
53
+ }
54
+ },
55
+ // Avoid collisions with ids in other SVGs,
56
+ // which was causing incorrect masking, gradient directions, etc
57
+ // this is an ongoing issue with both SVGR and SVGO,
58
+ // https://github.com/svg/svgo/issues/913#issuecomment-369373572
59
+ // see SVGR issues:
60
+ // https://github.com/gregberge/svgr/issues/322
61
+ // https://github.com/gregberge/svgr/issues/210
62
+ // see SVGO issues:
63
+ // https://github.com/svg/svgo/issues/674
64
+ // https://github.com/svg/svgo/issues/1746
65
+ //
66
+ // Initially, a naive counter was implemented based on this github comment:
67
+ // https://github.com/svg/svgo/issues/1746#issuecomment-1803600573
68
+ // But while that implementation insured id’s that are unique,
69
+ // it did not work in cases where the id is both declared and referenced in the same file,
70
+ // because the refernce gets a separate unique ID (a different number from the counter).
71
+ //
72
+ // The current implementation is based on this github comment:
73
+ // https://github.com/svg/svgo/issues/913#issuecomment-369373572
74
+ // Generates a hash of the filepath of the svg file, resulting in a prefix which is:
75
+ // - Short,
76
+ // - With characters valid for IDs,
77
+ // - The same within a file,
78
+ // - And different in different files.
79
+ {
80
+ name: 'prefixIds',
81
+ params: {
82
+ delim: '',
83
+ prefix: (_, info) => `svg${crypto__default["default"].createHash('shake256', {
84
+ outputLength: 6
85
+ }).update(info.path || '').digest('hex')}`
86
+ }
87
+ }]
88
+ }
89
+ }, {
90
+ filePath: id,
91
+ caller: {
92
+ previousExport: null
93
+ }
94
+ });
95
+ const res = await vite.transformWithEsbuild(componentCode, id, {
96
+ loader: 'jsx'
97
+ });
98
+ return {
99
+ code: res.code,
100
+ map: null // TODO:
101
+ };
102
+ }
103
+ return null;
104
+ }
105
+ };
106
+ }
107
+
108
+ exports.vitePluginSvgr = vitePluginSvgr;
package/package.json ADDED
@@ -0,0 +1,147 @@
1
+ {
2
+ "name": "@commercetools-frontend/mc-scripts",
3
+ "version": "0.0.0-FEC-157-preview-releases-20241126230331",
4
+ "description": "Configuration and scripts for developing a MC application",
5
+ "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/commercetools/merchant-center-application-kit.git",
9
+ "directory": "packages/mc-scripts"
10
+ },
11
+ "homepage": "https://docs.commercetools.com/merchant-center-customizations",
12
+ "keywords": [
13
+ "javascript",
14
+ "frontend",
15
+ "react",
16
+ "toolkit"
17
+ ],
18
+ "license": "MIT",
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "main": "dist/commercetools-frontend-mc-scripts.cjs.js",
23
+ "module": "dist/commercetools-frontend-mc-scripts.esm.js",
24
+ "preconstruct": {
25
+ "entrypoints": [
26
+ "./index.ts",
27
+ "./application-runtime.ts",
28
+ "./cli.ts",
29
+ "./postcss.ts",
30
+ "./webpack.ts",
31
+ "./webpack-loaders/i18n-message-compilation-loader.ts"
32
+ ]
33
+ },
34
+ "files": [
35
+ "bin",
36
+ "cli",
37
+ "dist",
38
+ "config",
39
+ "application-runtime",
40
+ "postcss",
41
+ "webpack",
42
+ "webpack-loaders",
43
+ "package.json",
44
+ "LICENSE",
45
+ "README.md"
46
+ ],
47
+ "bin": "./bin/cli.js",
48
+ "browserslist": {
49
+ "production": [
50
+ ">1%",
51
+ "not op_mini all",
52
+ "not dead"
53
+ ],
54
+ "development": [
55
+ "last 2 firefox versions",
56
+ "last 2 chrome versions"
57
+ ]
58
+ },
59
+ "dependencies": {
60
+ "@babel/core": "^7.22.17",
61
+ "@babel/runtime": "^7.22.15",
62
+ "@babel/runtime-corejs3": "^7.22.15",
63
+ "@commercetools-frontend/application-components": "0.0.0-FEC-157-preview-releases-20241126230331",
64
+ "@commercetools-frontend/application-config": "0.0.0-FEC-157-preview-releases-20241126230331",
65
+ "@commercetools-frontend/assets": "0.0.0-FEC-157-preview-releases-20241126230331",
66
+ "@commercetools-frontend/babel-preset-mc-app": "0.0.0-FEC-157-preview-releases-20241126230331",
67
+ "@commercetools-frontend/constants": "0.0.0-FEC-157-preview-releases-20241126230331",
68
+ "@commercetools-frontend/mc-dev-authentication": "0.0.0-FEC-157-preview-releases-20241126230331",
69
+ "@commercetools-frontend/mc-html-template": "0.0.0-FEC-157-preview-releases-20241126230331",
70
+ "@commercetools/http-user-agent": "3.0.0",
71
+ "@formatjs/cli-lib": "^6.3.8",
72
+ "@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
73
+ "@rollup/plugin-graphql": "2.0.4",
74
+ "@rollup/pluginutils": "5.1.0",
75
+ "@svgr/babel-preset": "^6.5.1",
76
+ "@svgr/core": "^6.5.1",
77
+ "@svgr/webpack": "^6.5.1",
78
+ "@types/prompts": "^2.4.4",
79
+ "@types/svgo": "^2.6.4",
80
+ "@types/webpack-bundle-analyzer": "^4.6.0",
81
+ "@vitejs/plugin-react": "4.3.1",
82
+ "@vitejs/plugin-react-swc": "3.7.0",
83
+ "autoprefixer": "^10.4.15",
84
+ "babel-loader": "8.3.0",
85
+ "browserslist": "^4.21.10",
86
+ "cac": "6.7.14",
87
+ "chalk": "4.1.2",
88
+ "core-js": "^3.32.2",
89
+ "css-loader": "6.11.0",
90
+ "css-minimizer-webpack-plugin": "3.4.1",
91
+ "dotenv": "16.4.5",
92
+ "dotenv-expand": "8.0.3",
93
+ "fs-extra": "10.1.0",
94
+ "graphql": "16.8.2",
95
+ "graphql-request": "5.2.0",
96
+ "graphql-tag": "^2.12.6",
97
+ "html-webpack-plugin": "5.6.0",
98
+ "json-loader": "0.5.7",
99
+ "lodash": "4.17.21",
100
+ "mini-css-extract-plugin": "2.9.0",
101
+ "moment": "^2.29.4",
102
+ "moment-locales-webpack-plugin": "1.2.0",
103
+ "node-fetch": "2.7.0",
104
+ "postcss": "8.4.38",
105
+ "postcss-custom-media": "8.0.2",
106
+ "postcss-custom-properties": "12.1.4",
107
+ "postcss-import": "14.1.0",
108
+ "postcss-loader": "6.2.1",
109
+ "postcss-reporter": "7.1.0",
110
+ "prettier": "2.8.8",
111
+ "prompts": "^2.4.2",
112
+ "querystring-es3": "^0.2.1",
113
+ "react-dev-utils": "12.0.1",
114
+ "react-refresh": "0.14.2",
115
+ "rollup-plugin-visualizer": "^5.12.0",
116
+ "serve-handler": "6.1.5",
117
+ "shelljs": "0.8.5",
118
+ "style-loader": "3.3.4",
119
+ "svg-url-loader": "7.1.1",
120
+ "terser-webpack-plugin": "5.3.10",
121
+ "thread-loader": "3.0.4",
122
+ "url": "^0.11.0",
123
+ "vite": "~4.5.3",
124
+ "vite-bundle-analyzer": "0.12.1",
125
+ "webpack": "5.94.0",
126
+ "webpack-bundle-analyzer": "4.10.2",
127
+ "webpack-dev-server": "4.15.2",
128
+ "webpackbar": "5.0.2"
129
+ },
130
+ "devDependencies": {
131
+ "@commercetools-test-data/custom-view": "^8.0.0",
132
+ "@tsconfig/node16": "^16.1.1",
133
+ "@types/fs-extra": "^11.0.1",
134
+ "@types/lodash": "^4.14.198",
135
+ "@types/mock-fs": "^4.13.1",
136
+ "@types/moment-locales-webpack-plugin": "^1.2.3",
137
+ "@types/node-fetch": "2.6.11",
138
+ "@types/serve-handler": "^6.1.1",
139
+ "memfs": "^4.8.2",
140
+ "mock-fs": "^5.2.0",
141
+ "msw": "0.49.3",
142
+ "rimraf": "5.0.7"
143
+ },
144
+ "engines": {
145
+ "node": "16.x || >=18.0.0"
146
+ }
147
+ }
@@ -0,0 +1,2 @@
1
+ export * from "../../dist/declarations/src/postcss";
2
+ //# sourceMappingURL=commercetools-frontend-mc-scripts-postcss.cjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commercetools-frontend-mc-scripts-postcss.cjs.d.ts","sourceRoot":"","sources":["../../dist/declarations/src/postcss.d.ts"],"names":[],"mappings":"AAAA"}
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var createPostcssConfig = require('../../dist/create-postcss-config-5962fa01.cjs.dev.js');
6
+ require('@babel/runtime-corejs3/helpers/slicedToArray');
7
+ require('path');
8
+ require('../../dist/package-436331e6.cjs.dev.js');
9
+
10
+
11
+
12
+ exports.createPostcssConfig = createPostcssConfig.createPostcssConfig;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./commercetools-frontend-mc-scripts-postcss.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./commercetools-frontend-mc-scripts-postcss.cjs.dev.js");
7
+ }
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var createPostcssConfig = require('../../dist/create-postcss-config-3b540c7c.cjs.prod.js');
6
+ require('@babel/runtime-corejs3/helpers/slicedToArray');
7
+ require('path');
8
+ require('../../dist/package-a7096308.cjs.prod.js');
9
+
10
+
11
+
12
+ exports.createPostcssConfig = createPostcssConfig.createPostcssConfig;
@@ -0,0 +1,4 @@
1
+ export { c as createPostcssConfig } from '../../dist/create-postcss-config-2f709335.esm.js';
2
+ import '@babel/runtime-corejs3/helpers/slicedToArray';
3
+ import 'path';
4
+ import '../../dist/package-b2f2b4e5.esm.js';
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "dist/commercetools-frontend-mc-scripts-postcss.cjs.js",
3
+ "module": "dist/commercetools-frontend-mc-scripts-postcss.esm.js"
4
+ }
@@ -0,0 +1,2 @@
1
+ export * from "../../dist/declarations/src/webpack";
2
+ //# sourceMappingURL=commercetools-frontend-mc-scripts-webpack.cjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commercetools-frontend-mc-scripts-webpack.cjs.d.ts","sourceRoot":"","sources":["../../dist/declarations/src/webpack.d.ts"],"names":[],"mappings":"AAAA"}