@plumeria/turbopack-loader 4.2.0 → 5.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.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +59 -7
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -27,8 +27,60 @@ async function loader(source) {
|
|
|
27
27
|
tsx: true,
|
|
28
28
|
target: 'es2022',
|
|
29
29
|
});
|
|
30
|
-
const localConsts = (0, utils_1.collectLocalConsts)(ast
|
|
31
|
-
|
|
30
|
+
const localConsts = (0, utils_1.collectLocalConsts)(ast);
|
|
31
|
+
const resourcePath = this.resourcePath;
|
|
32
|
+
const importMap = {};
|
|
33
|
+
(0, utils_1.traverse)(ast, {
|
|
34
|
+
ImportDeclaration({ node }) {
|
|
35
|
+
const sourcePath = node.source.value;
|
|
36
|
+
const actualPath = (0, utils_1.resolveImportPath)(sourcePath, resourcePath);
|
|
37
|
+
if (actualPath && fs_1.default.existsSync(actualPath)) {
|
|
38
|
+
if (fs_1.default.existsSync(actualPath)) {
|
|
39
|
+
node.specifiers.forEach((specifier) => {
|
|
40
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
41
|
+
const importedName = specifier.imported
|
|
42
|
+
? specifier.imported.value
|
|
43
|
+
: specifier.local.value;
|
|
44
|
+
const localName = specifier.local.value;
|
|
45
|
+
const uniqueKey = `${actualPath}-${importedName}`;
|
|
46
|
+
if (utils_1.tables.staticTable[uniqueKey]) {
|
|
47
|
+
importMap[localName] = utils_1.tables.staticTable[uniqueKey];
|
|
48
|
+
}
|
|
49
|
+
if (utils_1.tables.keyframesHashTable[uniqueKey]) {
|
|
50
|
+
importMap[localName] = utils_1.tables.keyframesHashTable[uniqueKey];
|
|
51
|
+
}
|
|
52
|
+
if (utils_1.tables.viewTransitionHashTable[uniqueKey]) {
|
|
53
|
+
importMap[localName] =
|
|
54
|
+
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
|
+
});
|
|
65
|
+
const mergedStaticTable = { ...utils_1.tables.staticTable };
|
|
66
|
+
for (const key of Object.keys(localConsts)) {
|
|
67
|
+
mergedStaticTable[key] = localConsts[key];
|
|
68
|
+
}
|
|
69
|
+
for (const key of Object.keys(importMap)) {
|
|
70
|
+
mergedStaticTable[key] = importMap[key];
|
|
71
|
+
}
|
|
72
|
+
const mergedKeyframesTable = { ...utils_1.tables.keyframesHashTable };
|
|
73
|
+
for (const key of Object.keys(importMap)) {
|
|
74
|
+
mergedKeyframesTable[key] = importMap[key];
|
|
75
|
+
}
|
|
76
|
+
const mergedViewTransitionTable = { ...utils_1.tables.viewTransitionHashTable };
|
|
77
|
+
for (const key of Object.keys(importMap)) {
|
|
78
|
+
mergedViewTransitionTable[key] = importMap[key];
|
|
79
|
+
}
|
|
80
|
+
const mergedThemeTable = { ...utils_1.tables.themeTable };
|
|
81
|
+
for (const key of Object.keys(importMap)) {
|
|
82
|
+
mergedThemeTable[key] = importMap[key];
|
|
83
|
+
}
|
|
32
84
|
const isTSFile = this.resourcePath.endsWith('.ts') && !this.resourcePath.endsWith('.tsx');
|
|
33
85
|
const localCreateStyles = {};
|
|
34
86
|
const replacements = [];
|
|
@@ -47,7 +99,7 @@ async function loader(source) {
|
|
|
47
99
|
const propName = node.init.callee.property.value;
|
|
48
100
|
if (propName === 'create' &&
|
|
49
101
|
utils_1.t.isObjectExpression(node.init.arguments[0].expression)) {
|
|
50
|
-
const obj = (0, utils_1.objectExpressionToObject)(node.init.arguments[0].expression,
|
|
102
|
+
const obj = (0, utils_1.objectExpressionToObject)(node.init.arguments[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable);
|
|
51
103
|
if (obj) {
|
|
52
104
|
const hashMap = {};
|
|
53
105
|
Object.entries(obj).forEach(([key, style]) => {
|
|
@@ -145,7 +197,7 @@ async function loader(source) {
|
|
|
145
197
|
if (propName === 'keyframes' &&
|
|
146
198
|
args.length > 0 &&
|
|
147
199
|
utils_1.t.isObjectExpression(args[0].expression)) {
|
|
148
|
-
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression,
|
|
200
|
+
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable);
|
|
149
201
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
150
202
|
utils_1.tables.keyframesObjectTable[hash] = obj;
|
|
151
203
|
replacements.push({
|
|
@@ -157,7 +209,7 @@ async function loader(source) {
|
|
|
157
209
|
else if (propName === 'viewTransition' &&
|
|
158
210
|
args.length > 0 &&
|
|
159
211
|
utils_1.t.isObjectExpression(args[0].expression)) {
|
|
160
|
-
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression,
|
|
212
|
+
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable);
|
|
161
213
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
162
214
|
utils_1.tables.viewTransitionObjectTable[hash] = obj;
|
|
163
215
|
(0, utils_1.extractOndemandStyles)(obj, extractedSheets);
|
|
@@ -171,7 +223,7 @@ async function loader(source) {
|
|
|
171
223
|
else if (propName === 'createTheme' &&
|
|
172
224
|
args.length > 0 &&
|
|
173
225
|
utils_1.t.isObjectExpression(args[0].expression)) {
|
|
174
|
-
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression,
|
|
226
|
+
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable);
|
|
175
227
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
176
228
|
utils_1.tables.createThemeObjectTable[hash] = obj;
|
|
177
229
|
}
|
|
@@ -266,7 +318,7 @@ async function loader(source) {
|
|
|
266
318
|
const merged = args.reduce((acc, arg) => {
|
|
267
319
|
const expr = arg.expression;
|
|
268
320
|
if (utils_1.t.isObjectExpression(expr)) {
|
|
269
|
-
const obj = (0, utils_1.objectExpressionToObject)(expr,
|
|
321
|
+
const obj = (0, utils_1.objectExpressionToObject)(expr, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable);
|
|
270
322
|
return obj ? (0, utils_1.deepMerge)(acc, obj) : acc;
|
|
271
323
|
}
|
|
272
324
|
else if (utils_1.t.isMemberExpression(expr) &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/turbopack-loader",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Plumeria Turbopack-loader",
|
|
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": "^
|
|
25
|
+
"@plumeria/utils": "^5.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@swc/core": "1.15.8",
|