@commercetools-frontend/mc-scripts 27.12.0 → 27.13.0

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 (55) hide show
  1. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +7 -7
  2. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +7 -7
  3. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +7 -7
  4. package/dist/{build-d10b7b9c.cjs.dev.js → build-57cc074d.cjs.dev.js} +3 -3
  5. package/dist/{build-88d20516.esm.js → build-5e7d1303.esm.js} +3 -3
  6. package/dist/{build-5c9807bf.cjs.prod.js → build-7508f568.cjs.prod.js} +3 -3
  7. package/dist/{build-vite-782c1634.esm.js → build-vite-01e2aaf0.esm.js} +190 -8
  8. package/dist/{build-vite-0b37a521.cjs.prod.js → build-vite-600ec6bd.cjs.prod.js} +194 -10
  9. package/dist/{build-vite-dfe4ce01.cjs.dev.js → build-vite-fb6643b3.cjs.dev.js} +194 -10
  10. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +1 -1
  11. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +1 -1
  12. package/dist/commercetools-frontend-mc-scripts.esm.js +1 -1
  13. package/dist/{config-sync-e95f4b01.cjs.prod.js → config-sync-4d2d7d71.cjs.prod.js} +3 -3
  14. package/dist/{config-sync-8eab0a7a.esm.js → config-sync-593781fd.esm.js} +3 -3
  15. package/dist/{config-sync-ci-7b9bd247.esm.js → config-sync-ci-1f59bf79.esm.js} +3 -3
  16. package/dist/{config-sync-ci-93339284.cjs.dev.js → config-sync-ci-7b95c32a.cjs.dev.js} +3 -3
  17. package/dist/{config-sync-ci-7d64585b.cjs.prod.js → config-sync-ci-f33b765c.cjs.prod.js} +3 -3
  18. package/dist/{config-sync-a408a6bd.cjs.dev.js → config-sync-f8267173.cjs.dev.js} +3 -3
  19. package/dist/{config-sync-helpers-1e0d8b73.cjs.dev.js → config-sync-helpers-45798902.cjs.dev.js} +1 -1
  20. package/dist/{config-sync-helpers-e3387197.esm.js → config-sync-helpers-649b6c87.esm.js} +1 -1
  21. package/dist/{config-sync-helpers-a24fc76b.cjs.prod.js → config-sync-helpers-ab74b949.cjs.prod.js} +1 -1
  22. package/dist/{create-postcss-config-f0432393.esm.js → create-postcss-config-08564589.esm.js} +1 -1
  23. package/dist/{create-postcss-config-359a248e.cjs.prod.js → create-postcss-config-2b9affd5.cjs.prod.js} +1 -1
  24. package/dist/{create-postcss-config-4cfdca27.cjs.dev.js → create-postcss-config-5253f51d.cjs.dev.js} +1 -1
  25. package/dist/{create-webpack-config-for-development-66baf4c7.cjs.prod.js → create-webpack-config-for-development-6e3e2752.cjs.prod.js} +1 -1
  26. package/dist/{create-webpack-config-for-development-80f64db5.esm.js → create-webpack-config-for-development-83207381.esm.js} +1 -1
  27. package/dist/{create-webpack-config-for-development-c606ff3e.cjs.dev.js → create-webpack-config-for-development-febf2163.cjs.dev.js} +1 -1
  28. package/dist/{create-webpack-config-for-production-2c8ea8e1.cjs.dev.js → create-webpack-config-for-production-351be45d.cjs.dev.js} +1 -1
  29. package/dist/{create-webpack-config-for-production-e268d2a9.cjs.prod.js → create-webpack-config-for-production-35502c64.cjs.prod.js} +1 -1
  30. package/dist/{create-webpack-config-for-production-5541c8a9.esm.js → create-webpack-config-for-production-d619b595.esm.js} +1 -1
  31. package/dist/{deployment-previews-set-02d950fa.cjs.prod.js → deployment-previews-set-33a3a023.cjs.prod.js} +2 -2
  32. package/dist/{deployment-previews-set-0afbb44c.esm.js → deployment-previews-set-697801d9.esm.js} +2 -2
  33. package/dist/{deployment-previews-set-5cc6cd27.cjs.dev.js → deployment-previews-set-760532e0.cjs.dev.js} +2 -2
  34. package/dist/{graphql-requests-c8bfe58e.cjs.dev.js → graphql-requests-3cc7deec.cjs.dev.js} +1 -1
  35. package/dist/{graphql-requests-0f5e76bf.cjs.prod.js → graphql-requests-7ca459c8.cjs.prod.js} +1 -1
  36. package/dist/{graphql-requests-94a1fb99.esm.js → graphql-requests-e034376f.esm.js} +1 -1
  37. package/dist/{login-75fe7cb9.cjs.prod.js → login-60fd6d4a.cjs.prod.js} +1 -1
  38. package/dist/{login-d67e9ddf.esm.js → login-d077a257.esm.js} +1 -1
  39. package/dist/{login-b51be3e8.cjs.dev.js → login-f32f3623.cjs.dev.js} +1 -1
  40. package/dist/{package-2ce7d094.cjs.prod.js → package-84973c56.cjs.dev.js} +1 -1
  41. package/dist/{package-cdfe3e2e.esm.js → package-b717bf0d.esm.js} +1 -1
  42. package/dist/{package-e604fbd7.cjs.dev.js → package-d1a1140f.cjs.prod.js} +1 -1
  43. package/dist/{start-bb2cef13.esm.js → start-59484653.esm.js} +3 -3
  44. package/dist/{start-049ad265.cjs.prod.js → start-9d09aeb0.cjs.prod.js} +3 -3
  45. package/dist/{start-96ed4013.cjs.dev.js → start-a1034a4d.cjs.dev.js} +3 -3
  46. package/dist/{start-vite-dd8a1e26.cjs.prod.js → start-vite-69dc28cf.cjs.prod.js} +31 -1
  47. package/dist/{start-vite-698c9e82.cjs.dev.js → start-vite-a2daee6e.cjs.dev.js} +31 -1
  48. package/dist/{start-vite-4b0df191.esm.js → start-vite-f0085975.esm.js} +23 -1
  49. package/package.json +8 -8
  50. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -2
  51. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -2
  52. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -2
  53. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +4 -4
  54. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +4 -4
  55. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +4 -4
