@plumeria/turbopack-loader 6.3.0 → 6.3.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/dist/index.js +12 -8
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5,13 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = loader;
|
|
7
7
|
const core_1 = require("@swc/core");
|
|
8
|
-
const fs_1 =
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const zss_engine_1 = require("zss-engine");
|
|
11
11
|
const utils_1 = require("@plumeria/utils");
|
|
12
12
|
const VIRTUAL_FILE_PATH = path_1.default.resolve(__dirname, '..', 'zero-virtual.css');
|
|
13
13
|
if (process.env.NODE_ENV === 'production') {
|
|
14
|
-
fs_1.
|
|
14
|
+
(0, fs_1.writeFileSync)(VIRTUAL_FILE_PATH, '/** Placeholder file */\n', 'utf-8');
|
|
15
15
|
}
|
|
16
16
|
async function loader(source) {
|
|
17
17
|
const callback = this.async();
|
|
@@ -221,7 +221,7 @@ async function loader(source) {
|
|
|
221
221
|
if (obj) {
|
|
222
222
|
const hashMap = {};
|
|
223
223
|
Object.entries(obj).forEach(([key, style]) => {
|
|
224
|
-
const records = (0, utils_1.getStyleRecords)(key, style
|
|
224
|
+
const records = (0, utils_1.getStyleRecords)(key, style);
|
|
225
225
|
if (!isProduction) {
|
|
226
226
|
(0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
|
|
227
227
|
records.forEach((r) => {
|
|
@@ -371,6 +371,9 @@ async function loader(source) {
|
|
|
371
371
|
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
|
|
372
372
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
373
373
|
scannedTables.keyframesObjectTable[hash] = obj;
|
|
374
|
+
if (!isProduction) {
|
|
375
|
+
(0, utils_1.extractOndemandStyles)({ kf: `kf-${hash}` }, extractedSheets, scannedTables);
|
|
376
|
+
}
|
|
374
377
|
replacements.push({
|
|
375
378
|
start: node.span.start - ast.span.start,
|
|
376
379
|
end: node.span.end - ast.span.start,
|
|
@@ -418,7 +421,7 @@ async function loader(source) {
|
|
|
418
421
|
scannedTables.createObjectTable[hash] = obj;
|
|
419
422
|
Object.entries(obj).forEach(([key, style]) => {
|
|
420
423
|
if (typeof style === 'object' && style !== null) {
|
|
421
|
-
const records = (0, utils_1.getStyleRecords)(key, style
|
|
424
|
+
const records = (0, utils_1.getStyleRecords)(key, style);
|
|
422
425
|
if (!isProduction) {
|
|
423
426
|
(0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
|
|
424
427
|
records.forEach((r) => addSheet(r.sheet));
|
|
@@ -769,7 +772,7 @@ async function loader(source) {
|
|
|
769
772
|
(0, utils_1.extractOndemandStyles)(baseStyle, extractedSheets, scannedTables);
|
|
770
773
|
}
|
|
771
774
|
const hash = (0, zss_engine_1.genBase36Hash)(baseStyle, 1, 8);
|
|
772
|
-
const records = (0, utils_1.getStyleRecords)(hash, baseStyle
|
|
775
|
+
const records = (0, utils_1.getStyleRecords)(hash, baseStyle);
|
|
773
776
|
if (!isProduction) {
|
|
774
777
|
records.forEach((r) => addSheet(r.sheet));
|
|
775
778
|
}
|
|
@@ -810,7 +813,7 @@ async function loader(source) {
|
|
|
810
813
|
(0, utils_1.extractOndemandStyles)(currentStyle, extractedSheets, scannedTables);
|
|
811
814
|
}
|
|
812
815
|
const hash = (0, zss_engine_1.genBase36Hash)(currentStyle, 1, 8);
|
|
813
|
-
const records = (0, utils_1.getStyleRecords)(hash, currentStyle
|
|
816
|
+
const records = (0, utils_1.getStyleRecords)(hash, currentStyle);
|
|
814
817
|
if (process.env.NODE_ENV !== 'production') {
|
|
815
818
|
records.forEach((r) => extractedSheets.push(r.sheet));
|
|
816
819
|
}
|
|
@@ -848,7 +851,7 @@ async function loader(source) {
|
|
|
848
851
|
},
|
|
849
852
|
});
|
|
850
853
|
Object.values(localCreateStyles).forEach((info) => {
|
|
851
|
-
if (info.type === 'constant'
|
|
854
|
+
if (info.type === 'constant') {
|
|
852
855
|
return;
|
|
853
856
|
}
|
|
854
857
|
if (info.isExported) {
|
|
@@ -866,6 +869,7 @@ async function loader(source) {
|
|
|
866
869
|
});
|
|
867
870
|
}
|
|
868
871
|
});
|
|
872
|
+
const optInCSS = await (0, utils_1.optimizer)(extractedSheets.join(''));
|
|
869
873
|
const buffer = Buffer.from(source);
|
|
870
874
|
let offset = 0;
|
|
871
875
|
const parts = [];
|
|
@@ -899,7 +903,7 @@ async function loader(source) {
|
|
|
899
903
|
if (process.env.NODE_ENV === 'production')
|
|
900
904
|
return callback(null, transformedSource);
|
|
901
905
|
if (extractedSheets.length > 0 && process.env.NODE_ENV === 'development') {
|
|
902
|
-
fs_1.
|
|
906
|
+
(0, fs_1.appendFileSync)(VIRTUAL_FILE_PATH, optInCSS, 'utf-8');
|
|
903
907
|
}
|
|
904
908
|
return callback(null, transformedSource + postfix);
|
|
905
909
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/turbopack-loader",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.1",
|
|
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.3.
|
|
25
|
+
"@plumeria/utils": "^6.3.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@swc/core": "1.15.8",
|