Skip to content

Commit

Permalink
remove tsconfig target warning due to complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jun 23, 2023
1 parent ecb33a3 commit d6056b8
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 55 deletions.
31 changes: 0 additions & 31 deletions internal/bundler_tests/bundler_tsconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1471,37 +1471,6 @@ func TestTsconfigUnrecognizedTargetWarning(t *testing.T) {
})
}

func TestTsconfigIgnoredTargetWarning(t *testing.T) {
tsconfig_suite.expectBundled(t, bundled{
files: map[string]string{
"/Users/user/project/src/entry.ts": `
import "./a"
import "b"
`,
"/Users/user/project/src/a/index.ts": ``,
"/Users/user/project/src/a/tsconfig.json": `{
"compilerOptions": {
"target": "es5"
}
}`,
"/Users/user/project/src/node_modules/b/index.ts": ``,
"/Users/user/project/src/node_modules/b/tsconfig.json": `{
"compilerOptions": {
"target": "es5"
}
}`,
},
entryPaths: []string{"/Users/user/project/src/entry.ts"},
options: config.Options{
Mode: config.ModeBundle,
AbsOutputFile: "/Users/user/project/out.js",
},
expectedScanLog: `Users/user/project/src/a/tsconfig.json: WARNING: "tsconfig.json" does not affect esbuild's own target setting
NOTE: This is because esbuild supports reading from multiple "tsconfig.json" files within a single build, and using different language targets for different files in the same build wouldn't be correct. If you want to set esbuild's language target, you should use esbuild's own global "target" setting such as with "Target: api.ES5".
`,
})
}

func TestTsconfigIgnoredTargetSilent(t *testing.T) {
tsconfig_suite.expectBundled(t, bundled{
files: map[string]string{
Expand Down
4 changes: 0 additions & 4 deletions internal/bundler_tests/snapshots/snapshots_tsconfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,6 @@ TestTsConfigWithStatementStrictTrueAlwaysStrictFalse
TestTsconfigIgnoredTargetSilent
---------- /Users/user/project/out.js ----------

================================================================================
TestTsconfigIgnoredTargetWarning
---------- /Users/user/project/out.js ----------

================================================================================
TestTsconfigImportsNotUsedAsValuesPreserve
---------- /Users/user/project/out.js ----------
Expand Down
1 change: 0 additions & 1 deletion internal/logger/msg_ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ const (
MsgID_TSConfigJSON_InvalidPaths
MsgID_TSConfigJSON_InvalidTarget
MsgID_TSConfigJSON_Missing
MsgID_TSConfigJSON_TargetIgnored
MsgID_TSConfigJSON_LAST // Keep this last

MsgID_END // Keep this at the end (used only for tests)
Expand Down
19 changes: 0 additions & 19 deletions internal/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1261,25 +1261,6 @@ func (r resolverQuery) parseTSConfigFromSource(source logger.Source, visited map
return nil, errParseErrorAlreadyLogged
}

// Warn when people try to set esbuild's target via "tsconfig.json" and esbuild's target is unset
if result.Settings.Target != config.TSTargetUnspecified && r.options.OriginalTargetEnv == "" &&
// Don't warn if the target is "ESNext" since esbuild's target also defaults to "esnext" (so that case is harmless)
result.tsTargetKey.LowerValue != "esnext" && !helpers.IsInsideNodeModules(source.KeyPath.Text) {
var example string
switch logger.API {
case logger.CLIAPI:
example = fmt.Sprintf("--target=%s", result.tsTargetKey.LowerValue)
case logger.JSAPI:
example = fmt.Sprintf("target: '%s'", result.tsTargetKey.LowerValue)
case logger.GoAPI:
example = fmt.Sprintf("Target: api.%s", strings.ToUpper(result.tsTargetKey.LowerValue))
}
tracker := logger.MakeLineColumnTracker(&result.tsTargetKey.Source)
r.log.AddIDWithNotes(logger.MsgID_TSConfigJSON_TargetIgnored, logger.Warning, &tracker, result.tsTargetKey.Range, "\"tsconfig.json\" does not affect esbuild's own target setting",
[]logger.MsgData{{Text: fmt.Sprintf("This is because esbuild supports reading from multiple \"tsconfig.json\" files within a single build, and using different language targets "+
"for different files in the same build wouldn't be correct. If you want to set esbuild's language target, you should use esbuild's own global \"target\" setting such as with %q.", example)}})
}

if result.BaseURL != nil && !r.fs.IsAbs(*result.BaseURL) {
*result.BaseURL = r.fs.Join(fileDir, *result.BaseURL)
}
Expand Down

0 comments on commit d6056b8

Please sign in to comment.