Skip to content

[Bug]: Configure doesn't handle solution style tsconfigs #835

@walkerburgin

Description

@walkerburgin

What happened?

I think this is probably a combination of a couple different bugs and missing features.

I'm trying to get configure working with "solution style" tsconfig.json files, largely motivated by tsserver performance in the IDE. For example: https://github.com/walkerburgin/solution-ts_config-repro

.
├── tsconfig.json
├── tsconfig.base.json
└── packages
    └── foo-lib
        ├── BUILD.bazel
        ├── tsconfig.base.json
        ├── tsconfig.json
        ├── tsconfig.main.json
        └── tsconfig.test.json

Where //packages/foo-lib:tsconfig.json looks like this:

{
    "references": [
        { "path": "./tsconfig.main.json" },
        { "path": "./tsconfig.test.json" }
    ]
}

//packages/foo-lib:tsconfig.main.json looks like this:

{
    "extends": "./tsconfig.base.json",
    "include": ["src"],
    "exclude": ["src/**/__tests__"],
    "references": []
}

//packages/foo-lib:tsconfig.test.json looks like this:

{
    "extends": "./tsconfig.base.json",
    "include": ["src/**/__tests__"],
    "references": [
        { "path": "./tsconfig.main.json" }
    ]
}

And //packages/foo-lib:tsconfig.base.json looks like this:

{
    "extends": "../../tsconfig.base.json",
    "compilerOptions": {
        "outDir": "dist",
        "rootDir": "src",
        "rootDirs": ["src", "dist"]
    }
}

If you run bazel configure in that repository you'll get an error that looks like this:

➜  solution-ts_config-repro git:(master) ✗ bazel configure
Updating BUILD files for javascript
Failed to validate dependencies for target "//packages/foo-app:tsconfig":

Import "packages/foo-app/tsconfig.main.json" from "packages/foo-app/tsconfig.json" is an unknown dependency. Possible solutions:
	1. Instruct Gazelle to resolve to a known dependency using a directive:
		# aspect:resolve [src-lang] js import-string label
		   or
		# aspect:js_resolve import-string-glob label
	2. Ignore the dependency using the '# aspect:js_ignore_imports packages/foo-app/tsconfig.main.json' directive.
	3. Disable Gazelle resolution validation using '# aspect:js_validate_import_statements off'

Import "packages/foo-app/tsconfig.test.json" from "packages/foo-app/tsconfig.json" is an unknown dependency. Possible solutions:
	1. Instruct Gazelle to resolve to a known dependency using a directive:
		# aspect:resolve [src-lang] js import-string label
		   or
		# aspect:js_resolve import-string-glob label
	2. Ignore the dependency using the '# aspect:js_ignore_imports packages/foo-app/tsconfig.test.json' directive.
	3. Disable Gazelle resolution validation using '# aspect:js_validate_import_statements off'

I think the first issue is that this assumes references always point to a project directory instead of to a specific file:

	for _, reference := range tsconfig.References {
		// TODO: how do we know the referenced tsconfig filename?
		referenceFile := cfg.tsconfigName

		imports = append(imports, ImportStatement{
			ImportSpec: resolve.ImportSpec{
				Lang: LanguageName,
				Imp:  path.Join(reference, referenceFile),
			},
			ImportPath: reference,
			SourcePath: SourcePath,
		})
	}

If I change that to something like this…

	for _, reference := range tsconfig.References {
		var referenceFile string
		if strings.HasSuffix(reference, ".json") {
			referenceFile = reference
		} else {
			referenceFile = path.Join(reference, cfg.tsconfigName)
		}

		imports = append(imports, ImportStatement{
			ImportSpec: resolve.ImportSpec{
				Lang: LanguageName,
				Imp:  referenceFile,
			},
			ImportPath: reference,
			SourcePath: SourcePath,
		})
	}

I no longer get any errors, but it doesn't generate the output I'm looking for either:

Image

Related:

This tsconfig structure is similar to what Airtable describes in their monorepo here.

Version

Development (host) and target OS/architectures: OSX

Output of bazel --version:

aspect 2025.08.18+7c3bef4ee

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

bazel_dep(name = "aspect_bazel_lib", version = "2.14.0")
bazel_dep(name = "aspect_rules_js", version = "2.2.0")
bazel_dep(name = "aspect_rules_ts", version = "3.5.0")

Language(s) and/or frameworks involved:

  • TypeScript

How to reproduce

See standalone repro: https://github.com/walkerburgin/solution-ts_config-repro

Any other information?

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions