@plumeria/webpack-plugin 6.0.1 → 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 +20 -8
- 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({
|
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",
|