Skip to content

Commit

Permalink
fail the build if --tsconfig is missing (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Aug 13, 2020
1 parent 9a6bd67 commit a7bfebe
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

* Add an error message for a missing `--tsconfig` file ([#330](https://github.com/evanw/esbuild/issues/330))

The `--tsconfig` flag that was added in version 0.6.1 didn't report an error if the provided file doesn't actually exist. This release makes doing this an error that will fail the build.

## 0.6.22

* The bell character is now escaped
Expand Down
15 changes: 15 additions & 0 deletions internal/bundler/bundler_tsconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,21 @@ func TestTsconfigJsonOverrideNodeModules(t *testing.T) {
})
}

func TestTsconfigJsonOverrideInvalid(t *testing.T) {
tsconfig_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.ts": ``,
},
entryPaths: []string{"/entry.ts"},
options: config.Options{
IsBundling: true,
AbsOutputFile: "/out.js",
TsConfigOverride: "/this/file/doesn't/exist/tsconfig.json",
},
expectedScanLog: "error: Cannot find tsconfig file \"/this/file/doesn't/exist/tsconfig.json\"\n",
})
}

func TestTsconfigJsonNodeModulesImplicitFile(t *testing.T) {
tsconfig_suite.expectBundled(t, bundled{
files: map[string]string{
Expand Down
6 changes: 5 additions & 1 deletion internal/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,11 @@ func (r *resolver) dirInfoUncached(path string) *dirInfo {
}
} else if parentInfo == nil {
// If there is a tsconfig.json override, mount it at the root directory
info.tsConfigJson, _ = r.parseJsTsConfig(forceTsConfig, make(map[string]bool))
var status parseStatus
info.tsConfigJson, status = r.parseJsTsConfig(forceTsConfig, make(map[string]bool))
if status == parseReadFailure {
r.log.AddError(nil, ast.Loc{}, fmt.Sprintf("Cannot find tsconfig file %q", r.PrettyPath(forceTsConfig)))
}
}

// Propagate the enclosing tsconfig.json from the parent directory
Expand Down

0 comments on commit a7bfebe

Please sign in to comment.