@@ -3,7 +3,7 @@
3
3
  var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
4
4
  var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
5
5
  var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
6
- var path$1 = require('path');
6
+ var path = require('path');
7
7
  var pluginGraphql = require('@rollup/plugin-graphql');
8
8
  var pluginReact = require('@vitejs/plugin-react');
9
9
  var fs$1 = require('fs-extra');
@@ -13,6 +13,8 @@ var viteBundleAnalyzer = require('vite-bundle-analyzer');
13
13
  var assets = require('@commercetools-frontend/assets');
14
14
  var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
15
15
  var paths = require('./paths-7768b440.cjs.prod.js');
16
+ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
17
+ var applicationConfig = require('@commercetools-frontend/application-config');
16
18
  var tryLoadNimbusPlugins = require('./try-load-nimbus-plugins-a713d7d3.cjs.prod.js');
17
19
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
18
20
  var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
@@ -26,11 +28,12 @@ var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/insta
26
28
  var cliLib = require('@formatjs/cli-lib');
27
29
  var pluginutils = require('@rollup/pluginutils');
28
30
  var i18nMessageComplilation = require('./i18n-message-complilation-7762da61.cjs.prod.js');
31
+ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
29
32
  var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
30
33
  var _endsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/ends-with');
31
34
  var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
32
35
  var fs = require('node:fs');
33
- var path = require('node:path');
36
+ var path$1 = require('node:path');
34
37
  var glob = require('glob');
35
38
  var vitePluginSvgr = require('./vite-plugin-svgr-4034a834.cjs.prod.js');
36
39
  require('@babel/runtime-corejs3/core-js-stable/instance/find');
@@ -47,10 +50,11 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
47
50
  var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
48
51
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
49
52
  var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
50
- var path__default$1 = /*#__PURE__*/_interopDefault(path$1);
53
+ var path__default = /*#__PURE__*/_interopDefault(path);
51
54
  var pluginGraphql__default = /*#__PURE__*/_interopDefault(pluginGraphql);
52
55
  var pluginReact__default = /*#__PURE__*/_interopDefault(pluginReact);
53
56
  var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
57
+ var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
54
58
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
55
59
  var _Object$values__default = /*#__PURE__*/_interopDefault(_Object$values);
56
60
  var _Map__default = /*#__PURE__*/_interopDefault(_Map);
@@ -60,11 +64,41 @@ var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfIns
60
64
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
61
65
  var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
62
66
  var _sortInstanceProperty__default = /*#__PURE__*/_interopDefault(_sortInstanceProperty);
67
+ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
63
68
  var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
64
69
  var _endsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_endsWithInstanceProperty);
65
70
  var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
66
71
  var fs__default = /*#__PURE__*/_interopDefault(fs);
67
- var path__default = /*#__PURE__*/_interopDefault(path);
72
+ var path__default$1 = /*#__PURE__*/_interopDefault(path$1);
73
+
74
+ /**
75
+ * Whether the app being built is a Custom View rather than a Custom
76
+ * Application.
77
+ *
78
+ * Decided from which configuration file is present, which is the same signal
79
+ * `processConfig` itself branches on. `getConfigPath` only resolves the file's
80
+ * path — it does not read env vars or process the config — so this stays cheap
81
+ * enough for a build-time decision. `loadConfig` rejects a project carrying
82
+ * both files, so the two cases cannot overlap.
83
+ *
84
+ * Matched on the file name only. Against the whole path, a Custom Application
85
+ * living anywhere under a directory like `custom-view-config-demo/` would read
86
+ * as a Custom View and silently lose the optimisation.
87
+ *
88
+ * Fails open: anything unexpected (no config found, a resolution error)
89
+ * answers `false`, so a detection gap leaves Custom Application behaviour
90
+ * intact rather than silently dropping an optimisation from a real app.
91
+ */
92
+ const isCustomView = async () => {
93
+ try {
94
+ var _context;
95
+ const configPath = await applicationConfig.getConfigPath();
96
+ if (!configPath) return false;
97
+ return _startsWithInstanceProperty__default["default"](_context = path__default["default"].basename(configPath)).call(_context, 'custom-view-config');
98
+ } catch {
99
+ return false;
100
+ }
101
+ };
68
102
 
