From 8d53df517a882b2ece249bf1369aadc055c28c8a Mon Sep 17 00:00:00 2001 From: Lars Kappert Date: Thu, 14 Nov 2024 13:51:36 +0100 Subject: [PATCH] Use entire body of diff --git a/packages/knip/fixtures/compilers/enum.ts b/packages/knip/fixtures/compilers/enum.ts new file mode 100644 index 000000000..0136eae62 --- /dev/null +++ b/packages/knip/fixtures/compilers/enum.ts @@ -0,0 +1,3 @@ +export enum Enum { + Member = 'member', +} diff --git a/packages/knip/fixtures/compilers/index.ts b/packages/knip/fixtures/compilers/index.ts index ed638b459..637f40adb 100644 --- a/packages/knip/fixtures/compilers/index.ts +++ b/packages/knip/fixtures/compilers/index.ts @@ -1,2 +1,6 @@ import identifier from './module.mdx'; +import Component from './Component.vue'; +import { createApp } from 'vue'; + identifier; +createApp(Component); diff --git a/packages/knip/fixtures/compilers/package.json b/packages/knip/fixtures/compilers/package.json index 2a279d6b4..ffa18ad89 100644 --- a/packages/knip/fixtures/compilers/package.json +++ b/packages/knip/fixtures/compilers/package.json @@ -1,6 +1,7 @@ { "name": "compilers", "devDependencies": { - "@mdx-js/mdx": "*" + "@mdx-js/mdx": "*", + "vue": "*" } } diff --git a/packages/knip/fixtures/compilers/tsconfig.json b/packages/knip/fixtures/compilers/tsconfig.json index 560b59325..353b4bdd0 100644 --- a/packages/knip/fixtures/compilers/tsconfig.json +++ b/packages/knip/fixtures/compilers/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { - "target": "ES2015" + "target": "ES2015", + "jsx": "preserve" } } diff --git a/packages/knip/src/compilers/compilers.ts b/packages/knip/src/compilers/compilers.ts index 7507c6280..7b0e19b19 100644 --- a/packages/knip/src/compilers/compilers.ts +++ b/packages/knip/src/compilers/compilers.ts @@ -1,9 +1,10 @@ import type { SyncCompilerFn } from './types.js'; -const scriptExtractor = /]*>([\s\S]*?)<\/script>/gm; -export const importMatcher = /import[^'"]+['"]([^'"]+)['"]/g; export const fencedCodeBlockMatcher = /```[\s\S]*?```/g; +// Extract imports from body of