-
-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use incremental in production build (#8311)
- Loading branch information
Showing
9 changed files
with
188 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 37 additions & 7 deletions
44
packages/rspack/src/builtin-plugin/FlagDependencyUsagePlugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,39 @@ | ||
import { BuiltinPluginName } from "@rspack/binding"; | ||
import { type BuiltinPlugin, BuiltinPluginName } from "@rspack/binding"; | ||
import type { Compiler } from "../Compiler"; | ||
import type { Incremental } from "../config"; | ||
import { RspackBuiltinPlugin, createBuiltinPlugin } from "./base"; | ||
|
||
import { create } from "./base"; | ||
export class FlagDependencyUsagePlugin extends RspackBuiltinPlugin { | ||
name = BuiltinPluginName.FlagDependencyUsagePlugin; | ||
affectedHooks = "compilation" as const; | ||
|
||
export const FlagDependencyUsagePlugin = create( | ||
BuiltinPluginName.FlagDependencyUsagePlugin, | ||
(global: boolean) => global, | ||
"compilation" | ||
); | ||
constructor(private global: boolean) { | ||
super(); | ||
} | ||
|
||
raw(compiler: Compiler): BuiltinPlugin { | ||
const incremental = compiler.options.experiments.incremental as Incremental; | ||
const logger = compiler.getInfrastructureLogger( | ||
"rspack.FlagDependencyUsagePlugin" | ||
); | ||
if (incremental.modulesHashes) { | ||
incremental.modulesHashes = false; | ||
logger.warn( | ||
"`optimization.usedExports` can't be used with `incremental.modulesHashes` as export usage is a global effect. `incremental.modulesHashes` has been overridden to false." | ||
); | ||
} | ||
if (incremental.modulesCodegen) { | ||
incremental.modulesCodegen = false; | ||
logger.warn( | ||
"`optimization.usedExports` can't be used with `incremental.modulesCodegen` as export usage is a global effect. `incremental.modulesCodegen` has been overridden to false." | ||
); | ||
} | ||
if (incremental.modulesRuntimeRequirements) { | ||
incremental.modulesRuntimeRequirements = false; | ||
logger.warn( | ||
"`optimization.usedExports` can't be used with `incremental.modulesRuntimeRequirements` as export usage is a global effect. `incremental.modulesRuntimeRequirements` has been overridden to false." | ||
); | ||
} | ||
return createBuiltinPlugin(this.name, this.global); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,39 @@ | ||
import { BuiltinPluginName } from "@rspack/binding"; | ||
import { type BuiltinPlugin, BuiltinPluginName } from "@rspack/binding"; | ||
import type { Compiler } from "../Compiler"; | ||
import type { Incremental } from "../config"; | ||
import { RspackBuiltinPlugin, createBuiltinPlugin } from "./base"; | ||
|
||
import { create } from "./base"; | ||
export class MangleExportsPlugin extends RspackBuiltinPlugin { | ||
name = BuiltinPluginName.MangleExportsPlugin; | ||
affectedHooks = "compilation" as const; | ||
|
||
export const MangleExportsPlugin = create( | ||
BuiltinPluginName.MangleExportsPlugin, | ||
(deterministic: boolean) => deterministic, | ||
"compilation" | ||
); | ||
constructor(private deterministic: boolean) { | ||
super(); | ||
} | ||
|
||
raw(compiler: Compiler): BuiltinPlugin { | ||
const incremental = compiler.options.experiments.incremental as Incremental; | ||
const logger = compiler.getInfrastructureLogger( | ||
"rspack.MangleExportsPlugin" | ||
); | ||
if (incremental.modulesHashes) { | ||
incremental.modulesHashes = false; | ||
logger.warn( | ||
"`optimization.mangleExports` can't be used with `incremental.modulesHashes` as export mangling is a global effect. `incremental.modulesHashes` has been overridden to false." | ||
); | ||
} | ||
if (incremental.modulesCodegen) { | ||
incremental.modulesCodegen = false; | ||
logger.warn( | ||
"`optimization.mangleExports` can't be used with `incremental.modulesCodegen` as export mangling is a global effect. `incremental.modulesCodegen` has been overridden to false." | ||
); | ||
} | ||
if (incremental.modulesRuntimeRequirements) { | ||
incremental.modulesRuntimeRequirements = false; | ||
logger.warn( | ||
"`optimization.mangleExports` can't be used with `incremental.modulesRuntimeRequirements` as export mangling is a global effect. `incremental.modulesRuntimeRequirements` has been overridden to false." | ||
); | ||
} | ||
return createBuiltinPlugin(this.name, this.deterministic); | ||
} | ||
} |
40 changes: 33 additions & 7 deletions
40
packages/rspack/src/builtin-plugin/ModuleConcatenationPlugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,35 @@ | ||
import { BuiltinPluginName } from "@rspack/binding"; | ||
import { type BuiltinPlugin, BuiltinPluginName } from "@rspack/binding"; | ||
import type { Compiler } from "../Compiler"; | ||
import type { Incremental } from "../config"; | ||
import { RspackBuiltinPlugin, createBuiltinPlugin } from "./base"; | ||
|
||
import { create } from "./base"; | ||
export class ModuleConcatenationPlugin extends RspackBuiltinPlugin { | ||
name = BuiltinPluginName.ModuleConcatenationPlugin; | ||
affectedHooks = "compilation" as const; | ||
|
||
export const ModuleConcatenationPlugin = create( | ||
BuiltinPluginName.ModuleConcatenationPlugin, | ||
() => {}, | ||
"compilation" | ||
); | ||
raw(compiler: Compiler): BuiltinPlugin { | ||
const incremental = compiler.options.experiments.incremental as Incremental; | ||
const logger = compiler.getInfrastructureLogger( | ||
"rspack.ModuleConcatenationPlugin" | ||
); | ||
if (incremental.modulesHashes) { | ||
incremental.modulesHashes = false; | ||
logger.warn( | ||
"`optimization.concatenateModules` can't be used with `incremental.modulesHashes` as module concatenation is a global effect. `incremental.modulesHashes` has been overridden to false." | ||
); | ||
} | ||
if (incremental.modulesCodegen) { | ||
incremental.modulesCodegen = false; | ||
logger.warn( | ||
"`optimization.concatenateModules` can't be used with `incremental.modulesCodegen` as module concatenation is a global effect. `incremental.modulesCodegen` has been overridden to false." | ||
); | ||
} | ||
if (incremental.modulesRuntimeRequirements) { | ||
incremental.modulesRuntimeRequirements = false; | ||
logger.warn( | ||
"`optimization.concatenateModules` can't be used with `incremental.modulesRuntimeRequirements` as module concatenation is a global effect. `incremental.modulesRuntimeRequirements` has been overridden to false." | ||
); | ||
} | ||
return createBuiltinPlugin(this.name, undefined); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1161016
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ran ecosystem CI: Open
1161016
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open
1161016
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ran ecosystem CI: Open
1161016
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open