@plumeria/unplugin 17.0.1 → 18.0.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/README.md +2 -2
- package/dist/core.js +11 -21
- package/dist/core.mjs +12 -22
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -155,7 +155,7 @@ plumeria.vite({
|
|
|
155
155
|
| `include` | `ts/tsx/js/jsx` | Files to transform. |
|
|
156
156
|
| `exclude` | — | Files to skip. |
|
|
157
157
|
| `devEmitToDisk` | `false` | Write CSS to disk in development so the bundler's watcher drives HMR. |
|
|
158
|
-
| `styleProp` | `'
|
|
158
|
+
| `styleProp` | `'classStyle'` | The JSX prop that carries styles. |
|
|
159
159
|
|
|
160
160
|
### styleProp
|
|
161
161
|
|
|
@@ -187,7 +187,7 @@ For the default name, reference the declaration that ships with the package inst
|
|
|
187
187
|
|
|
188
188
|
```ts
|
|
189
189
|
// plumeria.d.ts
|
|
190
|
-
/// <reference types="@plumeria/core/style
|
|
190
|
+
/// <reference types="@plumeria/core/class-style" />
|
|
191
191
|
```
|
|
192
192
|
|
|
193
193
|
If the two disagree, the prop type-checks but is never compiled away. [`@plumeria/eslint-plugin`](https://www.npmjs.com/package/@plumeria/eslint-plugin) reads the same name from `settings.plumeria.styleProp`.
|
package/dist/core.js
CHANGED
|
@@ -236,6 +236,13 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
236
236
|
const actualPath = (0, utils_1.resolveImportPath)(sourcePath, resourcePath);
|
|
237
237
|
if (actualPath) {
|
|
238
238
|
node.specifiers.forEach((specifier) => {
|
|
239
|
+
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
240
|
+
localImports[specifier.local.value] = {
|
|
241
|
+
actualPath,
|
|
242
|
+
importedName: '*',
|
|
243
|
+
};
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
239
246
|
if (specifier.type === 'ImportSpecifier' ||
|
|
240
247
|
specifier.type === 'ImportDefaultSpecifier') {
|
|
241
248
|
const importedName = specifier.type === 'ImportDefaultSpecifier'
|
|
@@ -1302,12 +1309,8 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1302
1309
|
};
|
|
1303
1310
|
(0, utils_1.traverse)(ast, {
|
|
1304
1311
|
JSXOpeningElement({ node }) {
|
|
1305
|
-
let tagName = '';
|
|
1306
|
-
if (node.name.type === 'Identifier') {
|
|
1307
|
-
tagName = node.name.value;
|
|
1308
|
-
}
|
|
1309
1312
|
jsxOpeningElementMap.set(node.span.start, {
|
|
1310
|
-
|
|
1313
|
+
compKey: (0, utils_1.resolveComponentKey)(node.name, resourcePath, localImports),
|
|
1311
1314
|
attributes: node.attributes,
|
|
1312
1315
|
});
|
|
1313
1316
|
},
|
|
@@ -1487,30 +1490,17 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1487
1490
|
return;
|
|
1488
1491
|
const attrName = node.name.value;
|
|
1489
1492
|
if (attrName !== styleProp) {
|
|
1490
|
-
let
|
|
1493
|
+
let compKey = null;
|
|
1491
1494
|
for (const [, val] of jsxOpeningElementMap) {
|
|
1492
1495
|
const found = val.attributes
|
|
1493
1496
|
.filter((a) => a.type === 'JSXAttribute')
|
|
1494
1497
|
.find((a) => a.span.start === node.span.start);
|
|
1495
1498
|
if (found) {
|
|
1496
|
-
|
|
1499
|
+
compKey = val.compKey;
|
|
1497
1500
|
break;
|
|
1498
1501
|
}
|
|
1499
1502
|
}
|
|
1500
|
-
if (
|
|
1501
|
-
parentTagName[0] === parentTagName[0].toUpperCase()) {
|
|
1502
|
-
let compKey;
|
|
1503
|
-
const imported = localImports[parentTagName];
|
|
1504
|
-
if (imported) {
|
|
1505
|
-
compKey = `${imported.actualPath}-${imported.importedName}`;
|
|
1506
|
-
const resolved = (0, utils_1.resolveExport)(imported.actualPath, imported.importedName);
|
|
1507
|
-
if (resolved) {
|
|
1508
|
-
compKey = `${resolved.filePath}-${resolved.localName}`;
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
else {
|
|
1512
|
-
compKey = `${resourcePath}-${parentTagName}`;
|
|
1513
|
-
}
|
|
1503
|
+
if (compKey) {
|
|
1514
1504
|
const list = scannedTables.componentPropsTable?.[compKey]?.[attrName];
|
|
1515
1505
|
if (list &&
|
|
1516
1506
|
node.value &&
|
package/dist/core.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createFilter } from '@rollup/pluginutils';
|
|
|
2
2
|
import { parseSync } from '@swc/core';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { applyCssValue, genBase36Hash, exceptionCamelCase, camelToKebabCase, isAtRule, } from 'zss-engine';
|
|
5
|
-
import { traverse, collectReferenceIdentifiers, getStyleRecords, collectLocalConsts, objectExpressionToObject, t, getRootIdentifier, extractOndemandStyles, deepMerge, scanAll, resolveImportPath, getLeadingCommentLength, optimizer, getFileDependencies, resolveExport, DEFAULT_STYLE_PROP, } from '@plumeria/utils';
|
|
5
|
+
import { traverse, collectReferenceIdentifiers, getStyleRecords, collectLocalConsts, objectExpressionToObject, t, getRootIdentifier, extractOndemandStyles, deepMerge, scanAll, resolveImportPath, getLeadingCommentLength, optimizer, getFileDependencies, resolveExport, resolveComponentKey, DEFAULT_STYLE_PROP, } from '@plumeria/utils';
|
|
6
6
|
export const TARGET_EXTENSIONS = ['ts', 'tsx', 'js', 'jsx'];
|
|
7
7
|
export const EXTENSION_PATTERN = /\.(ts|tsx|js|jsx)$/;
|
|
8
8
|
export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
@@ -200,6 +200,13 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
200
200
|
const actualPath = resolveImportPath(sourcePath, resourcePath);
|
|
201
201
|
if (actualPath) {
|
|
202
202
|
node.specifiers.forEach((specifier) => {
|
|
203
|
+
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
204
|
+
localImports[specifier.local.value] = {
|
|
205
|
+
actualPath,
|
|
206
|
+
importedName: '*',
|
|
207
|
+
};
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
203
210
|
if (specifier.type === 'ImportSpecifier' ||
|
|
204
211
|
specifier.type === 'ImportDefaultSpecifier') {
|
|
205
212
|
const importedName = specifier.type === 'ImportDefaultSpecifier'
|
|
@@ -1266,12 +1273,8 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1266
1273
|
};
|
|
1267
1274
|
traverse(ast, {
|
|
1268
1275
|
JSXOpeningElement({ node }) {
|
|
1269
|
-
let tagName = '';
|
|
1270
|
-
if (node.name.type === 'Identifier') {
|
|
1271
|
-
tagName = node.name.value;
|
|
1272
|
-
}
|
|
1273
1276
|
jsxOpeningElementMap.set(node.span.start, {
|
|
1274
|
-
|
|
1277
|
+
compKey: resolveComponentKey(node.name, resourcePath, localImports),
|
|
1275
1278
|
attributes: node.attributes,
|
|
1276
1279
|
});
|
|
1277
1280
|
},
|
|
@@ -1451,30 +1454,17 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1451
1454
|
return;
|
|
1452
1455
|
const attrName = node.name.value;
|
|
1453
1456
|
if (attrName !== styleProp) {
|
|
1454
|
-
let
|
|
1457
|
+
let compKey = null;
|
|
1455
1458
|
for (const [, val] of jsxOpeningElementMap) {
|
|
1456
1459
|
const found = val.attributes
|
|
1457
1460
|
.filter((a) => a.type === 'JSXAttribute')
|
|
1458
1461
|
.find((a) => a.span.start === node.span.start);
|
|
1459
1462
|
if (found) {
|
|
1460
|
-
|
|
1463
|
+
compKey = val.compKey;
|
|
1461
1464
|
break;
|
|
1462
1465
|
}
|
|
1463
1466
|
}
|
|
1464
|
-
if (
|
|
1465
|
-
parentTagName[0] === parentTagName[0].toUpperCase()) {
|
|
1466
|
-
let compKey;
|
|
1467
|
-
const imported = localImports[parentTagName];
|
|
1468
|
-
if (imported) {
|
|
1469
|
-
compKey = `${imported.actualPath}-${imported.importedName}`;
|
|
1470
|
-
const resolved = resolveExport(imported.actualPath, imported.importedName);
|
|
1471
|
-
if (resolved) {
|
|
1472
|
-
compKey = `${resolved.filePath}-${resolved.localName}`;
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
else {
|
|
1476
|
-
compKey = `${resourcePath}-${parentTagName}`;
|
|
1477
|
-
}
|
|
1467
|
+
if (compKey) {
|
|
1478
1468
|
const list = scannedTables.componentPropsTable?.[compKey]?.[attrName];
|
|
1479
1469
|
if (list &&
|
|
1480
1470
|
node.value &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/unplugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.1",
|
|
4
4
|
"description": "Universal Plumeria plugin for various build tools",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@rollup/pluginutils": "^5.4.0",
|
|
91
91
|
"unplugin": "^3.0.0",
|
|
92
|
-
"@plumeria/utils": "^
|
|
92
|
+
"@plumeria/utils": "^18.0.1"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@swc/core": "1.15.43",
|