@plumeria/webpack-plugin 6.0.0 → 6.0.2
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.
- package/dist/index.js +35 -35
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -14,22 +14,30 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
14
14
|
fs_1.default.writeFileSync(VIRTUAL_FILE_PATH, '/** Placeholder file */', 'utf-8');
|
|
15
15
|
}
|
|
16
16
|
function loader(source) {
|
|
17
|
-
const loaderContext = this;
|
|
18
17
|
const callback = this.async();
|
|
19
18
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
20
19
|
if (this.resourcePath.includes('node_modules') ||
|
|
21
20
|
!source.includes('@plumeria/core')) {
|
|
22
21
|
return callback(null, source);
|
|
23
22
|
}
|
|
23
|
+
const fileStyles = {};
|
|
24
24
|
this.clearDependencies();
|
|
25
25
|
this.addDependency(this.resourcePath);
|
|
26
|
-
const scannedTables = (0, utils_1.scanAll)();
|
|
27
|
-
const fileStyles = {};
|
|
28
26
|
const ast = (0, core_1.parseSync)(source, {
|
|
29
27
|
syntax: 'typescript',
|
|
30
28
|
tsx: true,
|
|
31
29
|
target: 'es2022',
|
|
32
30
|
});
|
|
31
|
+
for (const node of ast.body) {
|
|
32
|
+
if (node.type === 'ImportDeclaration') {
|
|
33
|
+
const sourcePath = node.source.value;
|
|
34
|
+
const actualPath = (0, utils_1.resolveImportPath)(sourcePath, this.resourcePath);
|
|
35
|
+
if (actualPath) {
|
|
36
|
+
this.addDependency(actualPath);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const scannedTables = (0, utils_1.scanAll)();
|
|
33
41
|
const localConsts = (0, utils_1.collectLocalConsts)(ast);
|
|
34
42
|
const resourcePath = this.resourcePath;
|
|
35
43
|
const importMap = {};
|
|
@@ -38,7 +46,6 @@ function loader(source) {
|
|
|
38
46
|
const sourcePath = node.source.value;
|
|
39
47
|
const actualPath = (0, utils_1.resolveImportPath)(sourcePath, resourcePath);
|
|
40
48
|
if (actualPath) {
|
|
41
|
-
loaderContext.addDependency(actualPath);
|
|
42
49
|
node.specifiers.forEach((specifier) => {
|
|
43
50
|
if (specifier.type === 'ImportSpecifier') {
|
|
44
51
|
const importedName = specifier.imported
|
|
@@ -119,6 +126,11 @@ function loader(source) {
|
|
|
119
126
|
const localCreateStyles = {};
|
|
120
127
|
const replacements = [];
|
|
121
128
|
const extractedSheets = [];
|
|
129
|
+
const addSheet = (sheet) => {
|
|
130
|
+
if (!extractedSheets.includes(sheet)) {
|
|
131
|
+
extractedSheets.push(sheet);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
122
134
|
const processedDecls = new Set();
|
|
123
135
|
const idSpans = new Set();
|
|
124
136
|
const excludedSpans = new Set();
|
|
@@ -153,7 +165,7 @@ function loader(source) {
|
|
|
153
165
|
if (!isProduction) {
|
|
154
166
|
(0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
|
|
155
167
|
records.forEach((r) => {
|
|
156
|
-
|
|
168
|
+
addSheet(r.sheet);
|
|
157
169
|
});
|
|
158
170
|
}
|
|
159
171
|
const atomMap = {};
|
|
@@ -314,7 +326,7 @@ function loader(source) {
|
|
|
314
326
|
const records = (0, utils_1.getStyleRecords)(key, style, 2);
|
|
315
327
|
if (!isProduction) {
|
|
316
328
|
(0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
|
|
317
|
-
records.forEach((r) =>
|
|
329
|
+
records.forEach((r) => addSheet(r.sheet));
|
|
318
330
|
}
|
|
319
331
|
}
|
|
320
332
|
});
|
|
@@ -348,7 +360,7 @@ function loader(source) {
|
|
|
348
360
|
const records = (0, utils_1.getStyleRecords)(propName, style, 2);
|
|
349
361
|
if (!isProduction) {
|
|
350
362
|
(0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
|
|
351
|
-
records.forEach((r) =>
|
|
363
|
+
records.forEach((r) => addSheet(r.sheet));
|
|
352
364
|
}
|
|
353
365
|
const atomMap = {};
|
|
354
366
|
records.forEach((r) => (atomMap[r.key] = r.hash));
|
|
@@ -561,7 +573,7 @@ function loader(source) {
|
|
|
561
573
|
const hash = (0, zss_engine_1.genBase36Hash)(baseStyle, 1, 8);
|
|
562
574
|
const records = (0, utils_1.getStyleRecords)(hash, baseStyle, 2);
|
|
563
575
|
if (!isProduction) {
|
|
564
|
-
records.forEach((r) =>
|
|
576
|
+
records.forEach((r) => addSheet(r.sheet));
|
|
565
577
|
}
|
|
566
578
|
const className = records.map((r) => r.hash).join(' ');
|
|
567
579
|
replacements.push({
|
|
@@ -574,22 +586,10 @@ function loader(source) {
|
|
|
574
586
|
const table = {};
|
|
575
587
|
const combinations = 1 << conditionals.length;
|
|
576
588
|
for (let i = 0; i < combinations; i++) {
|
|
577
|
-
|
|
589
|
+
let currentStyle = { ...baseStyle };
|
|
578
590
|
const seenGroups = new Set();
|
|
579
591
|
let impossible = false;
|
|
580
|
-
if (Object.keys(baseStyle).length > 0) {
|
|
581
|
-
if (!isProduction) {
|
|
582
|
-
(0, utils_1.extractOndemandStyles)(baseStyle, extractedSheets, scannedTables);
|
|
583
|
-
}
|
|
584
|
-
const hash = (0, zss_engine_1.genBase36Hash)(baseStyle, 1, 8);
|
|
585
|
-
const records = (0, utils_1.getStyleRecords)(hash, baseStyle, 2);
|
|
586
|
-
if (!isProduction) {
|
|
587
|
-
records.forEach((r) => extractedSheets.push(r.sheet));
|
|
588
|
-
}
|
|
589
|
-
currentClassNames.push(...records.map((r) => r.hash));
|
|
590
|
-
}
|
|
591
592
|
for (let j = 0; j < conditionals.length; j++) {
|
|
592
|
-
let targetStyle = {};
|
|
593
593
|
if ((i >> j) & 1) {
|
|
594
594
|
if (conditionals[j].groupId !== undefined) {
|
|
595
595
|
if (seenGroups.has(conditionals[j].groupId)) {
|
|
@@ -598,28 +598,28 @@ function loader(source) {
|
|
|
598
598
|
}
|
|
599
599
|
seenGroups.add(conditionals[j].groupId);
|
|
600
600
|
}
|
|
601
|
-
|
|
601
|
+
currentStyle = (0, utils_1.deepMerge)(currentStyle, conditionals[j].truthy);
|
|
602
602
|
}
|
|
603
603
|
else {
|
|
604
|
-
|
|
605
|
-
}
|
|
606
|
-
if (Object.keys(targetStyle).length > 0) {
|
|
607
|
-
if (!isProduction) {
|
|
608
|
-
(0, utils_1.extractOndemandStyles)(targetStyle, extractedSheets, scannedTables);
|
|
609
|
-
}
|
|
610
|
-
const hash = (0, zss_engine_1.genBase36Hash)(targetStyle, 1, 8);
|
|
611
|
-
const records = (0, utils_1.getStyleRecords)(hash, targetStyle, 2);
|
|
612
|
-
if (!isProduction) {
|
|
613
|
-
records.forEach((r) => extractedSheets.push(r.sheet));
|
|
614
|
-
}
|
|
615
|
-
currentClassNames.push(...records.map((r) => r.hash));
|
|
604
|
+
currentStyle = (0, utils_1.deepMerge)(currentStyle, conditionals[j].falsy);
|
|
616
605
|
}
|
|
617
606
|
}
|
|
618
607
|
if (impossible) {
|
|
619
608
|
table[i] = '';
|
|
620
609
|
continue;
|
|
621
610
|
}
|
|
622
|
-
|
|
611
|
+
if (!isProduction) {
|
|
612
|
+
(0, utils_1.extractOndemandStyles)(currentStyle, extractedSheets, scannedTables);
|
|
613
|
+
}
|
|
614
|
+
const hash = (0, zss_engine_1.genBase36Hash)(currentStyle, 1, 8);
|
|
615
|
+
const records = (0, utils_1.getStyleRecords)(hash, currentStyle, 2);
|
|
616
|
+
if (!isProduction) {
|
|
617
|
+
records.forEach((r) => extractedSheets.push(r.sheet));
|
|
618
|
+
}
|
|
619
|
+
const className = records
|
|
620
|
+
.map((r) => r.hash)
|
|
621
|
+
.join(' ');
|
|
622
|
+
table[i] = className;
|
|
623
623
|
}
|
|
624
624
|
let indexExpr = '';
|
|
625
625
|
if (conditionals.length === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/webpack-plugin",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2",
|
|
4
4
|
"description": "Plumeria Webpack plugin",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"zero-virtual.css"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@plumeria/utils": "^6.0.
|
|
25
|
+
"@plumeria/utils": "^6.0.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@swc/core": "1.15.8",
|