@plumeria/turbopack-loader 6.0.1 → 6.0.2

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 +19 -7
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -14,7 +14,6 @@ if (process.env.NODE_ENV === 'production') {
14
14
  fs_1.default.writeFileSync(VIRTUAL_FILE_PATH, '/** Placeholder file */', 'utf-8');
15
15
  }
16
16
  async function loader(source) {
17
- const loaderContext = this;
18
17
  const callback = this.async();
19
18
  const isProduction = process.env.NODE_ENV === 'production';
20
19
  if (this.resourcePath.includes('node_modules') ||
@@ -23,12 +22,21 @@ async function loader(source) {
23
22
  }
24
23
  this.clearDependencies();
25
24
  this.addDependency(this.resourcePath);
26
- const scannedTables = (0, utils_1.scanAll)();
27
25
  const ast = (0, core_1.parseSync)(source, {
28
26
  syntax: 'typescript',
29
27
  tsx: true,
30
28
  target: 'es2022',
31
29
  });
30
+ for (const node of ast.body) {
31
+ if (node.type === 'ImportDeclaration') {
32
+ const sourcePath = node.source.value;
33
+ const actualPath = (0, utils_1.resolveImportPath)(sourcePath, this.resourcePath);
34
+ if (actualPath) {
35
+ this.addDependency(actualPath);
36
+ }
37
+ }
38
+ }
39
+ const scannedTables = (0, utils_1.scanAll)();
32
40
  const localConsts = (0, utils_1.collectLocalConsts)(ast);
33
41
  const resourcePath = this.resourcePath;
34
42
  const importMap = {};
@@ -37,7 +45,6 @@ async function loader(source) {
37
45
  const sourcePath = node.source.value;
38
46
  const actualPath = (0, utils_1.resolveImportPath)(sourcePath, resourcePath);
39
47
  if (actualPath) {
40
- loaderContext.addDependency(actualPath);
41
48
  node.specifiers.forEach((specifier) => {
42
49
  if (specifier.type === 'ImportSpecifier') {
43
50
  const importedName = specifier.imported
@@ -118,6 +125,11 @@ async function loader(source) {
118
125
  const localCreateStyles = {};
119
126
  const replacements = [];
120
127
  const extractedSheets = [];
128
+ const addSheet = (sheet) => {
129
+ if (!extractedSheets.includes(sheet)) {
130
+ extractedSheets.push(sheet);
131
+ }
132
+ };
121
133
  const processedDecls = new Set();
122
134
  const idSpans = new Set();
123
135
  const excludedSpans = new Set();
@@ -152,7 +164,7 @@ async function loader(source) {
152
164
  if (!isProduction) {
153
165
  (0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
154
166
  records.forEach((r) => {
155
- extractedSheets.push(r.sheet);
167
+ addSheet(r.sheet);
156
168
  });
157
169
  }
158
170
  const atomMap = {};
@@ -313,7 +325,7 @@ async function loader(source) {
313
325
  const records = (0, utils_1.getStyleRecords)(key, style, 2);
314
326
  if (!isProduction) {
315
327
  (0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
316
- records.forEach((r) => extractedSheets.push(r.sheet));
328
+ records.forEach((r) => addSheet(r.sheet));
317
329
  }
318
330
  }
319
331
  });
@@ -347,7 +359,7 @@ async function loader(source) {
347
359
  const records = (0, utils_1.getStyleRecords)(propName, style, 2);
348
360
  if (!isProduction) {
349
361
  (0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
350
- records.forEach((r) => extractedSheets.push(r.sheet));
362
+ records.forEach((r) => addSheet(r.sheet));
351
363
  }
352
364
  const atomMap = {};
353
365
  records.forEach((r) => (atomMap[r.key] = r.hash));
@@ -560,7 +572,7 @@ async function loader(source) {
560
572
  const hash = (0, zss_engine_1.genBase36Hash)(baseStyle, 1, 8);
561
573
  const records = (0, utils_1.getStyleRecords)(hash, baseStyle, 2);
562
574
  if (!isProduction) {
563
- records.forEach((r) => extractedSheets.push(r.sheet));
575
+ records.forEach((r) => addSheet(r.sheet));
564
576
  }
565
577
  const className = records.map((r) => r.hash).join(' ');
566
578
  replacements.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/turbopack-loader",
3
- "version": "6.0.1",
3
+ "version": "6.0.2",
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.0.1"
25
+ "@plumeria/utils": "^6.0.2"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@swc/core": "1.15.8",