@plumeria/turbopack-loader 6.0.2 → 6.1.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.
Files changed (2) hide show
  1. package/dist/index.js +74 -8
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -40,9 +40,26 @@ async function loader(source) {
40
40
  const localConsts = (0, utils_1.collectLocalConsts)(ast);
41
41
  const resourcePath = this.resourcePath;
42
42
  const importMap = {};
43
+ const plumeriaAliases = {};
43
44
  (0, utils_1.traverse)(ast, {
44
45
  ImportDeclaration({ node }) {
45
46
  const sourcePath = node.source.value;
47
+ if (sourcePath === '@plumeria/core') {
48
+ node.specifiers.forEach((specifier) => {
49
+ if (specifier.type === 'ImportNamespaceSpecifier') {
50
+ plumeriaAliases[specifier.local.value] = 'NAMESPACE';
51
+ }
52
+ else if (specifier.type === 'ImportDefaultSpecifier') {
53
+ plumeriaAliases[specifier.local.value] = 'NAMESPACE';
54
+ }
55
+ else if (specifier.type === 'ImportSpecifier') {
56
+ const importedName = specifier.imported
57
+ ? specifier.imported.value
58
+ : specifier.local.value;
59
+ plumeriaAliases[specifier.local.value] = importedName;
60
+ }
61
+ });
62
+ }
46
63
  const actualPath = (0, utils_1.resolveImportPath)(sourcePath, resourcePath);
47
64
  if (actualPath) {
48
65
  node.specifiers.forEach((specifier) => {
@@ -146,14 +163,31 @@ async function loader(source) {
146
163
  }
147
164
  };
148
165
  const registerStyle = (node, declSpan, isExported) => {
166
+ let propName;
149
167
  if (utils_1.t.isIdentifier(node.id) &&
150
168
  node.init &&
151
169
  utils_1.t.isCallExpression(node.init) &&
152
- utils_1.t.isMemberExpression(node.init.callee) &&
153
- utils_1.t.isIdentifier(node.init.callee.object, { name: 'css' }) &&
154
- utils_1.t.isIdentifier(node.init.callee.property) &&
155
170
  node.init.arguments.length >= 1) {
156
- const propName = node.init.callee.property.value;
171
+ const callee = node.init.callee;
172
+ if (utils_1.t.isMemberExpression(callee) &&
173
+ utils_1.t.isIdentifier(callee.object) &&
174
+ utils_1.t.isIdentifier(callee.property)) {
175
+ const objectName = callee.object.value;
176
+ const propertyName = callee.property.value;
177
+ const alias = plumeriaAliases[objectName];
178
+ if (alias === 'NAMESPACE' || objectName === 'css') {
179
+ propName = propertyName;
180
+ }
181
+ }
182
+ else if (utils_1.t.isIdentifier(callee)) {
183
+ const calleeName = callee.value;
184
+ const originalName = plumeriaAliases[calleeName];
185
+ if (originalName) {
186
+ propName = originalName;
187
+ }
188
+ }
189
+ }
190
+ if (propName) {
157
191
  if (propName === 'create' &&
158
192
  utils_1.t.isObjectExpression(node.init.arguments[0].expression)) {
159
193
  const obj = (0, utils_1.objectExpressionToObject)(node.init.arguments[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable, mergedCreateTable, mergedVariantsTable);
@@ -274,10 +308,25 @@ async function loader(source) {
274
308
  },
275
309
  CallExpression({ node }) {
276
310
  const callee = node.callee;
311
+ let propName;
277
312
  if (utils_1.t.isMemberExpression(callee) &&
278
- utils_1.t.isIdentifier(callee.object, { name: 'css' }) &&
313
+ utils_1.t.isIdentifier(callee.object) &&
279
314
  utils_1.t.isIdentifier(callee.property)) {
280
- const propName = callee.property.value;
315
+ const objectName = callee.object.value;
316
+ const propertyName = callee.property.value;
317
+ const alias = plumeriaAliases[objectName];
318
+ if (alias === 'NAMESPACE' || objectName === 'css') {
319
+ propName = propertyName;
320
+ }
321
+ }
322
+ else if (utils_1.t.isIdentifier(callee)) {
323
+ const calleeName = callee.value;
324
+ const originalName = plumeriaAliases[calleeName];
325
+ if (originalName) {
326
+ propName = originalName;
327
+ }
328
+ }
329
+ if (propName) {
281
330
  const args = node.arguments;
282
331
  if (propName === 'keyframes' &&
283
332
  args.length > 0 &&
@@ -377,9 +426,26 @@ async function loader(source) {
377
426
  },
378
427
  CallExpression({ node }) {
379
428
  const callee = node.callee;
429
+ let isPropsCall = false;
380
430
  if (utils_1.t.isMemberExpression(callee) &&
381
- utils_1.t.isIdentifier(callee.object, { name: 'css' }) &&
382
- utils_1.t.isIdentifier(callee.property, { name: 'props' })) {
431
+ utils_1.t.isIdentifier(callee.object) &&
432
+ utils_1.t.isIdentifier(callee.property)) {
433
+ const objectName = callee.object.value;
434
+ const propertyName = callee.property.value;
435
+ const alias = plumeriaAliases[objectName];
436
+ if ((alias === 'NAMESPACE' || objectName === 'css') &&
437
+ propertyName === 'props') {
438
+ isPropsCall = true;
439
+ }
440
+ }
441
+ else if (utils_1.t.isIdentifier(callee)) {
442
+ const calleeName = callee.value;
443
+ const originalName = plumeriaAliases[calleeName];
444
+ if (originalName === 'props') {
445
+ isPropsCall = true;
446
+ }
447
+ }
448
+ if (isPropsCall) {
383
449
  const args = node.arguments;
384
450
  const resolveStyleObject = (expr) => {
385
451
  if (utils_1.t.isObjectExpression(expr)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/turbopack-loader",
3
- "version": "6.0.2",
3
+ "version": "6.1.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": "^6.0.2"
25
+ "@plumeria/utils": "^6.1.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@swc/core": "1.15.8",