69
103
  // Type guard to help with filtering arrays for nullish elements.
70
104
  function nonNullable(value) {
@@ -208,6 +242,145 @@ function vitePluginI18nMessageCompilation() {
208
242
  };
209
243
  }
210
244
 
245
+ // `application-shell-splitter` is deliberately absent. It is a root of the
246
+ // same wave, but it alone is ~1.2MB (Nimbus/chakra bindings) and pulls a
247
+ // further ~172KB `runtime` chunk, which would put ~1.5MB of high-priority
248
+ // preload in parallel with the 2.3MB entry that is the real critical path.
249
+ // Preloading it is a separate decision that needs a throttled measurement.
250
+ //
251
+ // When adding, renaming or removing a root here, update the assertion step in
252
+ // `.github/workflows/main.yml` to match — it checks these names by hand, so a
253
+ // drift makes CI pass or fail for the wrong reason.
254
+ const DEFAULT_ROOTS = ['navbar', 'project-container', 'user-settings-menu', 'use-applications-menu', 'requests-in-flight-loader'];
255
+ /**
256
+ * Resolves each root to its emitted chunk, then follows static `imports`
257
+ * transitively. The transitive walk is load-bearing rather than an
258
+ * optimisation: a browser is only guaranteed to preload dependencies that are
259
+ * listed individually, so preloading a root without its imports leaves them
260
+ * one round trip behind.
261
+ */
262
+ function resolveShellChunks(bundle, roots) {
263
+ var _context, _context4;
264
+ const chunks = _filterInstanceProperty__default["default"](_context = _Object$values__default["default"](bundle)).call(_context, entry => entry.type === 'chunk');
265
+ const byFileName = new _Map__default["default"](_mapInstanceProperty__default["default"](chunks).call(chunks, chunk => [chunk.fileName, chunk]));
266
+ const fileNames = new _Set__default["default"]();
267
+ const matchedRoots = [];
268
+ const missingRoots = [];
269
+ const visit = chunk => {
270
+ var _context2;
271
+ if (fileNames.has(chunk.fileName)) return;
272
+ fileNames.add(chunk.fileName);
273
+ _forEachInstanceProperty__default["default"](_context2 = chunk.imports).call(_context2, imported => {
274
+ const next = byFileName.get(imported);
275
+ if (next) visit(next);
276
+ });
277
+ };
278
+ _forEachInstanceProperty__default["default"](roots).call(roots, root => {
279
+ // Prefix, not exact: Rollup suffixes chunk names it has to disambiguate,
280
+ // so `navbar` has to match `navbar2`. The cost is that an app's own chunk
281
+ // named `navbar-…` would be preloaded too — a few KB of wasted hint on a
282
+ // page that is about to load the real navbar anyway.
283
+ const hits = _filterInstanceProperty__default["default"](chunks).call(chunks, chunk => {
284
+ var _context3;
285
+ return _startsWithInstanceProperty__default["default"](_context3 = chunk.name).call(_context3, root);
286
+ });
287
+ if (hits.length === 0) {
288
+ missingRoots.push(root);
289
+ return;
290
+ }
291
+ matchedRoots.push(root);
292
+ _forEachInstanceProperty__default["default"](hits).call(hits, visit);
293
+ });
294
+ return {
295
+ fileNames: _sortInstanceProperty__default["default"](_context4 = [...fileNames]).call(_context4),
296
+ matchedRoots,
297
+ missingRoots
298
+ };
299
+ }
300
+
301
+ /**
302
+ * Emits `<link rel="modulepreload">` for the authenticated shell chunk graph,
303
+ * so those chunks are fetched alongside the entry instead of waiting for it to
304
+ * execute and discover them.
305
+ *
306
+ * Works through `build.modulePreload.resolveDependencies` rather than by
307
+ * injecting tags directly. That hook renders its return value through
308
+ * `renderBuiltUrl`, which is what applies the `__CDN_URL__` prefix; tags a
309
+ * `transformIndexHtml` hook creates are emitted verbatim and would ship
310
+ * without it.
311
+ */
312
+ function pluginModulePreloadShellChunks() {
313
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
314
+ const roots = options.roots ?? DEFAULT_ROOTS;
315
+ const onMissing = options.onMissing ?? 'warn';
316
+ let resolved = null;
317
+ let hasWarnedAboutOrdering = false;
318
+ return {
319
+ name: 'vite-plugin-modulepreload-shell-chunks',
320
+ apply: 'build',
321
+ config(config) {
322
+ // Vite's config merge would turn an explicit `false` back into an
323
+ // object, silently re-enabling preloading the consumer switched off.
324
+ if (config.build?.modulePreload === false) return;
325
+ return {
326
+ build: {
327
+ modulePreload: {
328
+ resolveDependencies: (url, deps, _ref) => {
329
+ let hostType = _ref.hostType;
330
+ // Vite calls this once for the entry HTML and once per dynamic
331
+ // import. Appending for `js` too would bake the shell graph into
332
+ // every `__vitePreload` dependency array in the bundle.
333
+ if (hostType !== 'html') return deps;
334
+
335
+ // Reaching the HTML host with nothing resolved means
336
+ // `generateBundle` has not run yet, i.e. the plugin ordering
337
+ // below inverted. Every hint would silently disappear, so say
338
+ // so. `console.warn` rather than `this.warn`: this is a plain
339
+ // callback in the returned config, not a Rollup plugin hook,
340
+ // so there is no plugin context here.
341
+ if (!resolved) {
342
+ if (!hasWarnedAboutOrdering) {
343
+ hasWarnedAboutOrdering = true;
344
+ // eslint-disable-next-line no-console
345
+ console.warn(`vite-plugin-modulepreload-shell-chunks: the entry HTML ` + `asked for its preload dependencies before the bundle ` + `was analysed, so no shell chunks were preloaded. This ` + `plugin relies on its \`generateBundle\` running before ` + `\`vite:build-html\`'s, which is Vite-internal ordering ` + `— a Vite upgrade may have changed it.`);
346
+ }
347
+ return deps;
348
+ }
349
+ const merged = new _Set__default["default"]([...deps, ...resolved.fileNames]);
350
+ // Every shell chunk statically imports the entry, because
351
+ // Rollup co-locates all shared static code there. Preloading it
352
+ // would duplicate the entry's own `<script type="module">`.
353
+ merged.delete(url);
354
+ return [...merged];
355
+ }
356
+ }
357
+ }
358
+ };
359
+ },
360
+ // Expected to run before `vite:build-html`'s own `generateBundle`, which
361
+ // is where `resolveDependencies` is invoked. That ordering is internal to
362
+ // Vite rather than a contract, so the hook above warns instead of
363
+ // assuming it held.
364
+ generateBundle(_options, bundle) {
365
+ resolved = resolveShellChunks(bundle, roots);
366
+
367
+ // A partial match is the signal that a chunk moved: the shell is present
368
+ // but one name no longer resolves. Resolving nothing at all is not that
369
+ // signal, so it stays silent rather than failing a build whose entry
370
+ // never reaches these modules.
371
+ if (resolved.missingRoots.length === 0 || resolved.matchedRoots.length === 0) {
372
+ return;
373
+ }
374
+ const message = `vite-plugin-modulepreload-shell-chunks: expected shell chunks were ` + `not emitted: ${resolved.missingRoots.join(', ')}.\n` + `Other shell chunks resolved (${resolved.matchedRoots.join(', ')}), so these were likely renamed or re-split rather than ` + `legitimately absent. Those modules are no longer preloaded, so the ` + `page still works but loads them a round trip later.`;
375
+ if (onMissing === 'error') {
376
+ this.error(message);
377
+ } else {
378
+ this.warn(message);
379
+ }
380
+ }
381
+ };
382
+ }
383
+
211
384
  /**
212
385
  * Only a candidate filter: which links are actually rewritten is decided by
213
386
  * matching `href` against the CSS assets Vite really emitted (see
@@ -277,7 +450,7 @@ function pluginPostCleanup(options) {
277
450
  cwd: outputDir
278
451
  });
279
452
  for (const file of files) {
280
- const filePath = path__default["default"].join(outputDir, file);
453
+ const filePath = path__default$1["default"].join(outputDir, file);
281
454
  try {
282
455
  fs__default["default"].unlinkSync(filePath);
283
456
  totalFilesDeleted++;
@@ -308,7 +481,7 @@ async function run() {
308
481
  });
309
482
 
310
483
  // Generate `index.html` (template).
311
- const appEntryPoint = path__default$1["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
484
+ const appEntryPoint = path__default["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
312
485
  const html = mcHtmlTemplate.generateTemplate({
313
486
  // Define the module entry point (path relative from the `/public` folder).
314
487
  // NOTE: that this is different from the development configuration.
@@ -318,6 +491,10 @@ async function run() {
318
491
  fs__default$1["default"].writeFileSync(paths.paths.appIndexHtml, html, {
319
492
  encoding: 'utf8'
320
493
  });
494
+
495
+ // Resolved once here rather than inside the plugin list, which is built
496
+ // synchronously. Only reads which config file is present.
497
+ const isCustomViewBuild = await isCustomView();
321
498
  await vite.build({
322
499
  root: paths.paths.appRoot,
323
500
  base: './',
@@ -407,7 +584,14 @@ async function run() {
407
584
  // Fail the build if the emitted chunk graph contains circular imports.
408
585
  // Chunk cycles are silent at build time but crash at runtime with TDZ
409
586
  // errors (historical "aM is undefined" from the icons/app-shell split).
410
- pluginChunkCycleCheck(), shouldAnalyze && viteBundleAnalyzer.analyzer(analyzeOutput ? {
587
+ pluginChunkCycleCheck(),
588
+ // Custom Views import from the same package, so their builds emit these
589
+ // chunks and would carry ~128KB of preload hints for a navbar and
590
+ // project container `CustomViewShell` never renders. Decided from which
591
+ // config file is present: `getConfigPath` only resolves a path, and
592
+ // `loadConfig` rejects a project carrying both, so the two cases cannot
593
+ // overlap and this stays cheap enough for a build-time decision.
594
+ !isCustomViewBuild && pluginModulePreloadShellChunks(), shouldAnalyze && viteBundleAnalyzer.analyzer(analyzeOutput ? {
411
595
  analyzerMode: 'json',
412
596
  defaultSizes: 'stat',
413
597
  fileName: analyzeOutput
@@ -426,12 +610,12 @@ async function run() {
426
610
  // Vite will write the `index.html` to `/public/public/index.html`.
427
611
  // We need to move this file to the `/public` folder and rename it
428
612
  // to `index.html.template` (as expected by the `compile-html` command).
429
- path__default$1["default"].join(paths.paths.appBuild, 'public/index.html'), paths.paths.appIndexHtmlTemplate);
613
+ path__default["default"].join(paths.paths.appBuild, 'public/index.html'), paths.paths.appIndexHtmlTemplate);
430
614
  // Clean up nested folder
431
- fs__default$1["default"].rmdirSync(path__default$1["default"].join(paths.paths.appBuild, 'public'));
615
+ fs__default$1["default"].rmdirSync(path__default["default"].join(paths.paths.appBuild, 'public'));
432
616
 
433
617
  // Copy public assets
434
- fs__default$1["default"].copySync(path__default$1["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
618
+ fs__default$1["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
435
619
  dereference: true
436
620
  });
437
621
  }
@@ -3,7 +3,7 @@
3
3
  var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
4
4
  var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
5
5
  var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
6
- var path$1 = require('path');
6
+ var path = require('path');
7
7
  var pluginGraphql = require('@rollup/plugin-graphql');
8
8
  var pluginReact = require('@vitejs/plugin-react');
9
9
  var fs$1 = require('fs-extra');
@@ -13,6 +13,8 @@ var viteBundleAnalyzer = require('vite-bundle-analyzer');
13
13
  var assets = require('@commercetools-frontend/assets');
14
14
  var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
15
15
  var paths = require('./paths-b76fc753.cjs.dev.js');
16
+ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
17
+ var applicationConfig = require('@commercetools-frontend/application-config');
16
18
  var tryLoadNimbusPlugins = require('./try-load-nimbus-plugins-d502a5fe.cjs.dev.js');
17
19
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
18
20
  var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
@@ -26,11 +28,12 @@ var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/insta
26
28
  var cliLib = require('@formatjs/cli-lib');
27
29
  var pluginutils = require('@rollup/pluginutils');
28
30
  var i18nMessageComplilation = require('./i18n-message-complilation-7311cb29.cjs.dev.js');
31
+ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
29
32
  var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
30
33
  var _endsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/ends-with');
31
34
  var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
32
35
  var fs = require('node:fs');
33
- var path = require('node:path');
36
+ var path$1 = require('node:path');
34
37
  var glob = require('glob');
35
38
  var vitePluginSvgr = require('./vite-plugin-svgr-7d06f400.cjs.dev.js');
36
39
  require('@babel/runtime-corejs3/core-js-stable/instance/find');
@@ -47,10 +50,11 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
47
50
  var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
48
51
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
49
52
  var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
50
- var path__default$1 = /*#__PURE__*/_interopDefault(path$1);
53
+ var path__default = /*#__PURE__*/_interopDefault(path);
51
54
  var pluginGraphql__default = /*#__PURE__*/_interopDefault(pluginGraphql);
