vite-plugin-qingkuai 1.0.26 → 1.0.28

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.cjs CHANGED
@@ -78,11 +78,11 @@ async function attachScopeForStyleSelectors(code, hash, sourceFile, map) {
78
78
  }
79
79
  ]);
80
80
  const ret = await processor.process(code, {
81
- from: sourceFile,
82
81
  map: {
83
- prev: map,
84
- annotation: false
85
- }
82
+ annotation: false,
83
+ prev: map?.version ? map : void 0
84
+ },
85
+ from: sourceFile
86
86
  });
87
87
  const outputMap = ret.map?.toJSON();
88
88
  return {
@@ -163,7 +163,8 @@ function qingkuai(options = {}) {
163
163
  isDev = env.command === "serve";
164
164
  return {
165
165
  define: {
166
- __qk_max_schedule_depth: options.maxScheduleDepth
166
+ __qk__dev: isDev,
167
+ __qk__max_schedule_depth: options.maxScheduleDepth
167
168
  }
168
169
  };
169
170
  },
@@ -408,14 +409,14 @@ Caused by: "${fileId}".`;
408
409
  }
409
410
  const transformWithOxc = vite__namespace.transformWithOxc;
410
411
  const transformWithEsbuild = vite__namespace.transformWithEsbuild;
411
- const tsCompileRes = await (transformWithOxc ?? transformWithEsbuild)(
412
+ const tsTransform = transformWithOxc ?? transformWithEsbuild;
413
+ const tsCompileRes = await tsTransform(
412
414
  compiledCode,
413
415
  id,
414
416
  {
415
417
  sourcemap,
416
- lang: "ts",
417
- loader: "ts",
418
- target: "esnext"
418
+ target: "esnext",
419
+ [transformWithOxc ? "lang" : "loader"]: "ts"
419
420
  },
420
421
  sourcemap ? {
421
422
  version: 3,
@@ -443,9 +444,17 @@ Caused by: "${fileId}".`;
443
444
  };
444
445
  } catch (err) {
445
446
  if (compiler.isCompileError(err)) {
446
- this.error(err.message, err.loc.start.index);
447
+ const location = new linesAndColumns.LinesAndColumns(src).locationForIndex(err.loc.start.index) || void 0;
448
+ this.error({
449
+ loc: location && {
450
+ file: id,
451
+ line: location.line + 1,
452
+ column: location.column
453
+ },
454
+ message: err.message
455
+ });
447
456
  } else if (err.cause && isNumber(err.cause.pos)) {
448
- this.error(err, err.cause.pos);
457
+ this.error({ message: err.message });
449
458
  } else {
450
459
  this.error(
451
460
  "Qingkuai compile result is invalid. Please report this at https://github.com/qingkuai-js/qingkuai/issues and include your .qk source for reproduction."
@@ -509,7 +518,8 @@ Caused by: "${fileId}".`;
509
518
  const qingkuaiConfig = getQingkuaiConfiguration(id);
510
519
  const ret = {
511
520
  interpretiveComments: isUndefined(qingkuaiConfig.interpretiveComments) ? isDev : !!qingkuaiConfig.interpretiveComments,
512
- shorthandDerivedDeclaration: isUndefined(qingkuaiConfig.shorthandDerivedDeclaration) ? true : !!qingkuaiConfig.shorthandDerivedDeclaration,
521
+ allowConstReactive: qingkuaiConfig.allowConstReactive !== false,
522
+ requireReactivityMark: qingkuaiConfig.requireReactivityMark === true,
513
523
  reactivityMode: qingkuaiConfig.reactivityMode === "shallow" ? "shallow" : "reactive"
514
524
  };
515
525
  switch (qingkuaiConfig.whitespace) {
@@ -526,7 +536,7 @@ Caused by: "${fileId}".`;
526
536
  }
527
537
  }
528
538
  switch (qingkuaiConfig.preserveHtmlComments) {
529
- case "all": {
539
+ case "always": {
530
540
  ret.preserveHtmlComments = true;
531
541
  break;
532
542
  }
package/dist/index.js CHANGED
@@ -57,11 +57,11 @@ async function attachScopeForStyleSelectors(code, hash, sourceFile, map) {
57
57
  }
58
58
  ]);
59
59
  const ret = await processor.process(code, {
60
- from: sourceFile,
61
60
  map: {
62
- prev: map,
63
- annotation: false
64
- }
61
+ annotation: false,
62
+ prev: map?.version ? map : void 0
63
+ },
64
+ from: sourceFile
65
65
  });
