vite 5.0.11 → 5.1.0-beta.1

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.
@@ -1,914 +0,0 @@
1
- import { y as getDefaultExportFromCjs } from './dep-V3BH7oO1.js';
2
- import require$$0 from 'path';
3
- import require$$0__default from 'fs';
4
- import { l as lib } from './dep-8a-6Quh6.js';
5
-
6
- import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
7
- import { dirname as __cjs_dirname } from 'node:path';
8
- import { createRequire as __cjs_createRequire } from 'node:module';
9
-
10
- const __filename = __cjs_fileURLToPath(import.meta.url);
11
- const __dirname = __cjs_dirname(__filename);
12
- const require = __cjs_createRequire(import.meta.url);
13
- const __require = require;
14
- function _mergeNamespaces(n, m) {
15
- for (var i = 0; i < m.length; i++) {
16
- var e = m[i];
17
- if (typeof e !== 'string' && !Array.isArray(e)) { for (var k in e) {
18
- if (k !== 'default' && !(k in n)) {
19
- n[k] = e[k];
20
- }
21
- } }
22
- }
23
- return n;
24
- }
25
-
26
- const startsWithKeywordRegexp = /^(all|not|only|print|screen)/i;
27
-
28
- var joinMedia$1 = function (parentMedia, childMedia) {
29
- if (!parentMedia.length && childMedia.length) return childMedia
30
- if (parentMedia.length && !childMedia.length) return parentMedia
31
- if (!parentMedia.length && !childMedia.length) return []
32
-
33
- const media = [];
34
-
35
- parentMedia.forEach(parentItem => {
36
- const parentItemStartsWithKeyword = startsWithKeywordRegexp.test(parentItem);
37
-
38
- childMedia.forEach(childItem => {
39
- const childItemStartsWithKeyword = startsWithKeywordRegexp.test(childItem);
40
- if (parentItem !== childItem) {
41
- if (childItemStartsWithKeyword && !parentItemStartsWithKeyword) {
42
- media.push(`${childItem} and ${parentItem}`);
43
- } else {
44
- media.push(`${parentItem} and ${childItem}`);
45
- }
46
- }
47
- });
48
- });
49
-
50
- return media
51
- };
52
-
53
- var joinLayer$1 = function (parentLayer, childLayer) {
54
- if (!parentLayer.length && childLayer.length) return childLayer
55
- if (parentLayer.length && !childLayer.length) return parentLayer
56
- if (!parentLayer.length && !childLayer.length) return []
57
-
58
- return parentLayer.concat(childLayer)
59
- };
60
-
61
- var readCache$1 = {exports: {}};
62
-
63
- var pify$2 = {exports: {}};
64
-
65
- var processFn = function (fn, P, opts) {
66
- return function () {
67
- var that = this;
68
- var args = new Array(arguments.length);
69
-
70
- for (var i = 0; i < arguments.length; i++) {
71
- args[i] = arguments[i];
72
- }
73
-
74
- return new P(function (resolve, reject) {
75
- args.push(function (err, result) {
76
- if (err) {
77
- reject(err);
78
- } else if (opts.multiArgs) {
79
- var results = new Array(arguments.length - 1);
80
-
81
- for (var i = 1; i < arguments.length; i++) {
82
- results[i - 1] = arguments[i];
83
- }
84
-
85
- resolve(results);
86
- } else {
87
- resolve(result);
88
- }
89
- });
90
-
91
- fn.apply(that, args);
92
- });
93
- };
94
- };
95
-
96
- var pify$1 = pify$2.exports = function (obj, P, opts) {
97
- if (typeof P !== 'function') {
98
- opts = P;
99
- P = Promise;
100
- }
101
-
102
- opts = opts || {};
103
- opts.exclude = opts.exclude || [/.+Sync$/];
104
-
105
- var filter = function (key) {
106
- var match = function (pattern) {
107
- return typeof pattern === 'string' ? key === pattern : pattern.test(key);
108
- };
109
-
110
- return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
111
- };
112
-
113
- var ret = typeof obj === 'function' ? function () {
114
- if (opts.excludeMain) {
115
- return obj.apply(this, arguments);
116
- }
117
-
118
- return processFn(obj, P, opts).apply(this, arguments);
119
- } : {};
120
-
121
- return Object.keys(obj).reduce(function (ret, key) {
122
- var x = obj[key];
123
-
124
- ret[key] = typeof x === 'function' && filter(key) ? processFn(x, P, opts) : x;
125
-
126
- return ret;
127
- }, ret);
128
- };
129
-
130
- pify$1.all = pify$1;
131
-
132
- var pifyExports = pify$2.exports;
133
-
134
- var fs = require$$0__default;
135
- var path$2 = require$$0;
136
- var pify = pifyExports;
137
-
138
- var stat = pify(fs.stat);
139
- var readFile = pify(fs.readFile);
140
- var resolve = path$2.resolve;
141
-
142
- var cache = Object.create(null);
143
-
144
- function convert(content, encoding) {
145
- if (Buffer.isEncoding(encoding)) {
146
- return content.toString(encoding);
147
- }
148
- return content;
149
- }
150
-
151
- readCache$1.exports = function (path, encoding) {
152
- path = resolve(path);
153
-
154
- return stat(path).then(function (stats) {
155
- var item = cache[path];
156
-
157
- if (item && item.mtime.getTime() === stats.mtime.getTime()) {
158
- return convert(item.content, encoding);
159
- }
160
-
161
- return readFile(path).then(function (data) {
162
- cache[path] = {
163
- mtime: stats.mtime,
164
- content: data
165
- };
166
-
167
- return convert(data, encoding);
168
- });
169
- }).catch(function (err) {
170
- cache[path] = null;
171
- return Promise.reject(err);
172
- });
173
- };
174
-
175
- readCache$1.exports.sync = function (path, encoding) {
176
- path = resolve(path);
177
-
178
- try {
179
- var stats = fs.statSync(path);
180
- var item = cache[path];
181
-
182
- if (item && item.mtime.getTime() === stats.mtime.getTime()) {
183
- return convert(item.content, encoding);
184
- }
185
-
186
- var data = fs.readFileSync(path);
187
-
188
- cache[path] = {
189
- mtime: stats.mtime,
190
- content: data
191
- };
192
-
193
- return convert(data, encoding);
194
- } catch (err) {
195
- cache[path] = null;
196
- throw err;
197
- }
198
-
199
- };
200
-
201
- readCache$1.exports.get = function (path, encoding) {
202
- path = resolve(path);
203
- if (cache[path]) {
204
- return convert(cache[path].content, encoding);
205
- }
206
- return null;
207
- };
208
-
209
- readCache$1.exports.clear = function () {
210
- cache = Object.create(null);
211
- };
212
-
213
- var readCacheExports = readCache$1.exports;
214
-
215
- const dataURLRegexp = /^data:text\/css;base64,/i;
216
-
217
- function isValid(url) {
218
- return dataURLRegexp.test(url)
219
- }
220
-
221
- function contents(url) {
222
- // "data:text/css;base64,".length === 21
223
- return Buffer.from(url.slice(21), "base64").toString()
224
- }
225
-
226
- var dataUrl = {
227
- isValid,
228
- contents,
229
- };
230
-
231
- const readCache = readCacheExports;
232
- const dataURL$1 = dataUrl;
233
-
234
- var loadContent$1 = filename => {
235
- if (dataURL$1.isValid(filename)) {
236
- return dataURL$1.contents(filename)
237
- }
238
-
239
- return readCache(filename, "utf-8")
240
- };
241
-
242
- // builtin tooling
243
- const path$1 = require$$0;
244
-
245
- // placeholder tooling
246
- let sugarss;
247
-
248
- var processContent$1 = function processContent(
249
- result,
250
- content,
251
- filename,
252
- options,
253
- postcss
254
- ) {
255
- const { plugins } = options;
256
- const ext = path$1.extname(filename);
257
-
258
- const parserList = [];
259
-
260
- // SugarSS support:
261
- if (ext === ".sss") {
262
- if (!sugarss) {
263
- try {
264
- sugarss = __require('sugarss');
265
- } catch {} // Ignore
266
- }
267
- if (sugarss)
268
- return runPostcss(postcss, content, filename, plugins, [sugarss])
269
- }
270
-
271
- // Syntax support:
272
- if (result.opts.syntax?.parse) {
273
- parserList.push(result.opts.syntax.parse);
274
- }
275
-
276
- // Parser support:
277
- if (result.opts.parser) parserList.push(result.opts.parser);
278
- // Try the default as a last resort:
279
- parserList.push(null);
280
-
281
- return runPostcss(postcss, content, filename, plugins, parserList)
282
- };
283
-
284
- function runPostcss(postcss, content, filename, plugins, parsers, index) {
285
- if (!index) index = 0;
286
- return postcss(plugins)
287
- .process(content, {
288
- from: filename,
289
- parser: parsers[index],
290
- })
291
- .catch(err => {
292
- // If there's an error, try the next parser
293
- index++;
294
- // If there are no parsers left, throw it
295
- if (index === parsers.length) throw err
296
- return runPostcss(postcss, content, filename, plugins, parsers, index)
297
- })
298
- }
299
-
300
- // external tooling
301
- const valueParser = lib;
302
-
303
- // extended tooling
304
- const { stringify } = valueParser;
305
-
306
- function split(params, start) {
307
- const list = [];
308
- const last = params.reduce((item, node, index) => {
309
- if (index < start) return ""
310
- if (node.type === "div" && node.value === ",") {
311
- list.push(item);
312
- return ""
313
- }
314
- return item + stringify(node)
315
- }, "");
316
- list.push(last);
317
- return list
318
- }
319
-
320
- var parseStatements$1 = function (result, styles) {
321
- const statements = [];
322
- let nodes = [];
323
-
324
- styles.each(node => {
325
- let stmt;
326
- if (node.type === "atrule") {
327
- if (node.name === "import") stmt = parseImport(result, node);
328
- else if (node.name === "media") stmt = parseMedia(result, node);
329
- else if (node.name === "charset") stmt = parseCharset(result, node);
330
- }
331
-
332
- if (stmt) {
333
- if (nodes.length) {
334
- statements.push({
335
- type: "nodes",
336
- nodes,
337
- media: [],
338
- layer: [],
339
- });
340
- nodes = [];
341
- }
342
- statements.push(stmt);
343
- } else nodes.push(node);
344
- });
345
-
346
- if (nodes.length) {
347
- statements.push({
348
- type: "nodes",
349
- nodes,
350
- media: [],
351
- layer: [],
352
- });
353
- }
354
-
355
- return statements
356
- };
357
-
358
- function parseMedia(result, atRule) {
359
- const params = valueParser(atRule.params).nodes;
360
- return {
361
- type: "media",
362
- node: atRule,
363
- media: split(params, 0),
364
- layer: [],
365
- }
366
- }
367
-
368
- function parseCharset(result, atRule) {
369
- if (atRule.prev()) {
370
- return result.warn("@charset must precede all other statements", {
371
- node: atRule,
372
- })
373
- }
374
- return {
375
- type: "charset",
376
- node: atRule,
377
- media: [],
378
- layer: [],
379
- }
380
- }
381
-
382
- function parseImport(result, atRule) {
383
- let prev = atRule.prev();
384
- if (prev) {
385
- do {
386
- if (
387
- prev.type !== "comment" &&
388
- (prev.type !== "atrule" ||
389
- (prev.name !== "import" &&
390
- prev.name !== "charset" &&
391
- !(prev.name === "layer" && !prev.nodes)))
392
- ) {
393
- return result.warn(
394
- "@import must precede all other statements (besides @charset or empty @layer)",
395
- { node: atRule }
396
- )
397
- }
398
- prev = prev.prev();
399
- } while (prev)
400
- }
401
-
402
- if (atRule.nodes) {
403
- return result.warn(
404
- "It looks like you didn't end your @import statement correctly. " +
405
- "Child nodes are attached to it.",
406
- { node: atRule }
407
- )
408
- }
409
-
410
- const params = valueParser(atRule.params).nodes;
411
- const stmt = {
412
- type: "import",
413
- node: atRule,
414
- media: [],
415
- layer: [],
416
- };
417
-
418
- // prettier-ignore
419
- if (
420
- !params.length ||
421
- (
422
- params[0].type !== "string" ||
423
- !params[0].value
424
- ) &&
425
- (
426
- params[0].type !== "function" ||
427
- params[0].value !== "url" ||
428
- !params[0].nodes.length ||
429
- !params[0].nodes[0].value
430
- )
431
- ) {
432
- return result.warn(`Unable to find uri in '${ atRule.toString() }'`, {
433
- node: atRule,
434
- })
435
- }
436
-
437
- if (params[0].type === "string") stmt.uri = params[0].value;
438
- else stmt.uri = params[0].nodes[0].value;
439
- stmt.fullUri = stringify(params[0]);
440
-
441
- let remainder = params;
442
- if (remainder.length > 2) {
443
- if (
444
- (remainder[2].type === "word" || remainder[2].type === "function") &&
445
- remainder[2].value === "layer"
446
- ) {
447
- if (remainder[1].type !== "space") {
448
- return result.warn("Invalid import layer statement", { node: atRule })
449
- }
450
-
451
- if (remainder[2].nodes) {
452
- stmt.layer = [stringify(remainder[2].nodes)];
453
- } else {
454
- stmt.layer = [""];
455
- }
456
- remainder = remainder.slice(2);
457
- }
458
- }
459
-
460
- if (remainder.length > 2) {
461
- if (remainder[1].type !== "space") {
462
- return result.warn("Invalid import media statement", { node: atRule })
463
- }
464
-
465
- stmt.media = split(remainder, 2);
466
- }
467
-
468
- return stmt
469
- }
470
-
471
- var assignLayerNames$1 = function (layer, node, state, options) {
472
- layer.forEach((layerPart, i) => {
473
- if (layerPart.trim() === "") {
474
- if (options.nameLayer) {
475
- layer[i] = options
476
- .nameLayer(state.anonymousLayerCounter++, state.rootFilename)
477
- .toString();
478
- } else {
479
- throw node.error(
480
- `When using anonymous layers in @import you must also set the "nameLayer" plugin option`
481
- )
482
- }
483
- }
484
- });
485
- };
486
-
487
- // builtin tooling
488
- const path = require$$0;
489
-
490
- // internal tooling
491
- const joinMedia = joinMedia$1;
492
- const joinLayer = joinLayer$1;
493
- const resolveId = (id) => id;
494
- const loadContent = loadContent$1;
495
- const processContent = processContent$1;
496
- const parseStatements = parseStatements$1;
497
- const assignLayerNames = assignLayerNames$1;
498
- const dataURL = dataUrl;
499
-
500
- function AtImport(options) {
501
- options = {
502
- root: process.cwd(),
503
- path: [],
504
- skipDuplicates: true,
505
- resolve: resolveId,
506
- load: loadContent,
507
- plugins: [],
508
- addModulesDirectories: [],
509
- nameLayer: null,
510
- ...options,
511
- };
512
-
513
- options.root = path.resolve(options.root);
514
-
515
- // convert string to an array of a single element
516
- if (typeof options.path === "string") options.path = [options.path];
517
-
518
- if (!Array.isArray(options.path)) options.path = [];
519
-
520
- options.path = options.path.map(p => path.resolve(options.root, p));
521
-
522
- return {
523
- postcssPlugin: "postcss-import",
524
- Once(styles, { result, atRule, postcss }) {
525
- const state = {
526
- importedFiles: {},
527
- hashFiles: {},
528
- rootFilename: null,
529
- anonymousLayerCounter: 0,
530
- };
531
-
532
- if (styles.source?.input?.file) {
533
- state.rootFilename = styles.source.input.file;
534
- state.importedFiles[styles.source.input.file] = {};
535
- }
536
-
537
- if (options.plugins && !Array.isArray(options.plugins)) {
538
- throw new Error("plugins option must be an array")
539
- }
540
-
541
- if (options.nameLayer && typeof options.nameLayer !== "function") {
542
- throw new Error("nameLayer option must be a function")
543
- }
544
-
545
- return parseStyles(result, styles, options, state, [], []).then(
546
- bundle => {
547
- applyRaws(bundle);
548
- applyMedia(bundle);
549
- applyStyles(bundle, styles);
550
- }
551
- )
552
-
553
- function applyRaws(bundle) {
554
- bundle.forEach((stmt, index) => {
555
- if (index === 0) return
556
-
557
- if (stmt.parent) {
558
- const { before } = stmt.parent.node.raws;
559
- if (stmt.type === "nodes") stmt.nodes[0].raws.before = before;
560
- else stmt.node.raws.before = before;
561
- } else if (stmt.type === "nodes") {
562
- stmt.nodes[0].raws.before = stmt.nodes[0].raws.before || "\n";
563
- }
564
- });
565
- }
566
-
567
- function applyMedia(bundle) {
568
- bundle.forEach(stmt => {
569
- if (
570
- (!stmt.media.length && !stmt.layer.length) ||
571
- stmt.type === "charset"
572
- ) {
573
- return
574
- }
575
-
576
- if (stmt.layer.length > 1) {
577
- assignLayerNames(stmt.layer, stmt.node, state, options);
578
- }
579
-
580
- if (stmt.type === "import") {
581
- const parts = [stmt.fullUri];
582
-
583
- const media = stmt.media.join(", ");
584
-
585
- if (stmt.layer.length) {
586
- const layerName = stmt.layer.join(".");
587
-
588
- let layerParams = "layer";
589
- if (layerName) {
590
- layerParams = `layer(${layerName})`;
591
- }
592
-
593
- parts.push(layerParams);
594
- }
595
-
596
- if (media) {
597
- parts.push(media);
598
- }
599
-
600
- stmt.node.params = parts.join(" ");
601
- } else if (stmt.type === "media") {
602
- if (stmt.layer.length) {
603
- const layerNode = atRule({
604
- name: "layer",
605
- params: stmt.layer.join("."),
606
- source: stmt.node.source,
607
- });
608
-
609
- if (stmt.parentMedia?.length) {
610
- const mediaNode = atRule({
611
- name: "media",
612
- params: stmt.parentMedia.join(", "),
613
- source: stmt.node.source,
614
- });
615
-
616
- mediaNode.append(layerNode);
617
- layerNode.append(stmt.node);
618
- stmt.node = mediaNode;
619
- } else {
620
- layerNode.append(stmt.node);
621
- stmt.node = layerNode;
622
- }
623
- } else {
624
- stmt.node.params = stmt.media.join(", ");
625
- }
626
- } else {
627
- const { nodes } = stmt;
628
- const { parent } = nodes[0];
629
-
630
- let outerAtRule;
631
- let innerAtRule;
632
- if (stmt.media.length && stmt.layer.length) {
633
- const mediaNode = atRule({
634
- name: "media",
635
- params: stmt.media.join(", "),
636
- source: parent.source,
637
- });
638
-
639
- const layerNode = atRule({
640
- name: "layer",
641
- params: stmt.layer.join("."),
642
- source: parent.source,
643
- });
644
-
645
- mediaNode.append(layerNode);
646
- innerAtRule = layerNode;
647
- outerAtRule = mediaNode;
648
- } else if (stmt.media.length) {
649
- const mediaNode = atRule({
650
- name: "media",
651
- params: stmt.media.join(", "),
652
- source: parent.source,
653
- });
654
-
655
- innerAtRule = mediaNode;
656
- outerAtRule = mediaNode;
657
- } else if (stmt.layer.length) {
658
- const layerNode = atRule({
659
- name: "layer",
660
- params: stmt.layer.join("."),
661
- source: parent.source,
662
- });
663
-
664
- innerAtRule = layerNode;
665
- outerAtRule = layerNode;
666
- }
667
-
668
- parent.insertBefore(nodes[0], outerAtRule);
669
-
670
- // remove nodes
671
- nodes.forEach(node => {
672
- node.parent = undefined;
673
- });
674
-
675
- // better output
676
- nodes[0].raws.before = nodes[0].raws.before || "\n";
677
-
678
- // wrap new rules with media query and/or layer at rule
679
- innerAtRule.append(nodes);
680
-
681
- stmt.type = "media";
682
- stmt.node = outerAtRule;
683
- delete stmt.nodes;
684
- }
685
- });
686
- }
687
-
688
- function applyStyles(bundle, styles) {
689
- styles.nodes = [];
690
-
691
- // Strip additional statements.
692
- bundle.forEach(stmt => {
693
- if (["charset", "import", "media"].includes(stmt.type)) {
694
- stmt.node.parent = undefined;
695
- styles.append(stmt.node);
696
- } else if (stmt.type === "nodes") {
697
- stmt.nodes.forEach(node => {
698
- node.parent = undefined;
699
- styles.append(node);
700
- });
701
- }
702
- });
703
- }
704
-
705
- function parseStyles(result, styles, options, state, media, layer) {
706
- const statements = parseStatements(result, styles);
707
-
708
- return Promise.resolve(statements)
709
- .then(stmts => {
710
- // process each statement in series
711
- return stmts.reduce((promise, stmt) => {
712
- return promise.then(() => {
713
- stmt.media = joinMedia(media, stmt.media || []);
714
- stmt.parentMedia = media;
715
- stmt.layer = joinLayer(layer, stmt.layer || []);
716
-
717
- // skip protocol base uri (protocol://url) or protocol-relative
718
- if (
719
- stmt.type !== "import" ||
720
- /^(?:[a-z]+:)?\/\//i.test(stmt.uri)
721
- ) {
722
- return
723
- }
724
-
725
- if (options.filter && !options.filter(stmt.uri)) {
726
- // rejected by filter
727
- return
728
- }
729
-
730
- return resolveImportId(result, stmt, options, state)
731
- })
732
- }, Promise.resolve())
733
- })
734
- .then(() => {
735
- let charset;
736
- const imports = [];
737
- const bundle = [];
738
-
739
- function handleCharset(stmt) {
740
- if (!charset) charset = stmt;
741
- // charsets aren't case-sensitive, so convert to lower case to compare
742
- else if (
743
- stmt.node.params.toLowerCase() !==
744
- charset.node.params.toLowerCase()
745
- ) {
746
- throw new Error(
747
- `Incompatable @charset statements:
748
- ${stmt.node.params} specified in ${stmt.node.source.input.file}
749
- ${charset.node.params} specified in ${charset.node.source.input.file}`
750
- )
751
- }
752
- }
753
-
754
- // squash statements and their children
755
- statements.forEach(stmt => {
756
- if (stmt.type === "charset") handleCharset(stmt);
757
- else if (stmt.type === "import") {
758
- if (stmt.children) {
759
- stmt.children.forEach((child, index) => {
760
- if (child.type === "import") imports.push(child);
761
- else if (child.type === "charset") handleCharset(child);
762
- else bundle.push(child);
763
- // For better output
764
- if (index === 0) child.parent = stmt;
765
- });
766
- } else imports.push(stmt);
767
- } else if (stmt.type === "media" || stmt.type === "nodes") {
768
- bundle.push(stmt);
769
- }
770
- });
771
-
772
- return charset
773
- ? [charset, ...imports.concat(bundle)]
774
- : imports.concat(bundle)
775
- })
776
- }
777
-
778
- function resolveImportId(result, stmt, options, state) {
779
- if (dataURL.isValid(stmt.uri)) {
780
- return loadImportContent(result, stmt, stmt.uri, options, state).then(
781
- result => {
782
- stmt.children = result;
783
- }
784
- )
785
- }
786
-
787
- const atRule = stmt.node;
788
- let sourceFile;
789
- if (atRule.source?.input?.file) {
790
- sourceFile = atRule.source.input.file;
791
- }
792
- const base = sourceFile
793
- ? path.dirname(atRule.source.input.file)
794
- : options.root;
795
-
796
- return Promise.resolve(options.resolve(stmt.uri, base, options))
797
- .then(paths => {
798
- if (!Array.isArray(paths)) paths = [paths];
799
- // Ensure that each path is absolute:
800
- return Promise.all(
801
- paths.map(file => {
802
- return !path.isAbsolute(file)
803
- ? resolveId(file)
804
- : file
805
- })
806
- )
807
- })
808
- .then(resolved => {
809
- // Add dependency messages:
810
- resolved.forEach(file => {
811
- result.messages.push({
812
- type: "dependency",
813
- plugin: "postcss-import",
814
- file,
815
- parent: sourceFile,
816
- });
817
- });
818
-
819
- return Promise.all(
820
- resolved.map(file => {
821
- return loadImportContent(result, stmt, file, options, state)
822
- })
823
- )
824
- })
825
- .then(result => {
826
- // Merge loaded statements
827
- stmt.children = result.reduce((result, statements) => {
828
- return statements ? result.concat(statements) : result
829
- }, []);
830
- })
831
- }
832
-
833
- function loadImportContent(result, stmt, filename, options, state) {
834
- const atRule = stmt.node;
835
- const { media, layer } = stmt;
836
-
837
- assignLayerNames(layer, atRule, state, options);
838
-
839
- if (options.skipDuplicates) {
840
- // skip files already imported at the same scope
841
- if (state.importedFiles[filename]?.[media]?.[layer]) {
842
- return
843
- }
844
-
845
- // save imported files to skip them next time
846
- if (!state.importedFiles[filename]) {
847
- state.importedFiles[filename] = {};
848
- }
849
- if (!state.importedFiles[filename][media]) {
850
- state.importedFiles[filename][media] = {};
851
- }
852
- state.importedFiles[filename][media][layer] = true;
853
- }
854
-
855
- return Promise.resolve(options.load(filename, options)).then(
856
- content => {
857
- if (content.trim() === "") {
858
- result.warn(`${filename} is empty`, { node: atRule });
859
- return
860
- }
861
-
862
- // skip previous imported files not containing @import rules
863
- if (state.hashFiles[content]?.[media]?.[layer]) {
864
- return
865
- }
866
-
867
- return processContent(
868
- result,
869
- content,
870
- filename,
871
- options,
872
- postcss
873
- ).then(importedResult => {
874
- const styles = importedResult.root;
875
- result.messages = result.messages.concat(importedResult.messages);
876
-
877
- if (options.skipDuplicates) {
878
- const hasImport = styles.some(child => {
879
- return child.type === "atrule" && child.name === "import"
880
- });
881
- if (!hasImport) {
882
- // save hash files to skip them next time
883
- if (!state.hashFiles[content]) {
884
- state.hashFiles[content] = {};
885
- }
886
- if (!state.hashFiles[content][media]) {
887
- state.hashFiles[content][media] = {};
888
- }
889
- state.hashFiles[content][media][layer] = true;
890
- }
891
- }
892
-
893
- // recursion: import @import from imported file
894
- return parseStyles(result, styles, options, state, media, layer)
895
- })
896
- }
897
- )
898
- }
899
- },
900
- }
901
- }
902
-
903
- AtImport.postcss = true;
904
-
905
- var postcssImport = AtImport;
906
-
907
- var index = /*@__PURE__*/getDefaultExportFromCjs(postcssImport);
908
-
909
- var index$1 = /*#__PURE__*/_mergeNamespaces({
910
- __proto__: null,
911
- default: index
912
- }, [postcssImport]);
913
-
914
- export { index$1 as i };