@plumeria/webpack-plugin 4.2.0 → 4.2.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.js +41 -7
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -29,8 +29,42 @@ function loader(source) {
|
|
|
29
29
|
tsx: true,
|
|
30
30
|
target: 'es2022',
|
|
31
31
|
});
|
|
32
|
-
const localConsts = (0, utils_1.collectLocalConsts)(ast
|
|
33
|
-
|
|
32
|
+
const localConsts = (0, utils_1.collectLocalConsts)(ast);
|
|
33
|
+
const resourcePath = this.resourcePath;
|
|
34
|
+
const importMap = {};
|
|
35
|
+
(0, utils_1.traverse)(ast, {
|
|
36
|
+
ImportDeclaration({ node }) {
|
|
37
|
+
const sourcePath = node.source.value;
|
|
38
|
+
const actualPath = (0, utils_1.resolveImportPath)(sourcePath, resourcePath);
|
|
39
|
+
if (actualPath && fs_1.default.existsSync(actualPath)) {
|
|
40
|
+
node.specifiers.forEach((specifier) => {
|
|
41
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
42
|
+
const importedName = specifier.imported
|
|
43
|
+
? specifier.imported.value
|
|
44
|
+
: specifier.local.value;
|
|
45
|
+
const localName = specifier.local.value;
|
|
46
|
+
const uniqueKey = `${actualPath}-${importedName}`;
|
|
47
|
+
if (utils_1.tables.staticTable[uniqueKey]) {
|
|
48
|
+
importMap[localName] = utils_1.tables.staticTable[uniqueKey];
|
|
49
|
+
}
|
|
50
|
+
if (utils_1.tables.keyframesHashTable[uniqueKey]) {
|
|
51
|
+
importMap[localName] = utils_1.tables.keyframesHashTable[uniqueKey];
|
|
52
|
+
}
|
|
53
|
+
if (utils_1.tables.viewTransitionHashTable[uniqueKey]) {
|
|
54
|
+
importMap[localName] = utils_1.tables.viewTransitionHashTable[uniqueKey];
|
|
55
|
+
}
|
|
56
|
+
if (utils_1.tables.themeTable[uniqueKey]) {
|
|
57
|
+
importMap[localName] = utils_1.tables.themeTable[uniqueKey];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
const mergedStaticTable = Object.assign(Object.create(utils_1.tables.staticTable), localConsts, importMap);
|
|
65
|
+
const mergedKeyframesTable = Object.assign(Object.create(utils_1.tables.keyframesHashTable), importMap);
|
|
66
|
+
const mergedViewTransitionTable = Object.assign(Object.create(utils_1.tables.viewTransitionHashTable), importMap);
|
|
67
|
+
const mergedThemeTable = Object.assign(Object.create(utils_1.tables.themeTable), importMap);
|
|
34
68
|
const isTSFile = this.resourcePath.endsWith('.ts') && !this.resourcePath.endsWith('.tsx');
|
|
35
69
|
const localCreateStyles = {};
|
|
36
70
|
const replacements = [];
|
|
@@ -48,7 +82,7 @@ function loader(source) {
|
|
|
48
82
|
const propName = node.init.callee.property.value;
|
|
49
83
|
if (propName === 'create' &&
|
|
50
84
|
utils_1.t.isObjectExpression(node.init.arguments[0].expression)) {
|
|
51
|
-
const obj = (0, utils_1.objectExpressionToObject)(node.init.arguments[0].expression,
|
|
85
|
+
const obj = (0, utils_1.objectExpressionToObject)(node.init.arguments[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable);
|
|
52
86
|
if (obj) {
|
|
53
87
|
const hashMap = {};
|
|
54
88
|
Object.entries(obj).forEach(([key, style]) => {
|
|
@@ -146,7 +180,7 @@ function loader(source) {
|
|
|
146
180
|
if (propName === 'keyframes' &&
|
|
147
181
|
args.length > 0 &&
|
|
148
182
|
utils_1.t.isObjectExpression(args[0].expression)) {
|
|
149
|
-
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression,
|
|
183
|
+
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable);
|
|
150
184
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
151
185
|
utils_1.tables.keyframesObjectTable[hash] = obj;
|
|
152
186
|
replacements.push({
|
|
@@ -158,7 +192,7 @@ function loader(source) {
|
|
|
158
192
|
else if (propName === 'viewTransition' &&
|
|
159
193
|
args.length > 0 &&
|
|
160
194
|
utils_1.t.isObjectExpression(args[0].expression)) {
|
|
161
|
-
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression,
|
|
195
|
+
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable);
|
|
162
196
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
163
197
|
utils_1.tables.viewTransitionObjectTable[hash] = obj;
|
|
164
198
|
(0, utils_1.extractOndemandStyles)(obj, extractedSheets);
|
|
@@ -172,7 +206,7 @@ function loader(source) {
|
|
|
172
206
|
else if (propName === 'createTheme' &&
|
|
173
207
|
args.length > 0 &&
|
|
174
208
|
utils_1.t.isObjectExpression(args[0].expression)) {
|
|
175
|
-
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression,
|
|
209
|
+
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable);
|
|
176
210
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
177
211
|
utils_1.tables.createThemeObjectTable[hash] = obj;
|
|
178
212
|
}
|
|
@@ -267,7 +301,7 @@ function loader(source) {
|
|
|
267
301
|
const merged = args.reduce((acc, arg) => {
|
|
268
302
|
const expr = arg.expression;
|
|
269
303
|
if (utils_1.t.isObjectExpression(expr)) {
|
|
270
|
-
const obj = (0, utils_1.objectExpressionToObject)(expr,
|
|
304
|
+
const obj = (0, utils_1.objectExpressionToObject)(expr, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable);
|
|
271
305
|
return obj ? (0, utils_1.deepMerge)(acc, obj) : acc;
|
|
272
306
|
}
|
|
273
307
|
else if (utils_1.t.isMemberExpression(expr) &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/webpack-plugin",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.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": "^4.2.
|
|
25
|
+
"@plumeria/utils": "^4.2.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@swc/core": "1.15.8",
|