66
66
  const outputMap = ret.map?.toJSON();
67
67
  return {
@@ -142,7 +142,8 @@ function qingkuai(options = {}) {
142
142
  isDev = env.command === "serve";
143
143
  return {
144
144
  define: {
145
- __qk_max_schedule_depth: options.maxScheduleDepth
145
+ __qk__dev: isDev,
146
+ __qk__max_schedule_depth: options.maxScheduleDepth
146
147
  }
147
148
  };
148
149
  },
@@ -387,14 +388,14 @@ Caused by: "${fileId}".`;
387
388
  }
388
389
  const transformWithOxc = vite.transformWithOxc;
389
390
  const transformWithEsbuild = vite.transformWithEsbuild;
390
- const tsCompileRes = await (transformWithOxc ?? transformWithEsbuild)(
391
+ const tsTransform = transformWithOxc ?? transformWithEsbuild;
392
+ const tsCompileRes = await tsTransform(
391
393
  compiledCode,
392
394
  id,
393
395
  {
394
396
  sourcemap,
395
- lang: "ts",
396
- loader: "ts",
397
- target: "esnext"
397
+ target: "esnext",
398
+ [transformWithOxc ? "lang" : "loader"]: "ts"
398
399
  },
399
400
  sourcemap ? {
400
401
  version: 3,
@@ -422,9 +423,17 @@ Caused by: "${fileId}".`;
422
423
  };
423
424
  } catch (err) {
424
425
  if (isCompileError(err)) {
425
- this.error(err.message, err.loc.start.index);
426
+ const location = new LinesAndColumns(src).locationForIndex(err.loc.start.index) || void 0;
427
+ this.error({
428
+ loc: location && {
429
+ file: id,
430
+ line: location.line + 1,
431
+ column: location.column
432
+ },
433
+ message: err.message
434
+ });
426
435
  } else if (err.cause && isNumber(err.cause.pos)) {
427
- this.error(err, err.cause.pos);
436
+ this.error({ message: err.message });
428
437
  } else {
429
438
  this.error(
430
439
  "Qingkuai compile result is invalid. Please report this at https://github.com/qingkuai-js/qingkuai/issues and include your .qk source for reproduction."
@@ -488,7 +497,8 @@ Caused by: "${fileId}".`;
488
497
  const qingkuaiConfig = getQingkuaiConfiguration(id);
489
498
  const ret = {
490
499
  interpretiveComments: isUndefined(qingkuaiConfig.interpretiveComments) ? isDev : !!qingkuaiConfig.interpretiveComments,
491
- shorthandDerivedDeclaration: isUndefined(qingkuaiConfig.shorthandDerivedDeclaration) ? true : !!qingkuaiConfig.shorthandDerivedDeclaration,
500
+ allowConstReactive: qingkuaiConfig.allowConstReactive !== false,
501
+ requireReactivityMark: qingkuaiConfig.requireReactivityMark === true,
492
502
  reactivityMode: qingkuaiConfig.reactivityMode === "shallow" ? "shallow" : "reactive"
493
503
  };
494
504
  switch (qingkuaiConfig.whitespace) {
@@ -505,7 +515,7 @@ Caused by: "${fileId}".`;
505
515
  }
506
516
  }
507
517
  switch (qingkuaiConfig.preserveHtmlComments) {
508
- case "all": {
518
+ case "always": {
509
519
  ret.preserveHtmlComments = true;
510
520
  break;
511
521
  }
package/package.json CHANGED
@@ -3,13 +3,15 @@
3
3
  "author": "mlgq",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
- "version": "1.0.26",
6
+ "version": "1.0.28",
7
7
  "packageManager": "pnpm@9.9.0",
8
8
  "exports": {
9
9
  ".": {
10
+ "types": "./dist/index.d.ts",
10
11
  "import": "./dist/index.js",
11
12
  "require": "./dist/index.cjs"
12
- }
13
+ },
14
+ "./package.json": "./package.json"
13
15
  },
14
16
  "repository": {
15
17
  "type": "git",
@@ -30,7 +32,7 @@
30
32
  "fs-extra": "^11.3.0",
31
33
  "husky": "^9.1.7",
32
34
  "lint-staged": "^17.3.0",
33
- "qingkuai": "^1.0.83",
35
+ "qingkuai": "^1.0.101",
34
36
  "rimraf": "^6.0.1",
35
37
  "rollup": "^4.38.0",
36
38
  "rollup-plugin-dts": "^6.2.1",