Skip to content

Commit

Permalink
fix namings
Browse files Browse the repository at this point in the history
  • Loading branch information
vankop committed May 1, 2024
1 parent 8510a6d commit 3a498e7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 25 deletions.
18 changes: 2 additions & 16 deletions lib/Compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ class Compiler {
/** @type {LoggingFunction | undefined} */
this.infrastructureLogger = undefined;

/** @type {PlatformTargetProperties} */
this.target = {
/** @type {Readonly<PlatformTargetProperties>} */
this.platform = {
web: null,
browser: null,
webworker: null,
Expand Down Expand Up @@ -313,20 +313,6 @@ class Compiler {
this._assetEmittingPreviousFiles = new Set();
}

/**
* @returns {Readonly<PlatformTargetProperties>} platform target properties
*/
getPlatformTargetInfo() {
return this.target;
}

/**
* @param {PlatformTargetProperties} platform platform target properties
*/
setPlatformTargetInfo(platform) {
this.target = platform;
}

/**
* @param {string} name cache name
* @returns {CacheFacade} the cache facade instance
Expand Down
6 changes: 3 additions & 3 deletions lib/PlatformPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class PlatformPlugin {
*/
apply(compiler) {
compiler.hooks.environment.tap("PlatformPlugin", () => {
compiler.setPlatformTargetInfo({
...compiler.getPlatformTargetInfo(),
compiler.platform = {
...compiler.platform,
...this.platform
});
};
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const createCompiler = rawOptions => {
const platform =
applyWebpackOptionsDefaultsAndResolvePlatformTargetProperties(options);
if (platform) {
compiler.setPlatformTargetInfo(platform);
compiler.platform = platform;
}
compiler.hooks.environment.call();
compiler.hooks.afterEnvironment.call();
Expand Down
4 changes: 2 additions & 2 deletions test/Compiler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ describe("Compiler", () => {
}
});
it("default platform info", done => {
const platform = compiler.getPlatformTargetInfo();
const platform = compiler.platform;
expect(platform.web).toBe(true);
expect(platform.node).toBe(false);
done();
Expand Down Expand Up @@ -306,7 +306,7 @@ describe("Compiler", () => {
new (require("../lib/PlatformPlugin"))({ node: true }),
compiler => {
compiler.hooks.afterEnvironment.tap("test", () => {
const platform = compiler.getPlatformTargetInfo();
const platform = compiler.platform;
expect(platform.node).toBe(true);
expect(platform.web).toBe(true);
});
Expand Down
4 changes: 1 addition & 3 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2308,7 +2308,7 @@ declare class Compiler {
fsStartTime?: number;
resolverFactory: ResolverFactory;
infrastructureLogger?: (arg0: string, arg1: LogTypeEnum, arg2: any[]) => void;
target: PlatformTargetProperties;
platform: Readonly<PlatformTargetProperties>;
options: WebpackOptionsNormalized;
context: string;
requestShortener: RequestShortener;
Expand All @@ -2325,8 +2325,6 @@ declare class Compiler {
running: boolean;
idle: boolean;
watchMode: boolean;
getPlatformTargetInfo(): Readonly<PlatformTargetProperties>;
setPlatformTargetInfo(platform: PlatformTargetProperties): void;
getCache(name: string): CacheFacade;
getInfrastructureLogger(name: string | (() => string)): WebpackLogger;
watch(watchOptions: WatchOptions, handler: RunCallback<Stats>): Watching;
Expand Down

0 comments on commit 3a498e7

Please sign in to comment.