@valbuild/tanstack-build 0.142.0 → 0.144.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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var regeneratorValues = require('./regeneratorValues-637c3146.cjs.prod.js');
5
+ var regeneratorValues = require('./regeneratorValues-295cad22.cjs.prod.js');
6
6
  var browser = require('@rolldown/browser');
7
7
  var projectPaths = require('./projectPaths-9cbecebf.cjs.prod.js');
8
8
  var parseAst = require('@rolldown/browser/parseAst');
@@ -374,32 +374,6 @@ function _transformServerFns() {
374
374
  return _transformServerFns.apply(this, arguments);
375
375
  }
376
376
 
377
- // One sha256, used by the build hash and by asset content-addressing.
378
- //
379
- // `crypto.subtle` rather than node:crypto: the builder runs in a browser tab as
380
- // well as in Node, and this is the only digest available in both.
381
- function sha256Hex(_x) {
382
- return _sha256Hex.apply(this, arguments);
383
- }
384
- function _sha256Hex() {
385
- _sha256Hex = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(text) {
386
- var digest;
387
- return regeneratorValues._regenerator().w(function (_context) {
388
- while (1) switch (_context.n) {
389
- case 0:
390
- _context.n = 1;
391
- return crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
392
- case 1:
393
- digest = _context.v;
394
- return _context.a(2, regeneratorValues._toConsumableArray(new Uint8Array(digest)).map(function (_byte) {
395
- return _byte.toString(16).padStart(2, "0");
396
- }).join(""));
397
- }
398
- }, _callee);
399
- }));
400
- return _sha256Hex.apply(this, arguments);
401
- }
402
-
403
377
  var isCssModule = function isCssModule(path) {
404
378
  return /\.module\.css$/.test(path.split("?")[0]);
405
379
  };
