Skip to content

Commit c94ad6c

Browse files
committed
explicit pre-release version error (#2766, #2760)
1 parent 0fea6ae commit c94ad6c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pkg/api/api_impl.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ func validateEngine(value EngineName) compat.Engine {
285285
}
286286

287287
var versionRegex = regexp.MustCompile(`^([0-9]+)(?:\.([0-9]+))?(?:\.([0-9]+))?$`)
288+
var preReleaseVersionRegex = regexp.MustCompile(`^([0-9]+)(?:\.([0-9]+))?(?:\.([0-9]+))?-`)
288289

289290
func validateFeatures(log logger.Log, target Target, engines []Engine) (config.TargetFromAPI, compat.JSFeature, compat.CSSFeature, string) {
290291
if target == DefaultTarget && len(engines) == 0 {
@@ -337,7 +338,16 @@ func validateFeatures(log logger.Log, target Target, engines []Engine) (config.T
337338
}
338339
}
339340

340-
log.AddError(nil, logger.Range{}, fmt.Sprintf("Invalid version: %q", engine.Version))
341+
text := "All version numbers passed to esbuild must be in the format \"X\", \"X.Y\", or \"X.Y.Z\" where X, Y, and Z are non-negative integers."
342+
343+
// Our internal version-to-feature database only includes version triples.
344+
// We don't have any data on pre-release versions, so we don't accept them.
345+
if preReleaseVersionRegex.MatchString(engine.Version) {
346+
text += " Pre-release versions are not supported and cannot be used."
347+
}
348+
349+
log.AddErrorWithNotes(nil, logger.Range{}, fmt.Sprintf("Invalid version: %q", engine.Version),
350+
[]logger.MsgData{{Text: text}})
341351
}
342352

343353
for engine, version := range constraints {

0 commit comments

Comments
 (0)