Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions webworker/import-eval-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ export async function importEvalPath(
return
}

// Check if this matches a tsconfig path pattern but failed to resolve
// If so, throw an error instead of falling back to npm
const tsConfig = getTsConfig(ctx.fsMap)
if (matchesTsconfigPathPattern(importName, tsConfig)) {
throw new Error(
`Import "${importName}" matches a tsconfig path alias but could not be resolved to an existing file${opts.cwd ? ` from directory "${opts.cwd}"` : ""}`,
)
}

// Try to resolve from node_modules
const resolvedNodeModulePath = resolveNodeModule(
importName,
Expand All @@ -78,15 +87,6 @@ export async function importEvalPath(
return importSnippet(importName, ctx, depth)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Tsconfig alias check now blocks built‑in snippets

The new path‑alias check runs before the @tsci/ snippet handling. If a project has a wildcard alias such as "@*": ["packages/*"] (common in monorepos to target all scoped packages), matchesTsconfigPathPattern will treat @tsci/... as an alias hit and the function now throws before reaching importSnippet. In previous behavior snippets were imported before the alias guard, so they worked even with broad aliases. This change will cause the evaluator to throw on any @tsci/* import whenever a broad alias exists, breaking snippet resolution for those projects.

Useful? React with 👍 / 👎.

}

// Check if this matches a tsconfig path pattern but failed to resolve
// If so, throw an error instead of falling back to npm
const tsConfig = getTsConfig(ctx.fsMap)
if (matchesTsconfigPathPattern(importName, tsConfig)) {
throw new Error(
`Import "${importName}" matches a tsconfig path alias but could not be resolved to an existing file${opts.cwd ? ` from directory "${opts.cwd}"` : ""}`,
)
}

if (!importName.startsWith(".") && !importName.startsWith("/")) {
return importNpmPackage(importName, ctx, depth)
}
Expand Down