@mutineerjs/mutineer 0.2.0 → 0.2.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.
@@ -9,4 +9,4 @@ import type { MutationVariant } from './types.js';
9
9
  * @returns Array of unique mutations (with mutated full source), up to `max` if specified
10
10
  * @throws Error if max is provided and <= 0
11
11
  */
12
- export declare function mutateVueSfcScriptSetup(filename: string, code: string, include?: readonly string[], exclude?: readonly string[], max?: number): readonly MutationVariant[];
12
+ export declare function mutateVueSfcScriptSetup(filename: string, code: string, include?: readonly string[], exclude?: readonly string[], max?: number): Promise<readonly MutationVariant[]>;
package/dist/core/sfc.js CHANGED
@@ -1,4 +1,3 @@
1
- import { parse } from '@vue/compiler-sfc';
2
1
  import MagicString from 'magic-string';
3
2
  import { getFilteredRegistry } from './variant-utils.js';
4
3
  /**
@@ -11,11 +10,12 @@ import { getFilteredRegistry } from './variant-utils.js';
11
10
  * @returns Array of unique mutations (with mutated full source), up to `max` if specified
12
11
  * @throws Error if max is provided and <= 0
13
12
  */
14
- export function mutateVueSfcScriptSetup(filename, code, include, exclude, max) {
13
+ export async function mutateVueSfcScriptSetup(filename, code, include, exclude, max) {
15
14
  // Input validation
16
15
  if (max !== undefined && max <= 0) {
17
16
  throw new Error(`max must be a positive number, got: ${max}`);
18
17
  }
18
+ const { parse } = await import('@vue/compiler-sfc');
19
19
  const sfc = parse(code, { filename });
20
20
  const scriptSetup = sfc.descriptor.scriptSetup;
21
21
  if (!scriptSetup)
@@ -31,7 +31,7 @@ export async function enumerateVariantsForTarget(root, t, include, exclude, max)
31
31
  // Auto-detect kind from file extension if not specified
32
32
  const kind = explicitKind ?? (abs.endsWith('.vue') ? 'vue:script-setup' : 'module');
33
33
  const list = kind === 'vue:script-setup'
34
- ? mutateVueSfcScriptSetup(abs, code, includeArr, excludeArr, max)
34
+ ? await mutateVueSfcScriptSetup(abs, code, includeArr, excludeArr, max)
35
35
  : mutateModuleSource(code, includeArr, excludeArr, max);
36
36
  return list.map((v, i) => ({
37
37
  id: `${path.basename(abs)}#${i}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mutineerjs/mutineer",
3
- "version": "v0.2.0",
3
+ "version": "v0.2.1",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "bin": {