Skip to content

Commit 692b517

Browse files
authored
Rename noFrequencyBasedMinification to useFrequencyBasedMinification (flutter#182684)
# Rename noFrequencyBasedMinification to useFrequencyBasedMinification <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> This PR renames the parameter `noFrequencyBasedMinification` on `JsCompilerConfig` to `useFrequencyBasedMinification`, addressing the in-repo TODO in `packages/flutter_tools/lib/src/web/compiler_config.dart`: "consider renaming this to be 'positive'. Double negatives are confusing." (TODO(kevmoo)). **What changes:** The parameter is now positive: `useFrequencyBasedMinification` (default `true`). When set to `false`, the compiler still receives `--no-frequency-based-minification`. The CLI flag remains `--no-frequency-based-minification`; only the Dart API and internal naming change. **Why:** Positive naming improves readability (e.g. `useFrequencyBasedMinification: false` is clearer than `noFrequencyBasedMinification: true`). No behavior or CLI contract change. **Issues fixed:** None. This addresses an in-repo TODO; an issue is not required for this trivial refactor per the template. *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* N/A — no changes in flutter/tests. ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. (N/A: trivial refactor; addresses in-repo TODO.) - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. (Existing tests updated; no new behavior.) - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 450478a commit 692b517

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

packages/flutter_tools/lib/src/commands/build_web.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class BuildWebCommand extends BuildSubCommand {
223223
dumpInfo: boolArg('dump-info'),
224224
minify: minifyJs,
225225
nativeNullAssertions: boolArg('native-null-assertions'),
226-
noFrequencyBasedMinification: boolArg('no-frequency-based-minification'),
226+
useFrequencyBasedMinification: !boolArg('no-frequency-based-minification'),
227227
optimizationLevel: jsOptimizationLevel,
228228
sourceMaps: sourceMaps,
229229
),
@@ -235,7 +235,7 @@ class BuildWebCommand extends BuildSubCommand {
235235
dumpInfo: boolArg('dump-info'),
236236
minify: minifyJs,
237237
nativeNullAssertions: boolArg('native-null-assertions'),
238-
noFrequencyBasedMinification: boolArg('no-frequency-based-minification'),
238+
useFrequencyBasedMinification: !boolArg('no-frequency-based-minification'),
239239
optimizationLevel: jsOptimizationLevel,
240240
sourceMaps: sourceMaps,
241241
renderer: webRenderer,

packages/flutter_tools/lib/src/web/compiler_config.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class JsCompilerConfig extends WebCompilerConfig {
5959
this.dumpInfo = false,
6060
this.nativeNullAssertions = false,
6161
super.optimizationLevel,
62-
this.noFrequencyBasedMinification = false,
62+
this.useFrequencyBasedMinification = true,
6363
super.sourceMaps = true,
6464
this.minify,
6565
super.renderer = WebRendererMode.defaultForJs,
@@ -85,9 +85,10 @@ class JsCompilerConfig extends WebCompilerConfig {
8585
/// Whether native null assertions are enabled.
8686
final bool nativeNullAssertions;
8787

88-
// If `--no-frequency-based-minification` should be passed to dart2js
89-
// TODO(kevmoo): consider renaming this to be "positive". Double negatives are confusing.
90-
final bool noFrequencyBasedMinification;
88+
/// Whether to use frequency-based minification in dart2js.
89+
///
90+
/// When `false`, passes `--no-frequency-based-minification` to the compiler.
91+
final bool useFrequencyBasedMinification;
9192

9293
@override
9394
CompileTarget get compileTarget => CompileTarget.js;
@@ -101,7 +102,7 @@ class JsCompilerConfig extends WebCompilerConfig {
101102
if (buildMode == BuildMode.debug) '--enable-asserts',
102103
'-O${optimizationLevelForBuildMode(buildMode)}',
103104
if (minify ?? buildMode == BuildMode.release) '--minify' else '--no-minify',
104-
if (noFrequencyBasedMinification) '--no-frequency-based-minification',
105+
if (!useFrequencyBasedMinification) '--no-frequency-based-minification',
105106
if (csp) '--csp',
106107
];
107108

@@ -133,7 +134,7 @@ class JsCompilerConfig extends WebCompilerConfig {
133134
'csp': csp,
134135
'dumpInfo': dumpInfo,
135136
'nativeNullAssertions': nativeNullAssertions,
136-
'noFrequencyBasedMinification': noFrequencyBasedMinification,
137+
'useFrequencyBasedMinification': useFrequencyBasedMinification,
137138
'minify': minify,
138139
WebCompilerConfig.kSourceMapsEnabled: sourceMaps,
139140
};

packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ _flutter.loader.load();
12281228
);
12291229

12301230
await Dart2JSTarget(
1231-
const JsCompilerConfig(noFrequencyBasedMinification: true, sourceMaps: false),
1231+
const JsCompilerConfig(useFrequencyBasedMinification: false, sourceMaps: false),
12321232
).build(environment);
12331233
}, overrides: <Type, Generator>{ProcessManager: () => processManager}),
12341234
);
@@ -1334,7 +1334,7 @@ _flutter.loader.load();
13341334
JsCompilerConfig(dumpInfo: true),
13351335
JsCompilerConfig(nativeNullAssertions: true),
13361336
JsCompilerConfig(optimizationLevel: 0),
1337-
JsCompilerConfig(noFrequencyBasedMinification: true),
1337+
JsCompilerConfig(useFrequencyBasedMinification: false),
13381338
JsCompilerConfig(sourceMaps: false),
13391339
JsCompilerConfig(minify: false),
13401340

@@ -1344,7 +1344,7 @@ _flutter.loader.load();
13441344
dumpInfo: true,
13451345
nativeNullAssertions: true,
13461346
optimizationLevel: 0,
1347-
noFrequencyBasedMinification: true,
1347+
useFrequencyBasedMinification: false,
13481348
sourceMaps: false,
13491349
),
13501350
];

0 commit comments

Comments
 (0)