Skip to content

Commit

Permalink
fix #1489: do not warn about "es3" in node_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Aug 4, 2021
1 parent f68030c commit cfcf8cf
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
30 changes: 30 additions & 0 deletions internal/bundler/bundler_tsconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1269,3 +1269,33 @@ func TestTsconfigUseDefineForClassFieldsESNext(t *testing.T) {
},
})
}

func TestTsconfigUnrecognizedTargetWarning(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": "es3"
}
}`,
"/Users/user/project/src/node_modules/b/index.ts": ``,
"/Users/user/project/src/node_modules/b/tsconfig.json": `{
"compilerOptions": {
"target": "es3"
}
}`,
},
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: Unrecognized target environment "es3"
`,
})
}
4 changes: 4 additions & 0 deletions internal/bundler/snapshots/snapshots_tsconfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ TestTsconfigTargetIgnored
// Users/user/project/src/entry.ts
x = 123n;

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

================================================================================
TestTsconfigUseDefineForClassFieldsES2020
---------- /Users/user/project/out.js ----------
Expand Down
7 changes: 5 additions & 2 deletions internal/resolver/tsconfig_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/evanw/esbuild/internal/cache"
"github.com/evanw/esbuild/internal/compat"
"github.com/evanw/esbuild/internal/config"
"github.com/evanw/esbuild/internal/helpers"
"github.com/evanw/esbuild/internal/js_ast"
"github.com/evanw/esbuild/internal/js_lexer"
"github.com/evanw/esbuild/internal/js_parser"
Expand Down Expand Up @@ -141,8 +142,10 @@ func ParseTSConfigJSON(
// Nothing to do in this case
default:
ok = false
log.AddRangeWarning(&tracker, r,
fmt.Sprintf("Unrecognized target environment %q", value))
if !helpers.IsInsideNodeModules(source.KeyPath.Text) {
log.AddRangeWarning(&tracker, r,
fmt.Sprintf("Unrecognized target environment %q", value))
}
}

// These feature restrictions are merged with esbuild's own restrictions
Expand Down

0 comments on commit cfcf8cf

Please sign in to comment.