@plumeria/turbopack-loader 11.1.1 → 11.1.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.
Files changed (2) hide show
  1. package/dist/index.js +17 -28
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -385,11 +385,17 @@ async function loader(source) {
385
385
  const uniqueKey = `${resourcePath}-${node.id.value}`;
386
386
  scannedTables.createThemeHashTable[uniqueKey] = hash;
387
387
  scannedTables.createThemeObjectTable[hash] = obj;
388
+ mergedCreateThemeHashTable[node.id.value] = hash;
389
+ const themeHashMap = {};
390
+ for (const [key] of Object.entries(obj)) {
391
+ const cssVarName = (0, zss_engine_1.camelToKebabCase)(key);
392
+ themeHashMap[key] = `var(--${hash}-${cssVarName})`;
393
+ }
388
394
  localCreateStyles[node.id.value] = {
389
395
  name: node.id.value,
390
396
  type: 'constant',
391
397
  obj,
392
- hashMap: scannedTables.createAtomicMapTable[hash],
398
+ hashMap: themeHashMap,
393
399
  isExported,
394
400
  initSpan: {
395
401
  start: init.span.start - baseByteOffset,
@@ -1311,6 +1317,7 @@ async function loader(source) {
1311
1317
  });
1312
1318
  parts.push(buffer.subarray(offset));
1313
1319
  const transformedSource = Buffer.concat(parts).toString();
1320
+ const optInCSS = await (0, utils_1.optimizer)(extractedSheets.join(''));
1314
1321
  let relativeImportPath = path.relative(path.dirname(resourcePath), VIRTUAL_FILE_PATH);
1315
1322
  relativeImportPath = relativeImportPath.replace(/\\/g, '/');
1316
1323
  if (!relativeImportPath.startsWith('.')) {
@@ -1320,39 +1327,21 @@ async function loader(source) {
1320
1327
  if (process.env.NODE_ENV === 'production') {
1321
1328
  return callback(null, transformedSource);
1322
1329
  }
1323
- if (process.env.NODE_ENV === 'development') {
1324
- const optInCSS = await (0, utils_1.optimizer)(extractedSheets.join(''));
1325
- const projectName = path.basename(this.rootContext);
1326
- const relativeFromRoot = path
1327
- .relative(this.rootContext, resourcePath)
1328
- .replace(/\\/g, '/');
1329
- const filePathKey = `${projectName}/${relativeFromRoot}`;
1330
- const startMarker = `/* ---start:${filePathKey} */`;
1331
- const endMarker = `/* ---end:${filePathKey} */`;
1330
+ if (extractedSheets.length > 0 && process.env.NODE_ENV === 'development') {
1331
+ const newCss = optInCSS + '\n';
1332
1332
  let currentCss = '';
1333
1333
  try {
1334
1334
  currentCss = fs.readFileSync(VIRTUAL_FILE_PATH, 'utf-8');
1335
1335
  }
1336
1336
  catch (e) {
1337
1337
  }
1338
- let nextCss = currentCss;
1339
- const cleanOptInCSS = optInCSS.trim();
1340
- const newBlock = cleanOptInCSS
1341
- ? `${startMarker}\n${cleanOptInCSS}\n${endMarker}`
1342
- : '';
1343
- const startIndex = currentCss.indexOf(startMarker);
1344
- const endIndex = currentCss.indexOf(endMarker);
1345
- if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {
1346
- const before = currentCss.substring(0, startIndex);
1347
- const after = currentCss.substring(endIndex + endMarker.length);
1348
- nextCss = before + newBlock + after;
1349
- }
1350
- else if (newBlock) {
1351
- nextCss = currentCss + (currentCss.trim() ? '\n\n' : '') + newBlock;
1352
- }
1353
- nextCss = nextCss.replace(/\n{3,}/g, '\n\n').trim() + '\n';
1354
- if (currentCss !== nextCss) {
1355
- fs.writeFileSync(VIRTUAL_FILE_PATH, nextCss, 'utf-8');
1338
+ if (!currentCss.includes(optInCSS)) {
1339
+ if (currentCss) {
1340
+ fs.writeFileSync(VIRTUAL_FILE_PATH, currentCss + newCss, 'utf-8');
1341
+ }
1342
+ else {
1343
+ fs.writeFileSync(VIRTUAL_FILE_PATH, newCss, 'utf-8');
1344
+ }
1356
1345
  }
1357
1346
  }
1358
1347
  return callback(null, transformedSource + postfix);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/turbopack-loader",
3
- "version": "11.1.1",
3
+ "version": "11.1.3",
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": "^11.1.1"
25
+ "@plumeria/utils": "^11.1.3"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@swc/core": "1.15.21",