52
55
  var pluginReact__default = /*#__PURE__*/_interopDefault(pluginReact);
53
56
  var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
57
+ var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
54
58
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
55
59
  var _Object$values__default = /*#__PURE__*/_interopDefault(_Object$values);
56
60
  var _Map__default = /*#__PURE__*/_interopDefault(_Map);
@@ -60,11 +64,41 @@ var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfIns
60
64
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
61
65
  var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
62
66
  var _sortInstanceProperty__default = /*#__PURE__*/_interopDefault(_sortInstanceProperty);
67
+ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
63
68
  var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
64
69
  var _endsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_endsWithInstanceProperty);
65
70
  var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
66
71
  var fs__default = /*#__PURE__*/_interopDefault(fs);
67
- var path__default = /*#__PURE__*/_interopDefault(path);
72
+ var path__default$1 = /*#__PURE__*/_interopDefault(path$1);
73
+
74
+ /**
75
+ * Whether the app being built is a Custom View rather than a Custom
76
+ * Application.
77
+ *
78
+ * Decided from which configuration file is present, which is the same signal
79
+ * `processConfig` itself branches on. `getConfigPath` only resolves the file's
80
+ * path — it does not read env vars or process the config — so this stays cheap
81
+ * enough for a build-time decision. `loadConfig` rejects a project carrying
82
+ * both files, so the two cases cannot overlap.
83
+ *
84
+ * Matched on the file name only. Against the whole path, a Custom Application
85
+ * living anywhere under a directory like `custom-view-config-demo/` would read
86
+ * as a Custom View and silently lose the optimisation.
87
+ *
88
+ * Fails open: anything unexpected (no config found, a resolution error)
89
+ * answers `false`, so a detection gap leaves Custom Application behaviour
90
+ * intact rather than silently dropping an optimisation from a real app.
91
+ */
92
+ const isCustomView = async () => {
93
+ try {
94
+ var _context;
95
+ const configPath = await applicationConfig.getConfigPath();
96
+ if (!configPath) return false;
97
+ return _startsWithInstanceProperty__default["default"](_context = path__default["default"].basename(configPath)).call(_context, 'custom-view-config');
98
+ } catch {
99
+ return false;
100
+ }
101
+ };
68
102
 
