@plumeria/turbopack-loader 3.1.0 → 4.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.
Files changed (2) hide show
  1. package/dist/index.js +9 -11
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -9,6 +9,10 @@ const fs_1 = __importDefault(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
+ const VIRTUAL_FILE_PATH = path_1.default.resolve(__dirname, '..', 'zero-virtual.css');
13
+ if (process.env.NODE_ENV === 'production') {
14
+ fs_1.default.writeFileSync(VIRTUAL_FILE_PATH, '/** Placeholder file */', 'utf-8');
15
+ }
12
16
  async function loader(source) {
13
17
  const callback = this.async();
14
18
  if (this.resourcePath.includes('node_modules') ||
@@ -165,6 +169,8 @@ async function loader(source) {
165
169
  const obj = (0, utils_1.objectExpressionToObject)(args[0].expression, utils_1.tables.staticTable, utils_1.tables.keyframesHashTable, utils_1.tables.viewTransitionHashTable, utils_1.tables.themeTable);
166
170
  const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
167
171
  utils_1.tables.viewTransitionObjectTable[hash] = obj;
172
+ (0, utils_1.extractOndemandStyles)(obj, extractedSheets);
173
+ (0, utils_1.extractOndemandStyles)({ vt: `vt-${hash}` }, extractedSheets);
168
174
  replacements.push({
169
175
  start: node.span.start - ast.span.start,
170
176
  end: node.span.end - ast.span.start,
@@ -373,7 +379,6 @@ async function loader(source) {
373
379
  });
374
380
  parts.push(buffer.subarray(offset));
375
381
  const transformedSource = Buffer.concat(parts).toString();
376
- const VIRTUAL_FILE_PATH = path_1.default.resolve(__dirname, '..', 'zero-virtual.css');
377
382
  const VIRTUAL_CSS_PATH = require.resolve(VIRTUAL_FILE_PATH);
378
383
  function stringifyRequest(loaderContext, request) {
379
384
  const context = loaderContext.context || loaderContext.rootContext;
@@ -390,17 +395,10 @@ async function loader(source) {
390
395
  }
391
396
  const virtualCssRequest = stringifyRequest(this, `${VIRTUAL_CSS_PATH}`);
392
397
  const postfix = `\nimport ${virtualCssRequest};`;
393
- if (extractedSheets.length > 0 && process.env.NODE_ENV === 'development') {
394
- fs_1.default.appendFileSync(VIRTUAL_FILE_PATH, extractedSheets.join(''), 'utf-8');
395
- }
396
- else if (extractedSheets.length > 0 &&
397
- process.env.NODE_ENV === 'production') {
398
- fs_1.default.writeFileSync(VIRTUAL_FILE_PATH, '');
399
- }
400
398
  if (process.env.NODE_ENV === 'production')
401
399
  return callback(null, transformedSource);
402
- if (extractedSheets.length > 0) {
403
- return callback(null, transformedSource + postfix);
400
+ if (extractedSheets.length > 0 && process.env.NODE_ENV === 'development') {
401
+ fs_1.default.appendFileSync(VIRTUAL_FILE_PATH, extractedSheets.join(''), 'utf-8');
404
402
  }
405
- callback(null, transformedSource);
403
+ return callback(null, transformedSource + postfix);
406
404
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/turbopack-loader",
3
- "version": "3.1.0",
3
+ "version": "4.0.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": "^3.1.0"
25
+ "@plumeria/utils": "^4.0.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@swc/core": "1.15.2",