@plumeria/turbopack-loader 8.0.2 → 9.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.js +48 -19
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,18 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
5
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
36
|
exports.default = loader;
|
|
7
37
|
const core_1 = require("@swc/core");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
10
40
|
const zss_engine_1 = require("zss-engine");
|
|
11
41
|
const utils_1 = require("@plumeria/utils");
|
|
12
42
|
async function loader(source) {
|
|
13
43
|
const callback = this.async();
|
|
14
44
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
15
|
-
const VIRTUAL_FILE_PATH =
|
|
45
|
+
const VIRTUAL_FILE_PATH = path.resolve(__dirname, '..', 'zero-virtual.css');
|
|
16
46
|
if (this.resourcePath.includes('node_modules') ||
|
|
17
47
|
!source.includes('@plumeria/core')) {
|
|
18
48
|
return callback(null, source);
|
|
@@ -183,7 +213,7 @@ async function loader(source) {
|
|
|
183
213
|
if ((localCreateStyles[varName] &&
|
|
184
214
|
localCreateStyles[varName].type === 'variant') ||
|
|
185
215
|
mergedVariantsTable[varName]) {
|
|
186
|
-
throw new Error(`Plumeria: Assigning the return value of "css.variants" to a variable is not supported.\nPlease pass the variant function directly to "css.
|
|
216
|
+
throw new Error(`Plumeria: Assigning the return value of "css.variants" to a variable is not supported.\nPlease pass the variant function directly to "css.use". Found assignment to: ${utils_1.t.isIdentifier(decl.id) ? decl.id.value : 'unknown'}`);
|
|
187
217
|
}
|
|
188
218
|
}
|
|
189
219
|
};
|
|
@@ -200,7 +230,7 @@ async function loader(source) {
|
|
|
200
230
|
const objectName = callee.object.value;
|
|
201
231
|
const propertyName = callee.property.value;
|
|
202
232
|
const alias = plumeriaAliases[objectName];
|
|
203
|
-
if (alias === 'NAMESPACE'
|
|
233
|
+
if (alias === 'NAMESPACE') {
|
|
204
234
|
propName = propertyName;
|
|
205
235
|
}
|
|
206
236
|
}
|
|
@@ -351,7 +381,7 @@ async function loader(source) {
|
|
|
351
381
|
const objectName = callee.object.value;
|
|
352
382
|
const propertyName = callee.property.value;
|
|
353
383
|
const alias = plumeriaAliases[objectName];
|
|
354
|
-
if (alias === 'NAMESPACE'
|
|
384
|
+
if (alias === 'NAMESPACE') {
|
|
355
385
|
propName = propertyName;
|
|
356
386
|
}
|
|
357
387
|
}
|
|
@@ -538,26 +568,25 @@ async function loader(source) {
|
|
|
538
568
|
},
|
|
539
569
|
CallExpression({ node }) {
|
|
540
570
|
const callee = node.callee;
|
|
541
|
-
let
|
|
571
|
+
let isUseCall = false;
|
|
542
572
|
if (utils_1.t.isMemberExpression(callee) &&
|
|
543
573
|
utils_1.t.isIdentifier(callee.object) &&
|
|
544
574
|
utils_1.t.isIdentifier(callee.property)) {
|
|
545
575
|
const objectName = callee.object.value;
|
|
546
576
|
const propertyName = callee.property.value;
|
|
547
577
|
const alias = plumeriaAliases[objectName];
|
|
548
|
-
if (
|
|
549
|
-
|
|
550
|
-
isPropsCall = true;
|
|
578
|
+
if (alias === 'NAMESPACE' && propertyName === 'use') {
|
|
579
|
+
isUseCall = true;
|
|
551
580
|
}
|
|
552
581
|
}
|
|
553
582
|
else if (utils_1.t.isIdentifier(callee)) {
|
|
554
583
|
const calleeName = callee.value;
|
|
555
584
|
const originalName = plumeriaAliases[calleeName];
|
|
556
|
-
if (originalName === '
|
|
557
|
-
|
|
585
|
+
if (originalName === 'use') {
|
|
586
|
+
isUseCall = true;
|
|
558
587
|
}
|
|
559
588
|
}
|
|
560
|
-
if (
|
|
589
|
+
if (isUseCall) {
|
|
561
590
|
const args = node.arguments;
|
|
562
591
|
const resolveStyleObject = (expr) => {
|
|
563
592
|
if (utils_1.t.isObjectExpression(expr)) {
|
|
@@ -1154,13 +1183,13 @@ async function loader(source) {
|
|
|
1154
1183
|
const VIRTUAL_CSS_PATH = require.resolve(VIRTUAL_FILE_PATH);
|
|
1155
1184
|
function stringifyRequest(loaderContext, request) {
|
|
1156
1185
|
const context = loaderContext.context || loaderContext.rootContext;
|
|
1157
|
-
const relativePath =
|
|
1186
|
+
const relativePath = path.relative(context, request);
|
|
1158
1187
|
const requestPath = relativePath.startsWith('.')
|
|
1159
1188
|
? relativePath
|
|
1160
1189
|
: './' + relativePath;
|
|
1161
1190
|
return JSON.stringify(requestPath);
|
|
1162
1191
|
}
|
|
1163
|
-
const virtualCssImportPath =
|
|
1192
|
+
const virtualCssImportPath = path.posix.join(path.posix.relative(path.dirname(this.resourcePath), path.resolve(__dirname, '..', VIRTUAL_CSS_PATH)));
|
|
1164
1193
|
let importPath = virtualCssImportPath;
|
|
1165
1194
|
if (!importPath.startsWith('.')) {
|
|
1166
1195
|
importPath = './' + importPath;
|
|
@@ -1171,7 +1200,7 @@ async function loader(source) {
|
|
|
1171
1200
|
return callback(null, transformedSource);
|
|
1172
1201
|
}
|
|
1173
1202
|
if (extractedSheets.length > 0 && process.env.NODE_ENV === 'development') {
|
|
1174
|
-
|
|
1203
|
+
fs.appendFileSync(VIRTUAL_FILE_PATH, optInCSS + '\n', 'utf-8');
|
|
1175
1204
|
}
|
|
1176
1205
|
return callback(null, transformedSource + postfix);
|
|
1177
1206
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/turbopack-loader",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Plumeria Turbopack-loader",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"zero-virtual.css"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@plumeria/utils": "^
|
|
25
|
+
"@plumeria/utils": "^9.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@swc/core": "1.15.
|
|
28
|
+
"@swc/core": "1.15.18",
|
|
29
29
|
"zss-engine": "2.2.4"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|