69
103
  // Type guard to help with filtering arrays for nullish elements.
70
104
  function nonNullable(value) {
@@ -208,6 +242,145 @@ function vitePluginI18nMessageCompilation() {
208
242
  };
209
243
  }
210
244
 
245
+ // `application-shell-splitter` is deliberately absent. It is a root of the
246
+ // same wave, but it alone is ~1.2MB (Nimbus/chakra bindings) and pulls a
247
+ // further ~172KB `runtime` chunk, which would put ~1.5MB of high-priority
248
+ // preload in parallel with the 2.3MB entry that is the real critical path.
249
+ // Preloading it is a separate decision that needs a throttled measurement.
250
+ //
251
+ // When adding, renaming or removing a root here, update the assertion step in
252
+ // `.github/workflows/main.yml` to match — it checks these names by hand, so a
253
+ // drift makes CI pass or fail for the wrong reason.
254
+ const DEFAULT_ROOTS = ['navbar', 'project-container', 'user-settings-menu', 'use-applications-menu', 'requests-in-flight-loader'];
255
+ /**
256
+ * Resolves each root to its emitted chunk, then follows static `imports`
257
+ * transitively. The transitive walk is load-bearing rather than an
258
+ * optimisation: a browser is only guaranteed to preload dependencies that are
259
+ * listed individually, so preloading a root without its imports leaves them
260
+ * one round trip behind.
261
+ */
262
+ function resolveShellChunks(bundle, roots) {
263
+ var _context, _context4;
264
+ const chunks = _filterInstanceProperty__default["default"](_context = _Object$values__default["default"](bundle)).call(_context, entry => entry.type === 'chunk');
265
+ const byFileName = new _Map__default["default"](_mapInstanceProperty__default["default"](chunks).call(chunks, chunk => [chunk.fileName, chunk]));
266
+ const fileNames = new _Set__default["default"]();
267
+ const matchedRoots = [];
268
+ const missingRoots = [];
269
+ const visit = chunk => {
270
+ var _context2;
271
+ if (fileNames.has(chunk.fileName)) return;
272
+ fileNames.add(chunk.fileName);
273
+ _forEachInstanceProperty__default["default"](_context2 = chunk.imports).call(_context2, imported => {
274
+ const next = byFileName.get(imported);
275
+ if (next) visit(next);
276
+ });
277
+ };
278
+ _forEachInstanceProperty__default["default"](roots).call(roots, root => {
279
+ // Prefix, not exact: Rollup suffixes chunk names it has to disambiguate,
280
+ // so `navbar` has to match `navbar2`. The cost is that an app's own chunk
281
+ // named `navbar-…` would be preloaded too — a few KB of wasted hint on a
282
+ // page that is about to load the real navbar anyway.
283
+ const hits = _filterInstanceProperty__default["default"](chunks).call(chunks, chunk => {
284
+ var _context3;
285
+ return _startsWithInstanceProperty__default["default"](_context3 = chunk.name).call(_context3, root);
286
+ });
287
+ if (hits.length === 0) {
288
+ missingRoots.push(root);
289
+ return;
290
+ }
291
+ matchedRoots.push(root);
292
+ _forEachInstanceProperty__default["default"](hits).call(hits, visit);
293
+ });
294
+ return {
295
+ fileNames: _sortInstanceProperty__default["default"](_context4 = [...fileNames]).call(_context4),
296
+ matchedRoots,
297
+ missingRoots
298
+ };
299
+ }
300
+
301
+ /**
302
+ * Emits `<link rel="modulepreload">` for the authenticated shell chunk graph,
303
+ * so those chunks are fetched alongside the entry instead of waiting for it to
304
+ * execute and discover them.
305
+ *
306
+ * Works through `build.modulePreload.resolveDependencies` rather than by
307
+ * injecting tags directly. That hook renders its return value through
308
+ * `renderBuiltUrl`, which is what applies the `__CDN_URL__` prefix; tags a
309
+ * `transformIndexHtml` hook creates are emitted verbatim and would ship
310
+ * without it.
311
+ */
312
+ function pluginModulePreloadShellChunks() {
313
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
314
+ const roots = options.roots ?? DEFAULT_ROOTS;
315
+ const onMissing = options.onMissing ?? 'warn';
316
+ let resolved = null;
317
+ let hasWarnedAboutOrdering = false;
318
+ return {
319
+ name: 'vite-plugin-modulepreload-shell-chunks',
320
+ apply: 'build',
321
+ config(config) {
322
+ // Vite's config merge would turn an explicit `false` back into an
323
+ // object, silently re-enabling preloading the consumer switched off.
324
+ if (config.build?.modulePreload === false) return;
325
+ return {
326
+ build: {
327
+ modulePreload: {
328
+ resolveDependencies: (url, deps, _ref) => {
329
+ let hostType = _ref.hostType;
330
+ // Vite calls this once for the entry HTML and once per dynamic
331
+ // import. Appending for `js` too would bake the shell graph into
332
+ // every `__vitePreload` dependency array in the bundle.
333
+ if (hostType !== 'html') return deps;
334
+
335
+ // Reaching the HTML host with nothing resolved means
336
+ // `generateBundle` has not run yet, i.e. the plugin ordering
337
+ // below inverted. Every hint would silently disappear, so say
338
+ // so. `console.warn` rather than `this.warn`: this is a plain
339
+ // callback in the returned config, not a Rollup plugin hook,
340
+ // so there is no plugin context here.
341
+ if (!resolved) {
342
+ if (!hasWarnedAboutOrdering) {
343
+ hasWarnedAboutOrdering = true;
344
+ // eslint-disable-next-line no-console
345
+ console.warn(`vite-plugin-modulepreload-shell-chunks: the entry HTML ` + `asked for its preload dependencies before the bundle ` + `was analysed, so no shell chunks were preloaded. This ` + `plugin relies on its \`generateBundle\` running before ` + `\`vite:build-html\`'s, which is Vite-internal ordering ` + `— a Vite upgrade may have changed it.`);
346
+ }
347
+ return deps;
348
+ }
349
+ const merged = new _Set__default["default"]([...deps, ...resolved.fileNames]);
350
+ // Every shell chunk statically imports the entry, because
351
+ // Rollup co-locates all shared static code there. Preloading it
352
+ // would duplicate the entry's own `<script type="module">`.
353
+ merged.delete(url);
354
+ return [...merged];
355
+ }
356
+ }
357
+ }
358
+ };
359
+ },
360
+ // Expected to run before `vite:build-html`'s own `generateBundle`, which
361
+ // is where `resolveDependencies` is invoked. That ordering is internal to
362
+ // Vite rather than a contract, so the hook above warns instead of
363
+ // assuming it held.
364
+ generateBundle(_options, bundle) {
365
+ resolved = resolveShellChunks(bundle, roots);
366
+
367
+ // A partial match is the signal that a chunk moved: the shell is present
368
+ // but one name no longer resolves. Resolving nothing at all is not that
369
+ // signal, so it stays silent rather than failing a build whose entry
370
+ // never reaches these modules.
371
+ if (resolved.missingRoots.length === 0 || resolved.matchedRoots.length === 0) {
372
+ return;
373
+ }
374
+ const message = `vite-plugin-modulepreload-shell-chunks: expected shell chunks were ` + `not emitted: ${resolved.missingRoots.join(', ')}.\n` + `Other shell chunks resolved (${resolved.matchedRoots.join(', ')}), so these were likely renamed or re-split rather than ` + `legitimately absent. Those modules are no longer preloaded, so the ` + `page still works but loads them a round trip later.`;
375
+ if (onMissing === 'error') {
376
+ this.error(message);
377
+ } else {
378
+ this.warn(message);
379
+ }
380
+ }
381
+ };
382
+ }
383
+
211
384
  /**
212
385
  * Only a candidate filter: which links are actually rewritten is decided by
213
386
  * matching `href` against the CSS assets Vite really emitted (see
@@ -277,7 +450,7 @@ function pluginPostCleanup(options) {
277
450
  cwd: outputDir
278
451
  });
279
452
  for (const file of files) {
280
- const filePath = path__default["default"].join(outputDir, file);
453
+ const filePath = path__default$1["default"].join(outputDir, file);
281
454
  try {
282
455
  fs__default["default"].unlinkSync(filePath);
283
456
  totalFilesDeleted++;
@@ -308,7 +481,7 @@ async function run() {
308
481
  });
309
482
 
310
483
  // Generate `index.html` (template).
311
- const appEntryPoint = path__default$1["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
484
+ const appEntryPoint = path__default["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
312
485
  const html = mcHtmlTemplate.generateTemplate({
313
486
  // Define the module entry point (path relative from the `/public` folder).
314
487
  // NOTE: that this is different from the development configuration.
@@ -318,6 +491,10 @@ async function run() {
318
491
  fs__default$1["default"].writeFileSync(paths.paths.appIndexHtml, html, {
319
492
  encoding: 'utf8'
320
493
  });
494
+
495
+ // Resolved once here rather than inside the plugin list, which is built
496
+ // synchronously. Only reads which config file is present.
497
+ const isCustomViewBuild = await isCustomView();
321
498
  await vite.build({
322
499
  root: paths.paths.appRoot,
323
500
  base: './',
@@ -407,7 +584,14 @@ async function run() {
407
584
  // Fail the build if the emitted chunk graph contains circular imports.
408
585
  // Chunk cycles are silent at build time but crash at runtime with TDZ
409
586
  // errors (historical "aM is undefined" from the icons/app-shell split).
410
- pluginChunkCycleCheck(), shouldAnalyze && viteBundleAnalyzer.analyzer(analyzeOutput ? {
587
+ pluginChunkCycleCheck(),
588
+ // Custom Views import from the same package, so their builds emit these
589
+ // chunks and would carry ~128KB of preload hints for a navbar and
590
+ // project container `CustomViewShell` never renders. Decided from which
591
+ // config file is present: `getConfigPath` only resolves a path, and
592
+ // `loadConfig` rejects a project carrying both, so the two cases cannot
593
+ // overlap and this stays cheap enough for a build-time decision.
594
+ !isCustomViewBuild && pluginModulePreloadShellChunks(), shouldAnalyze && viteBundleAnalyzer.analyzer(analyzeOutput ? {
411
595
  analyzerMode: 'json',
412
596
  defaultSizes: 'stat',
413
597
  fileName: analyzeOutput
@@ -426,12 +610,12 @@ async function run() {
426
610
  // Vite will write the `index.html` to `/public/public/index.html`.
427
611
  // We need to move this file to the `/public` folder and rename it
428
612
  // to `index.html.template` (as expected by the `compile-html` command).
429
- path__default$1["default"].join(paths.paths.appBuild, 'public/index.html'), paths.paths.appIndexHtmlTemplate);
613
+ path__default["default"].join(paths.paths.appBuild, 'public/index.html'), paths.paths.appIndexHtmlTemplate);
430
614
  // Clean up nested folder
431
- fs__default$1["default"].rmdirSync(path__default$1["default"].join(paths.paths.appBuild, 'public'));
615
+ fs__default$1["default"].rmdirSync(path__default["default"].join(paths.paths.appBuild, 'public'));
432
616
 
433
617
  // Copy public assets
434
- fs__default$1["default"].copySync(path__default$1["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
618
+ fs__default$1["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
435
619
  dereference: true
436
620
  });
437
621
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var vendorsToTranspile = require('./vendors-to-transpile-6ab4ea06.cjs.dev.js');
6
6
 
7
7
  // NOTE: This string will be replaced on build time with the package version.
8
- var version = "27.12.0";
8
+ var version = "27.13.0";
9
9
 
10
10
  // These exports are deprecated.
11
11
 
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var vendorsToTranspile = require('./vendors-to-transpile-04a49d40.cjs.prod.js');
6
6
 
7
7
  // NOTE: This string will be replaced on build time with the package version.
8
- var version = "27.12.0";
8
+ var version = "27.13.0";
9
9
 
10
10
  // These exports are deprecated.
11
11
 
@@ -1,7 +1,7 @@
1
1
  export { v as vendorsToTranspile } from './vendors-to-transpile-7dc84a72.esm.js';
2
2
 
3
3
  // NOTE: This string will be replaced on build time with the package version.
4
- var version = "27.12.0";
4
+ var version = "27.13.0";
5
5
 
6
6
  // These exports are deprecated.
7
7
 
@@ -7,9 +7,9 @@ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/ins
7
7
  var chalk = require('chalk');
8
8
  var prompts = require('prompts');
9
9
  var applicationConfig = require('@commercetools-frontend/application-config');
10
- var configSyncHelpers = require('./config-sync-helpers-a24fc76b.cjs.prod.js');
10
+ var configSyncHelpers = require('./config-sync-helpers-ab74b949.cjs.prod.js');
11
11
  var credentialsStorage$1 = require('./credentials-storage-ea1c16dc.cjs.prod.js');
12
- var graphqlRequests = require('./graphql-requests-0f5e76bf.cjs.prod.js');
12
+ var graphqlRequests = require('./graphql-requests-7ca459c8.cjs.prod.js');
13
13
  require('@babel/runtime-corejs3/core-js-stable/json/stringify');
14
14
  require('lodash/omit');
15
15
  require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
@@ -36,7 +36,7 @@ require('graphql');
36
36
  require('graphql-request');
37
37
  require('@commercetools-frontend/constants');
38
38
  require('@commercetools/http-user-agent');
39
- require('./package-2ce7d094.cjs.prod.js');
39
+ require('./package-d1a1140f.cjs.prod.js');
40
40
 
41
41
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
42
42
 
@@ -5,9 +5,9 @@ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/insta
5
5
  import chalk from 'chalk';
6
6
  import prompts from 'prompts';
7
7
  import { processConfig } from '@commercetools-frontend/application-config';
8
- import { i as isCustomViewData, c as checkCustomApplicationStatus, p as performCreateCustomApplication, a as performUpdateCustomApplication, b as checkCustomViewStatus, d as performCreateCustomView, e as performUpdateCustomView } from './config-sync-helpers-e3387197.esm.js';
8
+ import { i as isCustomViewData, c as checkCustomApplicationStatus, p as performCreateCustomApplication, a as performUpdateCustomApplication, b as checkCustomViewStatus, d as performCreateCustomView, e as performUpdateCustomView } from './config-sync-helpers-649b6c87.esm.js';
9
9
  import { C as CredentialsStorage } from './credentials-storage-67deadc3.esm.js';
10
- import { f as fetchUserOrganizations } from './graphql-requests-94a1fb99.esm.js';
10
+ import { f as fetchUserOrganizations } from './graphql-requests-e034376f.esm.js';
11
11
  import '@babel/runtime-corejs3/core-js-stable/json/stringify';
12
12
  import 'lodash/omit';
13
13
  import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
@@ -34,7 +34,7 @@ import 'graphql';
34
34
  import 'graphql-request';
35
35
  import '@commercetools-frontend/constants';
36
36
  import '@commercetools/http-user-agent';
37
- import './package-cdfe3e2e.esm.js';
37
+ import './package-b717bf0d.esm.js';
38
38
 
39
39
  const credentialsStorage = new CredentialsStorage();
40
40
  async function promptForOrganization(_ref) {