@plumeria/turbopack-loader 18.2.2 → 18.2.3
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 +90 -44
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -238,6 +238,28 @@ async function loader(source) {
|
|
|
238
238
|
this.addDependency(parentFile);
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
+
const components = [];
|
|
242
|
+
for (const node of ast.body) {
|
|
243
|
+
const statement = utils_1.t.isExportDeclaration(node) ? node.declaration : node;
|
|
244
|
+
if (statement.type === 'FunctionDeclaration' && statement.identifier) {
|
|
245
|
+
components.push({ name: statement.identifier.value, node: statement });
|
|
246
|
+
}
|
|
247
|
+
else if (utils_1.t.isVariableDeclaration(statement)) {
|
|
248
|
+
for (const decl of statement.declarations) {
|
|
249
|
+
if (utils_1.t.isIdentifier(decl.id) &&
|
|
250
|
+
(decl.init?.type === 'ArrowFunctionExpression' ||
|
|
251
|
+
decl.init?.type === 'FunctionExpression')) {
|
|
252
|
+
components.push({ name: decl.id.value, node: decl.init });
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const appliedStyleProps = new Set();
|
|
258
|
+
const markStylePropApplied = (name, at) => {
|
|
259
|
+
const owner = components.find((c) => at.span.start >= c.node.span.start &&
|
|
260
|
+
at.span.start <= c.node.span.end);
|
|
261
|
+
appliedStyleProps.add(`${owner ? owner.name : '*'}:${name}`);
|
|
262
|
+
};
|
|
241
263
|
const extractedSheets = [];
|
|
242
264
|
const addSheet = (sheet) => {
|
|
243
265
|
if (!extractedSheets.includes(sheet)) {
|
|
@@ -1147,56 +1169,68 @@ async function loader(source) {
|
|
|
1147
1169
|
else if (node.type === 'ParenthesisExpression') {
|
|
1148
1170
|
return collectConditions(node.expression, currentTestStrings, argOrder);
|
|
1149
1171
|
}
|
|
1172
|
+
if (pushPropPossibilities(node, currentTestStrings))
|
|
1173
|
+
return true;
|
|
1150
1174
|
assertResolvable(node);
|
|
1151
1175
|
return false;
|
|
1152
1176
|
};
|
|
1153
|
-
|
|
1154
|
-
const
|
|
1155
|
-
|
|
1156
|
-
(
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
propPossibilities =
|
|
1169
|
-
scannedTables.componentPropsTable?.[key]?.[varName];
|
|
1170
|
-
break;
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
if (propPossibilities && propPossibilities.length > 0) {
|
|
1175
|
-
const currentGroupId = ++groupIdCounter;
|
|
1176
|
-
const currentOrder = sourceOrder++;
|
|
1177
|
-
const uniqueEntries = [];
|
|
1178
|
-
propPossibilities.forEach((entry) => {
|
|
1179
|
-
if (!uniqueEntries.some((x) => x.key === entry.key)) {
|
|
1180
|
-
uniqueEntries.push(entry);
|
|
1181
|
-
}
|
|
1182
|
-
});
|
|
1183
|
-
uniqueEntries.forEach((entry) => {
|
|
1184
|
-
conditionals.push({
|
|
1185
|
-
test: expr,
|
|
1186
|
-
testLHS,
|
|
1187
|
-
testString: `${testLHS} === ${JSON.stringify(entry.key)}`,
|
|
1188
|
-
truthy: entry.styleObj,
|
|
1189
|
-
falsy: {},
|
|
1190
|
-
groupId: currentGroupId,
|
|
1191
|
-
order: currentOrder,
|
|
1192
|
-
groupName: undefined,
|
|
1193
|
-
valueName: entry.key,
|
|
1194
|
-
varName,
|
|
1195
|
-
});
|
|
1196
|
-
});
|
|
1177
|
+
const pushPropPossibilities = (expr, gates) => {
|
|
1178
|
+
const isParamMember = utils_1.t.isMemberExpression(expr) &&
|
|
1179
|
+
utils_1.t.isIdentifier(expr.object) &&
|
|
1180
|
+
componentParamNames.has(expr.object.value) &&
|
|
1181
|
+
utils_1.t.isIdentifier(expr.property);
|
|
1182
|
+
if (!utils_1.t.isIdentifier(expr) && !isParamMember)
|
|
1183
|
+
return false;
|
|
1184
|
+
const varName = utils_1.t.isIdentifier(expr)
|
|
1185
|
+
? expr.value
|
|
1186
|
+
: expr.property.value;
|
|
1187
|
+
const source = utils_1.t.isIdentifier(expr) ? varName : getSource(expr);
|
|
1188
|
+
markStylePropApplied(varName, expr);
|
|
1189
|
+
let possibilities;
|
|
1190
|
+
for (const key of Object.keys(scannedTables.componentPropsTable || {})) {
|
|
1191
|
+
if (!key.startsWith(`${resourcePath}-`))
|
|
1197
1192
|
continue;
|
|
1193
|
+
if (scannedTables.componentPropsTable?.[key]?.[varName]) {
|
|
1194
|
+
possibilities = scannedTables.componentPropsTable[key][varName];
|
|
1195
|
+
break;
|
|
1198
1196
|
}
|
|
1199
1197
|
}
|
|
1198
|
+
if (!possibilities || possibilities.length === 0)
|
|
1199
|
+
return false;
|
|
1200
|
+
const testLHS = gates.length
|
|
1201
|
+
? `((${gates.join(' && ')}) ? ${source} : "")`
|
|
1202
|
+
: source;
|
|
1203
|
+
const currentGroupId = ++groupIdCounter;
|
|
1204
|
+
const currentOrder = sourceOrder++;
|
|
1205
|
+
const seen = new Set();
|
|
1206
|
+
const pushOption = (valueName, style) => {
|
|
1207
|
+
conditionals.push({
|
|
1208
|
+
test: expr,
|
|
1209
|
+
testLHS,
|
|
1210
|
+
testString: `${testLHS} === ${JSON.stringify(valueName)}`,
|
|
1211
|
+
truthy: style,
|
|
1212
|
+
falsy: {},
|
|
1213
|
+
groupId: currentGroupId,
|
|
1214
|
+
order: currentOrder,
|
|
1215
|
+
groupName: undefined,
|
|
1216
|
+
valueName,
|
|
1217
|
+
varName,
|
|
1218
|
+
});
|
|
1219
|
+
};
|
|
1220
|
+
possibilities.forEach((entry) => {
|
|
1221
|
+
if (seen.has(entry.key))
|
|
1222
|
+
return;
|
|
1223
|
+
seen.add(entry.key);
|
|
1224
|
+
pushOption(entry.key, entry.styleObj);
|
|
1225
|
+
});
|
|
1226
|
+
if (gates.length)
|
|
1227
|
+
pushOption('', {});
|
|
1228
|
+
return true;
|
|
1229
|
+
};
|
|
1230
|
+
for (const arg of args) {
|
|
1231
|
+
const expr = arg.expression;
|
|
1232
|
+
if (pushPropPossibilities(expr, []))
|
|
1233
|
+
continue;
|
|
1200
1234
|
if (utils_1.t.isCallExpression(expr) && utils_1.t.isIdentifier(expr.callee)) {
|
|
1201
1235
|
const varName = expr.callee.value;
|
|
1202
1236
|
const uniqueKey = `${resourcePath}-${varName}`;
|
|
@@ -2033,6 +2067,18 @@ async function loader(source) {
|
|
|
2033
2067
|
}
|
|
2034
2068
|
},
|
|
2035
2069
|
});
|
|
2070
|
+
for (const { name, node } of components) {
|
|
2071
|
+
const props = scannedTables.componentPropsTable?.[`${resourcePath}-${name}`];
|
|
2072
|
+
for (const propName of Object.keys(props ?? {})) {
|
|
2073
|
+
if (appliedStyleProps.has(`${name}:${propName}`) ||
|
|
2074
|
+
appliedStyleProps.has(`*:${propName}`)) {
|
|
2075
|
+
continue;
|
|
2076
|
+
}
|
|
2077
|
+
throwCompilationError(`Plumeria: "${propName}" is a style received through a prop but is never applied ` +
|
|
2078
|
+
`to ${styleProp} or css.use() here. Apply it on an element this component renders; ` +
|
|
2079
|
+
`a style prop cannot be passed on to another component.`, node);
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2036
2082
|
const buildExportedInit = (info) => {
|
|
2037
2083
|
const keys = Object.keys(info.obj);
|
|
2038
2084
|
if (isProduction || keys.length === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/turbopack-loader",
|
|
3
|
-
"version": "18.2.
|
|
3
|
+
"version": "18.2.3",
|
|
4
4
|
"description": "Plumeria Turbopack-loader",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"zero-virtual.css"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@plumeria/compiler": "^18.2.
|
|
26
|
-
"@plumeria/utils": "^18.2.
|
|
25
|
+
"@plumeria/compiler": "^18.2.3",
|
|
26
|
+
"@plumeria/utils": "^18.2.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@swc/core": "1.15.47",
|