Skip to content

Commit 7973dfd

Browse files
committed
fix(lint): avoid static file URL resolution
1 parent 45ba509 commit 7973dfd

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

packages/lint/linthost/config.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,11 +1268,12 @@ func fileURL(location string) string {
12681268

12691269
// typeScriptConfigLoaderSource returns the TypeScript source of the ephemeral
12701270
// loader script that ttsx executes to evaluate a TypeScript lint config file.
1271-
// `importLiteral` is a JSON-encoded relative import path (e.g. `"./lint.config.ts"`)
1272-
// that is spliced directly into the `import * as` statement, so it must
1273-
// already be a valid JSON string (produced by json.Marshal).
1271+
// `importLiteral` is a JSON-encoded file URL (produced by json.Marshal). It is
1272+
// assigned to a variable before `import(configUrl)` so tsgo does not try to
1273+
// statically resolve the file URL during the loader build.
12741274
func typeScriptConfigLoaderSource(importLiteral string) string {
1275-
return fmt.Sprintf(`const importedConfig = await import(%s);
1275+
return fmt.Sprintf(`const configUrl = %s;
1276+
const importedConfig = await import(configUrl);
12761277
12771278
declare const process: {
12781279
stdout: { write(value: string): void };

packages/lint/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ function readCjsConfigPlugins(configPath: string): ConfigPluginEntry[] {
394394
// collects every `plugins` map, and serialises each plugin's `source` field
395395
// as a JSON array for the parent process to parse — avoiding the need to
396396
// serialise arbitrary in-memory plugin objects across the process boundary.
397-
const TTSX_EXTRACTOR_SCRIPT = `const importedConfig = await import(%CONFIG_IMPORT%);
397+
// The URL lives in a variable so tsgo does not statically resolve it.
398+
const TTSX_EXTRACTOR_SCRIPT = `const configUrl = %CONFIG_IMPORT%;
399+
const importedConfig = await import(configUrl);
398400
399401
declare const process: {
400402
cwd(): string;

0 commit comments

Comments
 (0)