vite 6.0.0-beta.9 → 6.0.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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

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