@@ -443,7 +417,7 @@ function _transformCssModule() {
443
417
  while (1) switch (_context.n) {
444
418
  case 0:
445
419
  _context.n = 1;
446
- return sha256Hex(path);
420
+ return regeneratorValues.sha256Hex(path);
447
421
  case 1:
448
422
  suffix = _context.v.slice(0, 8);
449
423
  warnings = [];
@@ -480,6 +454,93 @@ var cssModuleExports = function cssModuleExports(names) {
480
454
  return "export default ".concat(JSON.stringify(names, null, 2), "\n");
481
455
  };
482
456
 
457
+ // `@import` inside a stylesheet.
458
+ /**
459
+ * A comment, or an `@import` with a quoted target -- `@import "x";`,
460
+ * `@import 'x' layer(base);`, `@import url("x") screen;`.
461
+ *
462
+ * Comments are matched so they can be skipped: an `@import` inside one is
463
+ * documentation, not an import. An unquoted `url(x)` is left for the browser,
464
+ * which is also what it does with one.
465
+ */
466
+ var IMPORT_OR_COMMENT = /\/\*[\s\S]*?\*\/|@import\s+(?:url\(\s*)?(["'])([^"']+)\1\s*\)?\s*([^;]*);/g;
467
+ var isTailwind = function isTailwind(specifier) {
468
+ return /^tailwindcss(\/|$)/.test(specifier);
469
+ };
470
+ var isUrl = function isUrl(specifier) {
471
+ return /^([a-z]+:)?\/\//i.test(specifier) || specifier.startsWith("data:");
472
+ };
473
+ var isRelative = function isRelative(specifier) {
474
+ return specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/");
475
+ };
476
+
477
+ /**
478
+ * What an `@import`'s conditions do to the sheet it pulls in.
479
+ *
480
+ * `layer(name)` puts it in a cascade layer, `supports(...)` behind a feature
481
+ * query and anything left over is a media query -- so inlining has to keep
482
+ * each as the block it would have been, or the rules would apply everywhere.
483
+ */
484
+ function wrap(css, conditions) {
485
+ var rest = conditions.trim();
486
+ var layer = null;
487
+ var supports = null;
488
+ var layerMatch = /^layer(?:\(([^)]*)\))?/.exec(rest);
489
+ if (layerMatch) {
490
+ var _layerMatch$;
491
+ layer = ((_layerMatch$ = layerMatch[1]) !== null && _layerMatch$ !== void 0 ? _layerMatch$ : "").trim();
492
+ rest = rest.slice(layerMatch[0].length).trim();
493
+ }
494
+ var supportsMatch = /^supports\(((?:[^()]|\([^()]*\))*)\)/.exec(rest);
495
+ if (supportsMatch) {
496
+ supports = supportsMatch[1].trim();
497
+ rest = rest.slice(supportsMatch[0].length).trim();
498
+ }
499
+ var out = css;
500
+ if (layer !== null) out = "@layer".concat(layer ? " ".concat(layer) : "", " {\n").concat(out, "\n}");
501
+ if (supports !== null) out = "@supports (".concat(supports, ") {\n").concat(out, "\n}");
502
+ if (rest) out = "@media ".concat(rest, " {\n").concat(out, "\n}");
503
+ return out;
504
+ }
505
+
506
+ /**
507
+ * The stylesheet at `path`, with every `@import` it can resolve inlined.
508
+ *
509
+ * `path` is the project path of the sheet, or the specifier of a dependency's
510
+ * sheet. A dependency's own relative imports were flattened when it was read
511
+ * (see `collectDependencyCss`), so what is left in one is bare, if anything.
512
+ */
513
+ function expandCssImports(path, css, context) {
514
+ var fromDependency = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
515
+ return css.replace(IMPORT_OR_COMMENT, function (match, quote, specifier, conditions) {
516
+ if (quote === undefined || specifier === undefined) return match;
517
+ if (isTailwind(specifier) || isUrl(specifier)) return match;
518
+ if (isRelative(specifier)) {
519
+ if (fromDependency) {
520
+ context.warnings.push("'".concat(path, "' imports '").concat(specifier, "', which was not carried with it. ") + "Its own stylesheets are read when the vendor layer is built; " + "publish again from the CLI.");
521
+ return "";
522
+ }
523
+ var target = resolve(dirname(path), specifier);
524
+ var _text = context.files[target];
525
+ if (_text === undefined) {
526
+ context.warnings.push("'".concat(path, "' imports '").concat(specifier, "', and there is no '").concat(target, "' in the project."));
527
+ return "";
528
+ }
529
+ if (context.seen.has(target)) return "";
530
+ context.seen.add(target);
531
+ return wrap(expandCssImports(target, _text, context).trim(), conditions !== null && conditions !== void 0 ? conditions : "");
532
+ }
533
+ var text = context.dependencyCss[specifier];
534
+ if (text === undefined) {
535
+ context.warnings.push("'".concat(path, "' imports '").concat(specifier, "', a stylesheet this build does not carry. ") + "Is '".concat(specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0], "' ") + "in package.json's dependencies?");
536
+ return "";
537
+ }
538
+ if (context.seen.has(specifier)) return "";
539
+ context.seen.add(specifier);
540
+ return wrap(expandCssImports(specifier, text, context, true).trim(), conditions !== null && conditions !== void 0 ? conditions : "");
541
+ });
542
+ }
543
+
483
544
  var CSS_EXTENSIONS = [".css"];
484
545
 
485
546
  /**
@@ -560,6 +621,7 @@ function _collectCss() {
560
621
  contributing,
561
622
  modules,
562
623
  warnings,
624
+ imports,
563
625
  walk,
564
626
  _walk,
565
627
  _args3 = arguments;
@@ -599,7 +661,7 @@ function _collectCss() {
599
661
  _context2.n = 4;
600
662
  break;
601
663
  case 3:
602
- sheets.push(text);
664
+ sheets.push(expandCssImports(bare, text, imports));
603
665
  case 4:
604
666
  contributing.push(bare);
605
667
  return _context2.a(2);
@@ -643,7 +705,7 @@ function _collectCss() {
643
705
  break;
644
706
  }
645
707
  visited.add(_bare);
646
- sheets.push(dependencyCss[_bare]);
708
+ sheets.push(expandCssImports(_bare, dependencyCss[_bare], imports, true));
647
709
  contributing.push(_bare);
648
710
  return _context2.a(3, 21);
649
711
  case 11:
@@ -723,7 +785,15 @@ function _collectCss() {
723
785
  sheets = [];
724
786
  contributing = [];
725
787
  modules = {};
726
- warnings = [];
788
+ warnings = []; // `@import`s inside the sheets. `seen` is the walk's own `visited`, so a
789
+ // stylesheet reached both from a module and from another sheet is emitted
790
+ // once, wherever it is reached first.
791
+ imports = {
792
+ files: files,
793
+ dependencyCss: dependencyCss,
794
+ seen: visited,
795
+ warnings: warnings
796
+ };
727
797
  _context3.n = 1;
728
798
  return walk(entry);
729
799
  case 1:
@@ -943,109 +1013,6 @@ function _compileTailwind() {
943
1013
  return _compileTailwind.apply(this, arguments);
944
1014
  }
945
1015
 
946
- /**
947
- * Extensions treated as assets.
948
- *
949
- * Deliberately a list rather than "anything not JS or CSS": an unknown
950
- * extension should fail as an unresolved import naming the file, not silently
951
- * become a URL to something the browser cannot use.
952
- */
953
- var ASSET_TYPES = {
954
- ".png": "image/png",
955
- ".jpg": "image/jpeg",
956
- ".jpeg": "image/jpeg",
957
- ".gif": "image/gif",
958
- ".webp": "image/webp",
959
- ".avif": "image/avif",
960
- ".svg": "image/svg+xml",
961
- ".ico": "image/x-icon",
962
- ".woff": "font/woff",
963
- ".woff2": "font/woff2",
964
- ".ttf": "font/ttf",
965
- ".otf": "font/otf",
966
- ".mp4": "video/mp4",
967
- ".webm": "video/webm",
968
- ".mp3": "audio/mpeg",
969
- ".wav": "audio/wav",
970
- ".pdf": "application/pdf",
971
- ".txt": "text/plain"
972
- };
973
- var extensionOf = function extensionOf(path) {
974
- var at = path.lastIndexOf(".");
975
- return at === -1 ? "" : path.slice(at).toLowerCase();
976
- };
977
- var isAsset = function isAsset(path) {
978
- return extensionOf(path) in ASSET_TYPES;
979
- };
980
- var mimeOf = function mimeOf(path) {
981
- var _ASSET_TYPES$extensio;
982
- return (_ASSET_TYPES$extensio = ASSET_TYPES[extensionOf(path)]) !== null && _ASSET_TYPES$extensio !== void 0 ? _ASSET_TYPES$extensio : "application/octet-stream";
983
- };
984
-
985
- /**
986
- * Below this many decoded bytes, an asset is inlined as a data URI.
987
- *
988
- * 4 kB, matching Vite's `assetsInlineLimit` default. The trade is the same one
989
- * Vite is making: an extra request costs more than 4 kB of base64 does, and
990
- * above that it stops being true.
991
- */
992
- var INLINE_LIMIT = 4096;
993
-
994
- /** Decoded byte length of base64, without decoding it. */
995
- function base64Bytes(base64) {
996
- var clean = base64.replace(/=+$/, "");
997
- return Math.floor(clean.length * 3 / 4);
998
- }
999
- /**
1000
- * Where an asset import resolves to, for one target.
1001
- *
1002
- * Server and client get the *same* URL. An asset is a URL in both, and SSR has
1003
- * to emit the same `src` the browser will hydrate against -- a server bundle
1004
- * with a different URL would be a hydration mismatch on every image.
1005
- */
1006
- function resolveAsset(_x, _x2) {
1007
- return _resolveAsset.apply(this, arguments);
1008
- }
1009
-
1010
- /** Where published assets are served from. Matched by the loader. */
1011
- function _resolveAsset() {
1012
- _resolveAsset = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(path, base64) {
1013
- var hash, name;
1014
- return regeneratorValues._regenerator().w(function (_context) {
1015
- while (1) switch (_context.n) {
1016
- case 0:
1017
- if (!(base64Bytes(base64) <= INLINE_LIMIT)) {
1018
- _context.n = 1;
1019
- break;
1020
- }
1021
- return _context.a(2, {
1022
- url: "data:".concat(mimeOf(path), ";base64,").concat(base64)
1023
- });
1024
- case 1:
1025
- _context.n = 2;
1026
- return sha256Hex(base64);
1027
- case 2:
1028
- hash = _context.v.slice(0, 16);
1029
- name = "".concat(hash).concat(extensionOf(path));
1030
- return _context.a(2, {
1031
- url: "".concat(ASSET_BASE).concat(name),
1032
- file: {
1033
- name: name,
1034
- base64: base64
1035
- }
1036
- });
1037
- }
1038
- }, _callee);
1039
- }));
1040
- return _resolveAsset.apply(this, arguments);
1041
- }
1042
- var ASSET_BASE = "/_app/a/";
1043
-
1044
- /** The module a resolved asset import becomes. */
1045
- var assetModule = function assetModule(url) {
1046
- return "export default ".concat(JSON.stringify(url), "\n");
1047
- };
1048
-
1049
1016
  /** Cheap pre-filter: skip the parse unless one of these appears in the source. */
1050
1017
  var MARKERS = ["createIsomorphicFn", "createServerOnlyFn", "createClientOnlyFn", "createMiddleware", "ClientOnly"];
1051
1018
 
@@ -2747,7 +2714,7 @@ function projectPlugin(files, projectSource, splitter, cssModules, aliases, asse
2747
2714
  // Assets are resolved against their own map: they are not text, so they
2748
2715
  // never entered `files`. Checked first because an asset path would not
2749
2716
  // resolve there anyway, and the error would name the wrong thing.
2750
- if (isAsset(base) && base in assets) return ASSET_PREFIX + base;
2717
+ if (regeneratorValues.isAsset(base) && base in assets) return ASSET_PREFIX + base;
2751
2718
  // A CSS module's *import* is its name mapping. The stylesheet half was
2752
2719
  // produced by the CSS pass; this is the object the module returns.
2753
2720
  var bareCss = withoutCssQuery(base);
@@ -2837,9 +2804,9 @@ function projectPlugin(files, projectSource, splitter, cssModules, aliases, asse
2837
2804
  }
2838
2805
  // Resolved ahead of the build, because `load` cannot be async here and
2839
2806
  // because the URL has to be identical across targets -- see resolveAsset.
2840
- if (id === CSS_URL_ID) return assetModule(CSS_URL);
2807
+ if (id === CSS_URL_ID) return regeneratorValues.assetModule(CSS_URL);
2841
2808
  if (id.startsWith(ASSET_PREFIX)) {
2842
- return assetModule(assetUrls.get(id.slice(ASSET_PREFIX.length)));
2809
+ return regeneratorValues.assetModule(assetUrls.get(id.slice(ASSET_PREFIX.length)));
2843
2810
  }
2844
2811
  if (!(id in files)) return null;
2845
2812
 
@@ -3205,7 +3172,7 @@ function _buildUserApp() {
3205
3172
  }
3206
3173
  _Object$entries3$_i = regeneratorValues._slicedToArray(_Object$entries3[_i3], 2), path = _Object$entries3$_i[0], base64 = _Object$entries3$_i[1];
3207
3174
  _context3.n = 5;
3208
- return resolveAsset(path, base64);
3175
+ return regeneratorValues.resolveAsset(path, base64);
3209
3176
  case 5:
3210
3177
  resolved = _context3.v;
3211
3178
  assetUrls.set(path, resolved.url);
@@ -3215,6 +3182,8 @@ function _buildUserApp() {
3215
3182
  _context3.n = 4;
3216
3183
  break;
3217
3184
  case 7:
3185
+ Object.assign(assetFiles, input.dependencyAssets);
3186
+
3218
3187
  // Collected once rather than per target: the stylesheet is the same either
3219
3188
  // way, and only the client ever uses it. Whether a build produced one is
3220
3189
  // recorded in the head pointer at publish time, because the loader -- not the
@@ -3308,7 +3277,7 @@ function _buildUserApp() {
3308
3277
  _t11 = input.rsc ? clientModules : undefined;
3309
3278
  _t12 = input.target.base.rev;
3310
3279
  _context3.n = 16;
3311
- return sha256Hex([input.target.base.rev, rev, styles].concat(regeneratorValues._toConsumableArray(Object.entries(assetFiles).flat()), regeneratorValues._toConsumableArray(Object.entries(publicFiles).flat()), regeneratorValues._toConsumableArray([serverBuild, clientBuild, rscBuild].flatMap(function (built) {
3280
+ return regeneratorValues.sha256Hex([input.target.base.rev, rev, styles].concat(regeneratorValues._toConsumableArray(Object.entries(assetFiles).flat()), regeneratorValues._toConsumableArray(Object.entries(publicFiles).flat()), regeneratorValues._toConsumableArray([serverBuild, clientBuild, rscBuild].flatMap(function (built) {
3312
3281
  return built ? [built.code].concat(regeneratorValues._toConsumableArray(Object.entries(built.chunks).flat())) : [];
3313
3282
  }))).join("\0"));
3314
3283
  case 16:
@@ -3435,7 +3404,7 @@ function _publishArtifacts() {
3435
3404
  _t = key;
3436
3405
  _t2 = body;
3437
3406
  _context.n = 1;
3438
- return sha256Hex(body);
3407
+ return regeneratorValues.sha256Hex(body);
3439
3408
  case 1:
3440
3409
  _t3 = _context.v;
3441
3410
  _t4 = encoder.encode(body).length;
@@ -4140,25 +4109,25 @@ function wireUp(files, options) {
4140
4109
  };
4141
4110
  }
4142
4111
 
4112
+ exports.INLINE_LIMIT = regeneratorValues.INLINE_LIMIT;
4113
+ exports.base64Bytes = regeneratorValues.base64Bytes;
4114
+ exports.isAsset = regeneratorValues.isAsset;
4143
4115
  exports.ENTRY = projectPaths.ENTRY;
4144
4116
  exports.ROUTES_DIR = projectPaths.ROUTES_DIR;
4145
4117
  exports.TREE = projectPaths.TREE;
4146
4118
  exports.ARTIFACT_KEYS = artifactKeys.ARTIFACT_KEYS;
4147
4119
  exports.ARTIFACT_PREFIXES = artifactKeys.ARTIFACT_PREFIXES;
4148
4120
  exports.ENTRY_CHUNK = ENTRY_CHUNK;
4149
- exports.INLINE_LIMIT = INLINE_LIMIT;
4150
4121
  exports.PROJECT_SOURCE = PROJECT_SOURCE;
4151
4122
  exports.PUBLIC_PREFIX = PUBLIC_PREFIX;
4152
4123
  exports.VAL_SERVER_PATH = VAL_SERVER_PATH;
4153
4124
  exports.aliasMap = aliasMap;
4154
4125
  exports.bakedGit = bakedGit;
4155
4126
  exports.bakedJob = bakedJob;
4156
- exports.base64Bytes = base64Bytes;
4157
4127
  exports.blobSha = blobSha;
4158
4128
  exports.buildUserApp = buildUserApp;
4159
4129
  exports.fetchBuildTarget = fetchBuildTarget;
4160
4130
  exports.fetchBuildTargetRev = fetchBuildTargetRev;
4161
- exports.isAsset = isAsset;
4162
4131
  exports.isValProject = isValProject;
4163
4132
  exports.isWired = isWired;
4164
4133
  exports.publishArtifacts = publishArtifacts;
@@ -1,4 +1,5 @@
1
- import { _ as _createForOfIteratorHelper, a as _asyncToGenerator, b as _regenerator, c as _toConsumableArray, d as _slicedToArray, e as _regeneratorValues, f as _objectSpread2, g as _defineProperty } from './regeneratorValues-3acdc3fe.esm.js';
1
+ import { _ as _createForOfIteratorHelper, a as _asyncToGenerator, b as _regenerator, c as _toConsumableArray, d as _slicedToArray, s as sha256Hex, e as _regeneratorValues, f as _objectSpread2, r as resolveAsset, g as assetModule, i as isAsset, h as _defineProperty } from './regeneratorValues-af449040.esm.js';
2
+ export { I as INLINE_LIMIT, j as base64Bytes, i as isAsset } from './regeneratorValues-af449040.esm.js';
2
3
  import { build } from '@rolldown/browser';
3
4
  import { E as ENTRY, T as TREE } from './projectPaths-5e4defea.esm.js';
4
5
  export { E as ENTRY, R as ROUTES_DIR, T as TREE } from './projectPaths-5e4defea.esm.js';
@@ -372,32 +373,6 @@ function _transformServerFns() {
372
373
  return _transformServerFns.apply(this, arguments);
373
374
  }
374
375
 
375
- // One sha256, used by the build hash and by asset content-addressing.
376
- //
377
- // `crypto.subtle` rather than node:crypto: the builder runs in a browser tab as
378
- // well as in Node, and this is the only digest available in both.
379
- function sha256Hex(_x) {
380
- return _sha256Hex.apply(this, arguments);
381
- }
382
- function _sha256Hex() {
383
- _sha256Hex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(text) {
384
- var digest;
385
- return _regenerator().w(function (_context) {
386
- while (1) switch (_context.n) {
387
- case 0:
388
- _context.n = 1;
389
- return crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
390
- case 1:
391
- digest = _context.v;
392
- return _context.a(2, _toConsumableArray(new Uint8Array(digest)).map(function (_byte) {
393
- return _byte.toString(16).padStart(2, "0");
394
- }).join(""));
395
- }
396
- }, _callee);
397
- }));
398
- return _sha256Hex.apply(this, arguments);
399
- }
400
-
401
376
  var isCssModule = function isCssModule(path) {
402
377
  return /\.module\.css$/.test(path.split("?")[0]);
403
378
  };
@@ -478,6 +453,93 @@ var cssModuleExports = function cssModuleExports(names) {
478
453
  return "export default ".concat(JSON.stringify(names, null, 2), "\n");
479
454
  };
480
455
 
456
+ // `@import` inside a stylesheet.
457
+ /**
458
+ * A comment, or an `@import` with a quoted target -- `@import "x";`,
459
+ * `@import 'x' layer(base);`, `@import url("x") screen;`.
460
+ *
461
+ * Comments are matched so they can be skipped: an `@import` inside one is
462
+ * documentation, not an import. An unquoted `url(x)` is left for the browser,
463
+ * which is also what it does with one.
464
+ */
465
+ var IMPORT_OR_COMMENT = /\/\*[\s\S]*?\*\/|@import\s+(?:url\(\s*)?(["'])([^"']+)\1\s*\)?\s*([^;]*);/g;
466
+ var isTailwind = function isTailwind(specifier) {
467
+ return /^tailwindcss(\/|$)/.test(specifier);
468
+ };
469
+ var isUrl = function isUrl(specifier) {
470
+ return /^([a-z]+:)?\/\//i.test(specifier) || specifier.startsWith("data:");
471
+ };
472
+ var isRelative = function isRelative(specifier) {
473
+ return specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/");
474
+ };
475
+
476
+ /**
477
+ * What an `@import`'s conditions do to the sheet it pulls in.
478
+ *
479
+ * `layer(name)` puts it in a cascade layer, `supports(...)` behind a feature
480
+ * query and anything left over is a media query -- so inlining has to keep
481
+ * each as the block it would have been, or the rules would apply everywhere.
482
+ */
483
+ function wrap(css, conditions) {
484
+ var rest = conditions.trim();
485
+ var layer = null;
486
+ var supports = null;
487
+ var layerMatch = /^layer(?:\(([^)]*)\))?/.exec(rest);
488
+ if (layerMatch) {
489
+ var _layerMatch$;
490
+ layer = ((_layerMatch$ = layerMatch[1]) !== null && _layerMatch$ !== void 0 ? _layerMatch$ : "").trim();
491
+ rest = rest.slice(layerMatch[0].length).trim();
492
+ }
493
+ var supportsMatch = /^supports\(((?:[^()]|\([^()]*\))*)\)/.exec(rest);
494
+ if (supportsMatch) {
495
+ supports = supportsMatch[1].trim();
496
+ rest = rest.slice(supportsMatch[0].length).trim();
497
+ }
498
+ var out = css;
499
+ if (layer !== null) out = "@layer".concat(layer ? " ".concat(layer) : "", " {\n").concat(out, "\n}");
500
+ if (supports !== null) out = "@supports (".concat(supports, ") {\n").concat(out, "\n}");
501
+ if (rest) out = "@media ".concat(rest, " {\n").concat(out, "\n}");
502
+ return out;
503
+ }
504
+
505
+ /**
506
+ * The stylesheet at `path`, with every `@import` it can resolve inlined.
507
+ *
508
+ * `path` is the project path of the sheet, or the specifier of a dependency's
509
+ * sheet. A dependency's own relative imports were flattened when it was read
510
+ * (see `collectDependencyCss`), so what is left in one is bare, if anything.
511
+ */
512
+ function expandCssImports(path, css, context) {
513
+ var fromDependency = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
514
+ return css.replace(IMPORT_OR_COMMENT, function (match, quote, specifier, conditions) {
515
+ if (quote === undefined || specifier === undefined) return match;
516
+ if (isTailwind(specifier) || isUrl(specifier)) return match;
517
+ if (isRelative(specifier)) {
518
+ if (fromDependency) {
519
+ context.warnings.push("'".concat(path, "' imports '").concat(specifier, "', which was not carried with it. ") + "Its own stylesheets are read when the vendor layer is built; " + "publish again from the CLI.");
520
+ return "";
521
+ }
522
+ var target = resolve(dirname(path), specifier);
523
+ var _text = context.files[target];
524
+ if (_text === undefined) {
525
+ context.warnings.push("'".concat(path, "' imports '").concat(specifier, "', and there is no '").concat(target, "' in the project."));
526
+ return "";
527
+ }
528
+ if (context.seen.has(target)) return "";
529
+ context.seen.add(target);
530
+ return wrap(expandCssImports(target, _text, context).trim(), conditions !== null && conditions !== void 0 ? conditions : "");
531
+ }
532
+ var text = context.dependencyCss[specifier];
533
+ if (text === undefined) {
534
+ context.warnings.push("'".concat(path, "' imports '").concat(specifier, "', a stylesheet this build does not carry. ") + "Is '".concat(specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0], "' ") + "in package.json's dependencies?");
535
+ return "";
536
+ }
537
+ if (context.seen.has(specifier)) return "";
538
+ context.seen.add(specifier);
539
+ return wrap(expandCssImports(specifier, text, context, true).trim(), conditions !== null && conditions !== void 0 ? conditions : "");
540
+ });
541
+ }
542
+
481
543
  var CSS_EXTENSIONS = [".css"];
482
544
 
483
545
  /**
@@ -558,6 +620,7 @@ function _collectCss() {
558
620
  contributing,
559
621
  modules,
560
622
  warnings,
623
+ imports,
561
624
  walk,
562
625
  _walk,
563
626
  _args3 = arguments;
@@ -597,7 +660,7 @@ function _collectCss() {
597
660
  _context2.n = 4;
598
661
  break;
599
662
  case 3:
600
- sheets.push(text);
663
+ sheets.push(expandCssImports(bare, text, imports));
601
664
  case 4:
602
665
  contributing.push(bare);
603
666
  return _context2.a(2);
@@ -641,7 +704,7 @@ function _collectCss() {
641
704
  break;
642
705
  }
643
706
  visited.add(_bare);
644
- sheets.push(dependencyCss[_bare]);
707
+ sheets.push(expandCssImports(_bare, dependencyCss[_bare], imports, true));
645
708
  contributing.push(_bare);
646
709
  return _context2.a(3, 21);
647
710
  case 11:
@@ -721,7 +784,15 @@ function _collectCss() {
721
784
  sheets = [];
722
785
  contributing = [];
723
786
  modules = {};
724
- warnings = [];
787
+ warnings = []; // `@import`s inside the sheets. `seen` is the walk's own `visited`, so a
788
+ // stylesheet reached both from a module and from another sheet is emitted
789
+ // once, wherever it is reached first.
790
+ imports = {
791
+ files: files,
792
+ dependencyCss: dependencyCss,
793
+ seen: visited,
794
+ warnings: warnings
795
+ };
725
796
  _context3.n = 1;
726
797
  return walk(entry);
727
798
  case 1:
@@ -941,109 +1012,6 @@ function _compileTailwind() {
941
1012
  return _compileTailwind.apply(this, arguments);
942
1013
  }
943
1014
 
944
- /**
945
- * Extensions treated as assets.
946
- *
947
- * Deliberately a list rather than "anything not JS or CSS": an unknown
948
- * extension should fail as an unresolved import naming the file, not silently
949
- * become a URL to something the browser cannot use.
950
- */
951
- var ASSET_TYPES = {
952
- ".png": "image/png",
953
- ".jpg": "image/jpeg",
954
- ".jpeg": "image/jpeg",
955
- ".gif": "image/gif",
956
- ".webp": "image/webp",
957
- ".avif": "image/avif",
958
- ".svg": "image/svg+xml",
959
- ".ico": "image/x-icon",
960
- ".woff": "font/woff",
961
- ".woff2": "font/woff2",
962
- ".ttf": "font/ttf",
963
- ".otf": "font/otf",
964
- ".mp4": "video/mp4",
965
- ".webm": "video/webm",
966
- ".mp3": "audio/mpeg",
967
- ".wav": "audio/wav",
968
- ".pdf": "application/pdf",
969
- ".txt": "text/plain"
970
- };
971
- var extensionOf = function extensionOf(path) {
972
- var at = path.lastIndexOf(".");
973
- return at === -1 ? "" : path.slice(at).toLowerCase();
974
- };
975
- var isAsset = function isAsset(path) {
976
- return extensionOf(path) in ASSET_TYPES;
977
- };
978
- var mimeOf = function mimeOf(path) {
979
- var _ASSET_TYPES$extensio;
980
- return (_ASSET_TYPES$extensio = ASSET_TYPES[extensionOf(path)]) !== null && _ASSET_TYPES$extensio !== void 0 ? _ASSET_TYPES$extensio : "application/octet-stream";
981
- };
982
-
983
- /**
984
- * Below this many decoded bytes, an asset is inlined as a data URI.
985
- *
986
- * 4 kB, matching Vite's `assetsInlineLimit` default. The trade is the same one
987
- * Vite is making: an extra request costs more than 4 kB of base64 does, and
988
- * above that it stops being true.
989
- */
990
- var INLINE_LIMIT = 4096;
991
-
992
- /** Decoded byte length of base64, without decoding it. */
993
- function base64Bytes(base64) {
994
- var clean = base64.replace(/=+$/, "");
995
- return Math.floor(clean.length * 3 / 4);
996
- }
997
- /**
998
- * Where an asset import resolves to, for one target.
999
- *
1000
- * Server and client get the *same* URL. An asset is a URL in both, and SSR has
1001
- * to emit the same `src` the browser will hydrate against -- a server bundle
1002
- * with a different URL would be a hydration mismatch on every image.
1003
- */
1004
- function resolveAsset(_x, _x2) {
1005
- return _resolveAsset.apply(this, arguments);
1006
- }
1007
-
1008
- /** Where published assets are served from. Matched by the loader. */
1009
- function _resolveAsset() {
1010
- _resolveAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(path, base64) {
1011
- var hash, name;
1012
- return _regenerator().w(function (_context) {
1013
- while (1) switch (_context.n) {
1014
- case 0:
1015
- if (!(base64Bytes(base64) <= INLINE_LIMIT)) {
1016
- _context.n = 1;
1017
- break;
1018
- }
1019
- return _context.a(2, {
1020
- url: "data:".concat(mimeOf(path), ";base64,").concat(base64)
1021
- });
1022
- case 1:
1023
- _context.n = 2;
1024
- return sha256Hex(base64);
1025
- case 2:
1026
- hash = _context.v.slice(0, 16);
1027
- name = "".concat(hash).concat(extensionOf(path));
1028
- return _context.a(2, {
1029
- url: "".concat(ASSET_BASE).concat(name),
1030
- file: {
1031
- name: name,
1032
- base64: base64
1033
- }
1034
- });
1035
- }
1036
- }, _callee);
1037
- }));
1038
- return _resolveAsset.apply(this, arguments);
1039
- }
1040
- var ASSET_BASE = "/_app/a/";
1041
-
1042
- /** The module a resolved asset import becomes. */
1043
- var assetModule = function assetModule(url) {
1044
- return "export default ".concat(JSON.stringify(url), "\n");
1045
- };
1046
-
1047
1015
  /** Cheap pre-filter: skip the parse unless one of these appears in the source. */
1048
1016
  var MARKERS = ["createIsomorphicFn", "createServerOnlyFn", "createClientOnlyFn", "createMiddleware", "ClientOnly"];
1049
1017
 
@@ -3213,6 +3181,8 @@ function _buildUserApp() {
3213
3181
  _context3.n = 4;
3214
3182
  break;
3215
3183
  case 7:
3184
+ Object.assign(assetFiles, input.dependencyAssets);
3185
+
3216
3186
  // Collected once rather than per target: the stylesheet is the same either
3217
3187
  // way, and only the client ever uses it. Whether a build produced one is
3218
3188
  // recorded in the head pointer at publish time, because the loader -- not the
@@ -4138,4 +4108,4 @@ function wireUp(files, options) {
4138
4108
  };
4139
4109
  }
4140
4110
 
4141
- export { ENTRY_CHUNK, INLINE_LIMIT, PROJECT_SOURCE, PUBLIC_PREFIX, VAL_SERVER_PATH, aliasMap, bakedGit, bakedJob, base64Bytes, blobSha, buildUserApp, fetchBuildTarget, fetchBuildTargetRev, isAsset, isValProject, isWired, publishArtifacts, publishPayload, rebakeGit, resolveInFiles, scanCandidates, treeSha, treeShaOfText, usesTailwind, wireUp, wiredValServer };
4111
+ export { ENTRY_CHUNK, PROJECT_SOURCE, PUBLIC_PREFIX, VAL_SERVER_PATH, aliasMap, bakedGit, bakedJob, blobSha, buildUserApp, fetchBuildTarget, fetchBuildTargetRev, isValProject, isWired, publishArtifacts, publishPayload, rebakeGit, resolveInFiles, scanCandidates, treeSha, treeShaOfText, usesTailwind, wireUp, wiredValServer };