@plumeria/webpack-plugin 6.2.1 → 6.3.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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +117 -101
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { LoaderContext } from 'webpack';
|
|
2
|
-
export default function loader(this: LoaderContext<unknown>, source: string): void
|
|
2
|
+
export default function loader(this: LoaderContext<unknown>, source: string): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -5,15 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = loader;
|
|
7
7
|
const core_1 = require("@swc/core");
|
|
8
|
-
const fs_1 =
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const zss_engine_1 = require("zss-engine");
|
|
11
11
|
const utils_1 = require("@plumeria/utils");
|
|
12
12
|
const VIRTUAL_FILE_PATH = path_1.default.resolve(__dirname, '..', 'zero-virtual.css');
|
|
13
13
|
if (process.env.NODE_ENV === 'production') {
|
|
14
|
-
fs_1.
|
|
14
|
+
(0, fs_1.writeFileSync)(VIRTUAL_FILE_PATH, '/** Placeholder file */\n', 'utf-8');
|
|
15
15
|
}
|
|
16
|
-
function loader(source) {
|
|
16
|
+
async function loader(source) {
|
|
17
17
|
const callback = this.async();
|
|
18
18
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
19
19
|
if (this.resourcePath.includes('node_modules') ||
|
|
@@ -41,6 +41,8 @@ function loader(source) {
|
|
|
41
41
|
const localConsts = (0, utils_1.collectLocalConsts)(ast);
|
|
42
42
|
const resourcePath = this.resourcePath;
|
|
43
43
|
const importMap = {};
|
|
44
|
+
const createThemeImportMap = {};
|
|
45
|
+
const createStaticImportMap = {};
|
|
44
46
|
const plumeriaAliases = {};
|
|
45
47
|
(0, utils_1.traverse)(ast, {
|
|
46
48
|
ImportDeclaration({ node }) {
|
|
@@ -88,11 +90,11 @@ function loader(source) {
|
|
|
88
90
|
importMap[localName] = scannedTables.variantsHashTable[uniqueKey];
|
|
89
91
|
}
|
|
90
92
|
if (scannedTables.createThemeHashTable[uniqueKey]) {
|
|
91
|
-
|
|
93
|
+
createThemeImportMap[localName] =
|
|
92
94
|
scannedTables.createThemeHashTable[uniqueKey];
|
|
93
95
|
}
|
|
94
96
|
if (scannedTables.createStaticHashTable[uniqueKey]) {
|
|
95
|
-
|
|
97
|
+
createStaticImportMap[localName] =
|
|
96
98
|
scannedTables.createStaticHashTable[uniqueKey];
|
|
97
99
|
}
|
|
98
100
|
}
|
|
@@ -124,20 +126,6 @@ function loader(source) {
|
|
|
124
126
|
for (const key of Object.keys(importMap)) {
|
|
125
127
|
mergedViewTransitionTable[key] = importMap[key];
|
|
126
128
|
}
|
|
127
|
-
const mergedCreateThemeHashTable = {};
|
|
128
|
-
for (const key of Object.keys(scannedTables.createThemeHashTable)) {
|
|
129
|
-
mergedCreateThemeHashTable[key] = scannedTables.createThemeHashTable[key];
|
|
130
|
-
}
|
|
131
|
-
for (const key of Object.keys(importMap)) {
|
|
132
|
-
mergedCreateThemeHashTable[key] = importMap[key];
|
|
133
|
-
}
|
|
134
|
-
const mergedCreateStaticHashTable = {};
|
|
135
|
-
for (const key of Object.keys(scannedTables.createStaticHashTable)) {
|
|
136
|
-
mergedCreateStaticHashTable[key] = scannedTables.createStaticHashTable[key];
|
|
137
|
-
}
|
|
138
|
-
for (const key of Object.keys(importMap)) {
|
|
139
|
-
mergedCreateStaticHashTable[key] = importMap[key];
|
|
140
|
-
}
|
|
141
129
|
const mergedCreateTable = {};
|
|
142
130
|
for (const key of Object.keys(scannedTables.createHashTable)) {
|
|
143
131
|
mergedCreateTable[key] = scannedTables.createHashTable[key];
|
|
@@ -152,6 +140,30 @@ function loader(source) {
|
|
|
152
140
|
for (const key of Object.keys(importMap)) {
|
|
153
141
|
mergedVariantsTable[key] = importMap[key];
|
|
154
142
|
}
|
|
143
|
+
const mergedCreateThemeHashTable = {};
|
|
144
|
+
for (const key of Object.keys(scannedTables.createThemeHashTable)) {
|
|
145
|
+
mergedCreateThemeHashTable[key] = scannedTables.createThemeHashTable[key];
|
|
146
|
+
if (key.startsWith(`${resourcePath}-`)) {
|
|
147
|
+
const varName = key.slice(resourcePath.length + 1);
|
|
148
|
+
mergedCreateThemeHashTable[varName] =
|
|
149
|
+
scannedTables.createThemeHashTable[key];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
for (const key of Object.keys(createThemeImportMap)) {
|
|
153
|
+
mergedCreateThemeHashTable[key] = createThemeImportMap[key];
|
|
154
|
+
}
|
|
155
|
+
const mergedCreateStaticHashTable = {};
|
|
156
|
+
for (const key of Object.keys(scannedTables.createStaticHashTable)) {
|
|
157
|
+
mergedCreateStaticHashTable[key] = scannedTables.createStaticHashTable[key];
|
|
158
|
+
if (key.startsWith(`${resourcePath}-`)) {
|
|
159
|
+
const varName = key.slice(resourcePath.length + 1);
|
|
160
|
+
mergedCreateStaticHashTable[varName] =
|
|
161
|
+
scannedTables.createStaticHashTable[key];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
for (const key of Object.keys(createStaticImportMap)) {
|
|
165
|
+
mergedCreateStaticHashTable[key] = createStaticImportMap[key];
|
|
166
|
+
}
|
|
155
167
|
const localCreateStyles = {};
|
|
156
168
|
const replacements = [];
|
|
157
169
|
const extractedSheets = [];
|
|
@@ -210,7 +222,7 @@ function loader(source) {
|
|
|
210
222
|
if (obj) {
|
|
211
223
|
const hashMap = {};
|
|
212
224
|
Object.entries(obj).forEach(([key, style]) => {
|
|
213
|
-
const records = (0, utils_1.getStyleRecords)(key, style
|
|
225
|
+
const records = (0, utils_1.getStyleRecords)(key, style);
|
|
214
226
|
if (!isProduction) {
|
|
215
227
|
(0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
|
|
216
228
|
records.forEach((r) => {
|
|
@@ -241,27 +253,11 @@ function loader(source) {
|
|
|
241
253
|
};
|
|
242
254
|
}
|
|
243
255
|
}
|
|
244
|
-
else if ((propName === 'createTheme' || propName === 'createStatic') &&
|
|
245
|
-
(utils_1.t.isObjectExpression(node.init.arguments[0].expression) ||
|
|
246
|
-
utils_1.t.isStringLiteral(node.init.arguments[0].expression))) {
|
|
247
|
-
localCreateStyles[node.id.value] = {
|
|
248
|
-
name: node.id.value,
|
|
249
|
-
type: 'constant',
|
|
250
|
-
obj: {},
|
|
251
|
-
hashMap: {},
|
|
252
|
-
isExported,
|
|
253
|
-
initSpan: {
|
|
254
|
-
start: node.init.span.start - ast.span.start,
|
|
255
|
-
end: node.init.span.end - ast.span.start,
|
|
256
|
-
},
|
|
257
|
-
declSpan: {
|
|
258
|
-
start: declSpan.start - ast.span.start,
|
|
259
|
-
end: declSpan.end - ast.span.start,
|
|
260
|
-
},
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
256
|
else if (propName === 'variants' &&
|
|
264
257
|
utils_1.t.isObjectExpression(node.init.arguments[0].expression)) {
|
|
258
|
+
if (utils_1.t.isIdentifier(node.id)) {
|
|
259
|
+
idSpans.add(node.id.span.start);
|
|
260
|
+
}
|
|
265
261
|
const obj = (0, utils_1.objectExpressionToObject)(node.init.arguments[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable, (name) => {
|
|
266
262
|
if (localCreateStyles[name]) {
|
|
267
263
|
return localCreateStyles[name].obj;
|
|
@@ -290,6 +286,32 @@ function loader(source) {
|
|
|
290
286
|
},
|
|
291
287
|
};
|
|
292
288
|
}
|
|
289
|
+
else if (propName === 'createTheme' &&
|
|
290
|
+
utils_1.t.isObjectExpression(node.init.arguments[0].expression)) {
|
|
291
|
+
if (utils_1.t.isIdentifier(node.id)) {
|
|
292
|
+
idSpans.add(node.id.span.start);
|
|
293
|
+
}
|
|
294
|
+
const obj = (0, utils_1.objectExpressionToObject)(node.init.arguments[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
|
|
295
|
+
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
296
|
+
const uniqueKey = `${resourcePath}-${node.id.value}`;
|
|
297
|
+
scannedTables.createThemeHashTable[uniqueKey] = hash;
|
|
298
|
+
scannedTables.createThemeObjectTable[hash] = obj;
|
|
299
|
+
localCreateStyles[node.id.value] = {
|
|
300
|
+
name: node.id.value,
|
|
301
|
+
type: 'constant',
|
|
302
|
+
obj,
|
|
303
|
+
hashMap: scannedTables.createAtomicMapTable[hash],
|
|
304
|
+
isExported,
|
|
305
|
+
initSpan: {
|
|
306
|
+
start: node.init.span.start - ast.span.start,
|
|
307
|
+
end: node.init.span.end - ast.span.start,
|
|
308
|
+
},
|
|
309
|
+
declSpan: {
|
|
310
|
+
start: declSpan.start - ast.span.start,
|
|
311
|
+
end: declSpan.end - ast.span.start,
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
}
|
|
293
315
|
}
|
|
294
316
|
};
|
|
295
317
|
(0, utils_1.traverse)(ast, {
|
|
@@ -350,6 +372,9 @@ function loader(source) {
|
|
|
350
372
|
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
|
|
351
373
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
352
374
|
scannedTables.keyframesObjectTable[hash] = obj;
|
|
375
|
+
if (!isProduction) {
|
|
376
|
+
(0, utils_1.extractOndemandStyles)({ kf: `kf-${hash}` }, extractedSheets, scannedTables);
|
|
377
|
+
}
|
|
353
378
|
replacements.push({
|
|
354
379
|
start: node.span.start - ast.span.start,
|
|
355
380
|
end: node.span.end - ast.span.start,
|
|
@@ -363,7 +388,6 @@ function loader(source) {
|
|
|
363
388
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
364
389
|
scannedTables.viewTransitionObjectTable[hash] = obj;
|
|
365
390
|
if (!isProduction) {
|
|
366
|
-
(0, utils_1.extractOndemandStyles)(obj, extractedSheets, scannedTables);
|
|
367
391
|
(0, utils_1.extractOndemandStyles)({ vt: `vt-${hash}` }, extractedSheets, scannedTables);
|
|
368
392
|
}
|
|
369
393
|
replacements.push({
|
|
@@ -372,12 +396,23 @@ function loader(source) {
|
|
|
372
396
|
content: JSON.stringify(`vt-${hash}`),
|
|
373
397
|
});
|
|
374
398
|
}
|
|
375
|
-
else if (propName === 'createTheme' &&
|
|
399
|
+
else if ((propName === 'createTheme' || propName === 'createStatic') &&
|
|
376
400
|
args.length > 0 &&
|
|
377
401
|
utils_1.t.isObjectExpression(args[0].expression)) {
|
|
378
402
|
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
|
|
379
403
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
380
|
-
|
|
404
|
+
if (propName === 'createTheme') {
|
|
405
|
+
scannedTables.createThemeObjectTable[hash] = obj;
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
scannedTables.createStaticObjectTable[hash] = obj;
|
|
409
|
+
}
|
|
410
|
+
const prefix = propName === 'createTheme' ? 'tm-' : 'st-';
|
|
411
|
+
replacements.push({
|
|
412
|
+
start: node.span.start - ast.span.start,
|
|
413
|
+
end: node.span.end - ast.span.start,
|
|
414
|
+
content: JSON.stringify(`${prefix}${hash}`),
|
|
415
|
+
});
|
|
381
416
|
}
|
|
382
417
|
else if (propName === 'create' &&
|
|
383
418
|
args.length > 0 &&
|
|
@@ -387,7 +422,7 @@ function loader(source) {
|
|
|
387
422
|
scannedTables.createObjectTable[hash] = obj;
|
|
388
423
|
Object.entries(obj).forEach(([key, style]) => {
|
|
389
424
|
if (typeof style === 'object' && style !== null) {
|
|
390
|
-
const records = (0, utils_1.getStyleRecords)(key, style
|
|
425
|
+
const records = (0, utils_1.getStyleRecords)(key, style);
|
|
391
426
|
if (!isProduction) {
|
|
392
427
|
(0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
|
|
393
428
|
records.forEach((r) => addSheet(r.sheet));
|
|
@@ -403,7 +438,7 @@ function loader(source) {
|
|
|
403
438
|
if (utils_1.t.isIdentifier(node.object) && utils_1.t.isIdentifier(node.property)) {
|
|
404
439
|
const varName = node.object.value;
|
|
405
440
|
const propName = node.property.value;
|
|
406
|
-
const uniqueKey = `${
|
|
441
|
+
const uniqueKey = `${resourcePath}-${varName}`;
|
|
407
442
|
let hash = scannedTables.createHashTable[uniqueKey];
|
|
408
443
|
if (!hash) {
|
|
409
444
|
hash = mergedCreateTable[varName];
|
|
@@ -426,13 +461,12 @@ function loader(source) {
|
|
|
426
461
|
themeHash = mergedCreateThemeHashTable[varName];
|
|
427
462
|
}
|
|
428
463
|
if (themeHash) {
|
|
429
|
-
const
|
|
430
|
-
if (
|
|
431
|
-
const cssVarName = (0, zss_engine_1.camelToKebabCase)(propName);
|
|
464
|
+
const atomicMap = scannedTables.createAtomicMapTable[themeHash];
|
|
465
|
+
if (atomicMap && atomicMap && atomicMap[propName]) {
|
|
432
466
|
replacements.push({
|
|
433
467
|
start: node.span.start - ast.span.start,
|
|
434
468
|
end: node.span.end - ast.span.start,
|
|
435
|
-
content: JSON.stringify(
|
|
469
|
+
content: JSON.stringify(atomicMap[propName]),
|
|
436
470
|
});
|
|
437
471
|
}
|
|
438
472
|
}
|
|
@@ -467,7 +501,7 @@ function loader(source) {
|
|
|
467
501
|
return;
|
|
468
502
|
}
|
|
469
503
|
const varName = node.value;
|
|
470
|
-
const uniqueKey = `${
|
|
504
|
+
const uniqueKey = `${resourcePath}-${varName}`;
|
|
471
505
|
let hash = scannedTables.createHashTable[uniqueKey];
|
|
472
506
|
if (!hash) {
|
|
473
507
|
hash = mergedCreateTable[varName];
|
|
@@ -489,46 +523,19 @@ function loader(source) {
|
|
|
489
523
|
});
|
|
490
524
|
}
|
|
491
525
|
}
|
|
492
|
-
let kfHash = scannedTables.keyframesHashTable[uniqueKey];
|
|
493
|
-
if (!kfHash) {
|
|
494
|
-
kfHash = mergedKeyframesTable[varName];
|
|
495
|
-
}
|
|
496
|
-
if (kfHash) {
|
|
497
|
-
replacements.push({
|
|
498
|
-
start: node.span.start - ast.span.start,
|
|
499
|
-
end: node.span.end - ast.span.start,
|
|
500
|
-
content: JSON.stringify(`kf-${kfHash}`),
|
|
501
|
-
});
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
let vtHash = scannedTables.viewTransitionHashTable[uniqueKey];
|
|
505
|
-
if (!vtHash) {
|
|
506
|
-
vtHash = mergedViewTransitionTable[varName];
|
|
507
|
-
}
|
|
508
|
-
if (vtHash) {
|
|
509
|
-
replacements.push({
|
|
510
|
-
start: node.span.start - ast.span.start,
|
|
511
|
-
end: node.span.end - ast.span.start,
|
|
512
|
-
content: JSON.stringify(`vt-${vtHash}`),
|
|
513
|
-
});
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
526
|
let themeHash = scannedTables.createThemeHashTable[uniqueKey];
|
|
517
527
|
if (!themeHash) {
|
|
518
528
|
themeHash = mergedCreateThemeHashTable[varName];
|
|
519
529
|
}
|
|
520
530
|
if (themeHash) {
|
|
521
|
-
const
|
|
522
|
-
if (
|
|
523
|
-
const themeVars = {};
|
|
524
|
-
Object.keys(themeObj).forEach((key) => {
|
|
525
|
-
themeVars[key] = `var(--${(0, zss_engine_1.camelToKebabCase)(key)})`;
|
|
526
|
-
});
|
|
531
|
+
const atomicMap = scannedTables.createAtomicMapTable[themeHash];
|
|
532
|
+
if (atomicMap) {
|
|
527
533
|
replacements.push({
|
|
528
534
|
start: node.span.start - ast.span.start,
|
|
529
535
|
end: node.span.end - ast.span.start,
|
|
530
|
-
content: JSON.stringify(
|
|
536
|
+
content: JSON.stringify(atomicMap),
|
|
531
537
|
});
|
|
538
|
+
return;
|
|
532
539
|
}
|
|
533
540
|
}
|
|
534
541
|
let staticHash = scannedTables.createStaticHashTable[uniqueKey];
|
|
@@ -602,17 +609,21 @@ function loader(source) {
|
|
|
602
609
|
}
|
|
603
610
|
else if (utils_1.t.isIdentifier(expr)) {
|
|
604
611
|
const varName = expr.value;
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
|
|
612
|
+
const uniqueKey = `${this.resourcePath}-${varName}`;
|
|
613
|
+
let hash = scannedTables.createHashTable[uniqueKey];
|
|
614
|
+
if (!hash) {
|
|
615
|
+
hash = mergedCreateTable[varName];
|
|
608
616
|
}
|
|
609
|
-
const hash = mergedCreateTable[varName];
|
|
610
617
|
if (hash) {
|
|
611
618
|
const obj = scannedTables.createObjectTable[hash];
|
|
612
619
|
if (obj && typeof obj === 'object') {
|
|
613
620
|
return obj;
|
|
614
621
|
}
|
|
615
622
|
}
|
|
623
|
+
const styleInfo = localCreateStyles[varName];
|
|
624
|
+
if (styleInfo && styleInfo.obj) {
|
|
625
|
+
return styleInfo.obj;
|
|
626
|
+
}
|
|
616
627
|
if (localCreateStyles[varName]) {
|
|
617
628
|
return localCreateStyles[varName].obj;
|
|
618
629
|
}
|
|
@@ -632,13 +643,18 @@ function loader(source) {
|
|
|
632
643
|
if (utils_1.t.isCallExpression(expr) && utils_1.t.isIdentifier(expr.callee)) {
|
|
633
644
|
const varName = expr.callee.value;
|
|
634
645
|
let variantObj;
|
|
635
|
-
|
|
636
|
-
|
|
646
|
+
const uniqueKey = `${this.resourcePath}-${varName}`;
|
|
647
|
+
let hash = scannedTables.variantsHashTable[uniqueKey];
|
|
648
|
+
if (!hash) {
|
|
649
|
+
hash = mergedVariantsTable[varName];
|
|
637
650
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
651
|
+
if (hash && scannedTables.variantsObjectTable[hash]) {
|
|
652
|
+
variantObj = scannedTables.variantsObjectTable[hash];
|
|
653
|
+
}
|
|
654
|
+
if (!variantObj) {
|
|
655
|
+
if (localCreateStyles[varName] &&
|
|
656
|
+
localCreateStyles[varName].obj) {
|
|
657
|
+
variantObj = localCreateStyles[varName].obj;
|
|
642
658
|
}
|
|
643
659
|
}
|
|
644
660
|
if (variantObj) {
|
|
@@ -757,7 +773,7 @@ function loader(source) {
|
|
|
757
773
|
(0, utils_1.extractOndemandStyles)(baseStyle, extractedSheets, scannedTables);
|
|
758
774
|
}
|
|
759
775
|
const hash = (0, zss_engine_1.genBase36Hash)(baseStyle, 1, 8);
|
|
760
|
-
const records = (0, utils_1.getStyleRecords)(hash, baseStyle
|
|
776
|
+
const records = (0, utils_1.getStyleRecords)(hash, baseStyle);
|
|
761
777
|
if (!isProduction) {
|
|
762
778
|
records.forEach((r) => addSheet(r.sheet));
|
|
763
779
|
}
|
|
@@ -794,12 +810,12 @@ function loader(source) {
|
|
|
794
810
|
table[i] = '';
|
|
795
811
|
continue;
|
|
796
812
|
}
|
|
797
|
-
if (
|
|
813
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
798
814
|
(0, utils_1.extractOndemandStyles)(currentStyle, extractedSheets, scannedTables);
|
|
799
815
|
}
|
|
800
816
|
const hash = (0, zss_engine_1.genBase36Hash)(currentStyle, 1, 8);
|
|
801
|
-
const records = (0, utils_1.getStyleRecords)(hash, currentStyle
|
|
802
|
-
if (
|
|
817
|
+
const records = (0, utils_1.getStyleRecords)(hash, currentStyle);
|
|
818
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
803
819
|
records.forEach((r) => extractedSheets.push(r.sheet));
|
|
804
820
|
}
|
|
805
821
|
const className = records
|
|
@@ -836,6 +852,9 @@ function loader(source) {
|
|
|
836
852
|
},
|
|
837
853
|
});
|
|
838
854
|
Object.values(localCreateStyles).forEach((info) => {
|
|
855
|
+
if (info.type === 'constant') {
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
839
858
|
if (info.isExported) {
|
|
840
859
|
replacements.push({
|
|
841
860
|
start: info.declSpan.start,
|
|
@@ -851,10 +870,7 @@ function loader(source) {
|
|
|
851
870
|
});
|
|
852
871
|
}
|
|
853
872
|
});
|
|
854
|
-
|
|
855
|
-
fileStyles.baseStyles =
|
|
856
|
-
(fileStyles.baseStyles || '') + extractedSheets.join('');
|
|
857
|
-
}
|
|
873
|
+
const optInCSS = await (0, utils_1.optimizer)(extractedSheets.join(''));
|
|
858
874
|
const buffer = Buffer.from(source);
|
|
859
875
|
let offset = 0;
|
|
860
876
|
const parts = [];
|
|
@@ -880,7 +896,7 @@ function loader(source) {
|
|
|
880
896
|
}
|
|
881
897
|
const virtualCssRequest = stringifyRequest(this, `${VIRTUAL_CSS_PATH}`);
|
|
882
898
|
const postfix = `\nimport ${virtualCssRequest};`;
|
|
883
|
-
const css = fs_1.
|
|
899
|
+
const css = (0, fs_1.readFileSync)(VIRTUAL_FILE_PATH, 'utf-8');
|
|
884
900
|
function generateOrderedCSS(styles) {
|
|
885
901
|
const sections = [];
|
|
886
902
|
if (styles.keyframeStyles?.trim()) {
|
|
@@ -900,7 +916,7 @@ function loader(source) {
|
|
|
900
916
|
}
|
|
901
917
|
return sections.join('\n');
|
|
902
918
|
}
|
|
903
|
-
const orderedCSS = generateOrderedCSS(fileStyles);
|
|
919
|
+
const orderedCSS = await (0, utils_1.optimizer)(generateOrderedCSS(fileStyles));
|
|
904
920
|
const relativeId = path_1.default.relative(process.cwd(), this.resourcePath);
|
|
905
921
|
const hmrCode = `
|
|
906
922
|
if (module.hot) {
|
|
@@ -934,7 +950,7 @@ function loader(source) {
|
|
|
934
950
|
}
|
|
935
951
|
`;
|
|
936
952
|
if (extractedSheets.length > 0 && process.env.NODE_ENV === 'development') {
|
|
937
|
-
fs_1.
|
|
953
|
+
(0, fs_1.appendFileSync)(VIRTUAL_FILE_PATH, optInCSS, 'utf-8');
|
|
938
954
|
}
|
|
939
955
|
const useClientDirective = /^\s*['"]use client['"]/;
|
|
940
956
|
if (process.env.NODE_ENV === 'production')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/webpack-plugin",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.1",
|
|
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.
|
|
25
|
+
"@plumeria/utils": "^6.3.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@swc/core": "1.15.8",
|