Skip to content

Commit

Permalink
fix #2723: skip import.meta warnings in packages
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Dec 8, 2022
1 parent c189b30 commit a4d7d97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/js_parser/js_parser.go
Expand Up @@ -12293,7 +12293,11 @@ func (p *parser) visitExprInOut(expr js_ast.Expr, in exprIn) (js_ast.Expr, exprO
p.markSyntaxFeature(compat.ImportMeta, r)
} else if p.options.mode != config.ModePassThrough && !p.options.outputFormat.KeepES6ImportExportSyntax() {
r := logger.Range{Loc: expr.Loc, Len: e.RangeLen}
p.log.AddIDWithNotes(logger.MsgID_JS_EmptyImportMeta, logger.Warning, &p.tracker, r, fmt.Sprintf(
kind := logger.Warning
if p.suppressWarningsAboutWeirdCode || p.fnOrArrowDataVisit.tryBodyCount > 0 {
kind = logger.Debug
}
p.log.AddIDWithNotes(logger.MsgID_JS_EmptyImportMeta, kind, &p.tracker, r, fmt.Sprintf(
"\"import.meta\" is not available with the %q output format and will be empty", p.options.outputFormat.String()),
[]logger.MsgData{{Text: "You need to set the output format to \"esm\" for \"import.meta\" to work correctly."}})
}
Expand Down
6 changes: 5 additions & 1 deletion internal/js_parser/js_parser_lower.go
Expand Up @@ -131,7 +131,11 @@ func (p *parser) markSyntaxFeature(feature compat.JSFeature, r logger.Range) (di

case compat.ImportMeta:
// This can't be polyfilled
p.log.AddIDWithNotes(logger.MsgID_JS_EmptyImportMeta, logger.Warning, &p.tracker, r, fmt.Sprintf(
kind := logger.Warning
if p.suppressWarningsAboutWeirdCode || p.fnOrArrowDataVisit.tryBodyCount > 0 {
kind = logger.Debug
}
p.log.AddIDWithNotes(logger.MsgID_JS_EmptyImportMeta, kind, &p.tracker, r, fmt.Sprintf(
"\"import.meta\" is not available in %s and will be empty", where), notes)
return

Expand Down

0 comments on commit a4d7d97

Please sign in to comment.