Skip to content

Commit 302412f

Browse files
committed
Simplify import-transform plugin
Removed constants exception and cleaned up code by using template strings for path construction and removing unnecessary fallbacks.
1 parent 903cd4a commit 302412f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

.config/vitest-plugins/import-transform.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ export function createImportTransformPlugin(
2424
async resolveId(source: string, importer: string | undefined, options) {
2525
// Handle @socketsecurity/registry imports.
2626
if (source.startsWith('@socketsecurity/registry')) {
27+
const subpath = source.replace('@socketsecurity/registry', '')
2728
// Transform: @socketsecurity/registry → /abs/path/registry/src/index.ts
2829
// Transform: @socketsecurity/registry/lib/foo → /abs/path/registry/src/lib/foo.ts
29-
const subpath = source.replace('@socketsecurity/registry', '') || ''
3030
const targetPath = subpath
31-
? resolve(actualProjectRoot, 'registry/src', subpath + '.ts')
31+
? resolve(actualProjectRoot, `registry/src${subpath}.ts`)
3232
: resolve(actualProjectRoot, 'registry/src/index.ts')
3333
return { id: targetPath }
3434
}

0 commit comments

Comments
 (0)