Skip to content

Commit

Permalink
internal minify flags now match external flags
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Feb 2, 2022
1 parent 43a7ce6 commit eba56ee
Show file tree
Hide file tree
Showing 29 changed files with 309 additions and 309 deletions.
10 changes: 5 additions & 5 deletions internal/bundler/bundler.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ func parseFile(args parseArgs) {

case config.LoaderCSS:
ast := args.caches.CSSCache.Parse(args.log, source, css_parser.Options{
MangleSyntax: args.options.MangleSyntax,
RemoveWhitespace: args.options.RemoveWhitespace,
MinifySyntax: args.options.MinifySyntax,
MinifyWhitespace: args.options.MinifyWhitespace,
UnsupportedCSSFeatures: args.options.UnsupportedCSSFeatures,
OriginalTargetEnv: args.options.OriginalTargetEnv,
})
Expand Down Expand Up @@ -2326,7 +2326,7 @@ func (b *Bundle) generateMetadataJSON(results []graph.OutputFile, allReachableFi
}

type runtimeCacheKey struct {
MangleSyntax bool
MinifySyntax bool
MinifyIdentifiers bool
ES6 bool
}
Expand All @@ -2341,7 +2341,7 @@ var globalRuntimeCache runtimeCache
func (cache *runtimeCache) parseRuntime(options *config.Options) (source logger.Source, runtimeAST js_ast.AST, ok bool) {
key := runtimeCacheKey{
// All configuration options that the runtime code depends on must go here
MangleSyntax: options.MangleSyntax,
MinifySyntax: options.MinifySyntax,
MinifyIdentifiers: options.MinifyIdentifiers,
ES6: runtime.CanUseES6(options.UnsupportedJSFeatures),
}
Expand Down Expand Up @@ -2375,7 +2375,7 @@ func (cache *runtimeCache) parseRuntime(options *config.Options) (source logger.
log := logger.NewDeferLog(logger.DeferLogAll)
runtimeAST, ok = js_parser.Parse(log, source, js_parser.OptionsFromConfig(&config.Options{
// These configuration options must only depend on the key
MangleSyntax: key.MangleSyntax,
MinifySyntax: key.MinifySyntax,
MinifyIdentifiers: key.MinifyIdentifiers,
UnsupportedJSFeatures: compat.UnsupportedJSFeatures(
map[compat.Engine][]int{compat.ES: {constraint}}),
Expand Down
22 changes: 11 additions & 11 deletions internal/bundler/bundler_dce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ func TestDeadCodeFollowingJump(t *testing.T) {
options: config.Options{
Mode: config.ModeBundle,
AbsOutputFile: "/out.js",
MangleSyntax: true,
MinifySyntax: true,
},
})
}
Expand Down Expand Up @@ -1427,7 +1427,7 @@ func TestRemoveTrailingReturn(t *testing.T) {
options: config.Options{
Mode: config.ModeBundle,
AbsOutputFile: "/out.js",
MangleSyntax: true,
MinifySyntax: true,
OutputFormat: config.FormatESModule,
},
})
Expand Down Expand Up @@ -1719,7 +1719,7 @@ func TestDCETypeOfEqualsStringMangle(t *testing.T) {
options: config.Options{
Mode: config.ModeBundle,
OutputFormat: config.FormatIIFE,
MangleSyntax: true,
MinifySyntax: true,
AbsOutputFile: "/out.js",
},
})
Expand Down Expand Up @@ -1843,7 +1843,7 @@ func TestRemoveUnusedImports(t *testing.T) {
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModePassThrough,
MangleSyntax: true,
MinifySyntax: true,
AbsOutputFile: "/out.js",
},
})
Expand All @@ -1864,7 +1864,7 @@ func TestRemoveUnusedImportsEval(t *testing.T) {
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModePassThrough,
MangleSyntax: true,
MinifySyntax: true,
AbsOutputFile: "/out.js",
},
})
Expand All @@ -1888,7 +1888,7 @@ func TestRemoveUnusedImportsEvalTS(t *testing.T) {
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModePassThrough,
MangleSyntax: true,
MinifySyntax: true,
AbsOutputFile: "/out.js",
},
})
Expand Down Expand Up @@ -2048,7 +2048,7 @@ func TestTreeShakingLoweredClassStaticFieldMinified(t *testing.T) {
Mode: config.ModeBundle,
AbsOutputDir: "/out",
UnsupportedJSFeatures: compat.ClassField,
MangleSyntax: true,
MinifySyntax: true,
},
})
}
Expand Down Expand Up @@ -2255,7 +2255,7 @@ func TestInlineIdentityFunctionCalls(t *testing.T) {
options: config.Options{
Mode: config.ModeBundle,
AbsOutputDir: "/out",
MangleSyntax: true,
MinifySyntax: true,
},
})
}
Expand Down Expand Up @@ -2390,7 +2390,7 @@ func TestInlineEmptyFunctionCalls(t *testing.T) {
options: config.Options{
Mode: config.ModeBundle,
AbsOutputDir: "/out",
MangleSyntax: true,
MinifySyntax: true,
},
})
}
Expand Down Expand Up @@ -2461,7 +2461,7 @@ func TestInlineFunctionCallBehaviorChanges(t *testing.T) {
options: config.Options{
Mode: config.ModePassThrough,
AbsOutputDir: "/out",
MangleSyntax: true,
MinifySyntax: true,
},
})
}
Expand All @@ -2481,7 +2481,7 @@ func TestInlineFunctionCallForInitDecl(t *testing.T) {
options: config.Options{
Mode: config.ModeBundle,
AbsOutputDir: "/out",
MangleSyntax: true,
MinifySyntax: true,
},
})
}
38 changes: 19 additions & 19 deletions internal/bundler/bundler_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ func TestMinifiedDynamicImportWithExpressionCJS(t *testing.T) {
Mode: config.ModeConvertFormat,
OutputFormat: config.FormatCommonJS,
AbsOutputFile: "/out.js",
RemoveWhitespace: true,
MinifyWhitespace: true,
},
})
}
Expand Down Expand Up @@ -1358,7 +1358,7 @@ func TestRequireFSNodeMinify(t *testing.T) {
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModeBundle,
RemoveWhitespace: true,
MinifyWhitespace: true,
OutputFormat: config.FormatCommonJS,
AbsOutputFile: "/out.js",
Platform: config.PlatformNode,
Expand Down Expand Up @@ -1560,8 +1560,8 @@ func TestMinifiedBundleES6(t *testing.T) {
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModeBundle,
MangleSyntax: true,
RemoveWhitespace: true,
MinifySyntax: true,
MinifyWhitespace: true,
MinifyIdentifiers: true,
AbsOutputFile: "/out.js",
},
Expand All @@ -1587,8 +1587,8 @@ func TestMinifiedBundleCommonJS(t *testing.T) {
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModeBundle,
MangleSyntax: true,
RemoveWhitespace: true,
MinifySyntax: true,
MinifyWhitespace: true,
MinifyIdentifiers: true,
AbsOutputFile: "/out.js",
},
Expand All @@ -1605,7 +1605,7 @@ func TestMinifiedBundleEndingWithImportantSemicolon(t *testing.T) {
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModeBundle,
RemoveWhitespace: true,
MinifyWhitespace: true,
OutputFormat: config.FormatIIFE,
AbsOutputFile: "/out.js",
},
Expand Down Expand Up @@ -2658,9 +2658,9 @@ func TestMinifyNestedLabelsNoBundle(t *testing.T) {
},
entryPaths: []string{"/entry.js"},
options: config.Options{
RemoveWhitespace: true,
MinifyWhitespace: true,
MinifyIdentifiers: true,
MangleSyntax: true,
MinifySyntax: true,
AbsOutputFile: "/out.js",
},
})
Expand Down Expand Up @@ -2755,8 +2755,8 @@ func TestUseStrictDirectiveMinifyNoBundle(t *testing.T) {
},
entryPaths: []string{"/entry.js"},
options: config.Options{
MangleSyntax: true,
RemoveWhitespace: true,
MinifySyntax: true,
MinifyWhitespace: true,
AbsOutputFile: "/out.js",
},
})
Expand Down Expand Up @@ -4384,7 +4384,7 @@ func TestKeepNamesTreeShaking(t *testing.T) {
Mode: config.ModeBundle,
AbsOutputFile: "/out.js",
KeepNames: true,
MangleSyntax: true,
MinifySyntax: true,
},
})
}
Expand Down Expand Up @@ -4474,7 +4474,7 @@ func TestConstWithLet(t *testing.T) {
options: config.Options{
Mode: config.ModeBundle,
AbsOutputFile: "/out.js",
MangleSyntax: true,
MinifySyntax: true,
},
})
}
Expand All @@ -4495,7 +4495,7 @@ func TestConstWithLetNoBundle(t *testing.T) {
options: config.Options{
Mode: config.ModePassThrough,
AbsOutputFile: "/out.js",
MangleSyntax: true,
MinifySyntax: true,
},
})
}
Expand Down Expand Up @@ -4874,7 +4874,7 @@ func TestQuotedPropertyMangle(t *testing.T) {
Mode: config.ModeBundle,
OutputFormat: config.FormatCommonJS,
AbsOutputDir: "/out",
MangleSyntax: true,
MinifySyntax: true,
ExternalSettings: config.ExternalSettings{
PreResolve: config.ExternalMatchers{Exact: map[string]bool{
"ext": true,
Expand Down Expand Up @@ -4976,7 +4976,7 @@ func TestStrictModeNestedFnDeclKeepNamesVariableInliningIssue1552(t *testing.T)
Mode: config.ModePassThrough,
AbsOutputDir: "/out",
KeepNames: true,
MangleSyntax: true,
MinifySyntax: true,
},
})
}
Expand Down Expand Up @@ -5114,7 +5114,7 @@ func TestMinifyIdentifiersImportPathFrequencyAnalysis(t *testing.T) {
options: config.Options{
Mode: config.ModeBundle,
AbsOutputDir: "/out",
RemoveWhitespace: true,
MinifyWhitespace: true,
MinifyIdentifiers: true,
},
})
Expand Down Expand Up @@ -5186,7 +5186,7 @@ func TestNamedFunctionExpressionArgumentCollision(t *testing.T) {
options: config.Options{
Mode: config.ModePassThrough,
AbsOutputDir: "/out",
MangleSyntax: true,
MinifySyntax: true,
},
})
}
Expand Down Expand Up @@ -5414,7 +5414,7 @@ func TestManglePropsMinify(t *testing.T) {
AbsOutputDir: "/out",
MangleProps: regexp.MustCompile("_$"),
MinifyIdentifiers: true,
MangleSyntax: true,
MinifySyntax: true,
},
})
}
Expand Down
6 changes: 3 additions & 3 deletions internal/bundler/bundler_importstar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func TestImportStarMangleNoBundleUnused(t *testing.T) {
},
entryPaths: []string{"/entry.js"},
options: config.Options{
MangleSyntax: true,
MinifySyntax: true,
AbsOutputFile: "/out.js",
},
})
Expand All @@ -436,7 +436,7 @@ func TestImportStarMangleNoBundleCapture(t *testing.T) {
},
entryPaths: []string{"/entry.js"},
options: config.Options{
MangleSyntax: true,
MinifySyntax: true,
AbsOutputFile: "/out.js",
},
})
Expand All @@ -453,7 +453,7 @@ func TestImportStarMangleNoBundleNoCapture(t *testing.T) {
},
entryPaths: []string{"/entry.js"},
options: config.Options{
MangleSyntax: true,
MinifySyntax: true,
AbsOutputFile: "/out.js",
},
})
Expand Down
6 changes: 3 additions & 3 deletions internal/bundler/bundler_importstar_ts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func TestTSImportStarMangleNoBundleUnused(t *testing.T) {
},
entryPaths: []string{"/entry.ts"},
options: config.Options{
MangleSyntax: true,
MinifySyntax: true,
AbsOutputFile: "/out.js",
},
})
Expand All @@ -436,7 +436,7 @@ func TestTSImportStarMangleNoBundleCapture(t *testing.T) {
},
entryPaths: []string{"/entry.ts"},
options: config.Options{
MangleSyntax: true,
MinifySyntax: true,
AbsOutputFile: "/out.js",
},
})
Expand All @@ -453,7 +453,7 @@ func TestTSImportStarMangleNoBundleNoCapture(t *testing.T) {
},
entryPaths: []string{"/entry.ts"},
options: config.Options{
MangleSyntax: true,
MinifySyntax: true,
AbsOutputFile: "/out.js",
},
})
Expand Down
2 changes: 1 addition & 1 deletion internal/bundler/bundler_splitting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func TestSplittingDuplicateChunkCollision(t *testing.T) {
options: config.Options{
Mode: config.ModeBundle,
CodeSplitting: true,
RemoveWhitespace: true,
MinifyWhitespace: true,
OutputFormat: config.FormatESModule,
AbsOutputDir: "/out",
},
Expand Down
Loading

0 comments on commit eba56ee

Please sign in to comment.