Skip to content

Commit

Permalink
fix(types): update dependency webpack to v5.94.0
Browse files Browse the repository at this point in the history
  • Loading branch information
easy1090 committed Oct 16, 2024
1 parent e888e74 commit b9b6e1f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { SDK, Plugin } from '@rsdoctor/types';
import type {
NormalModule as WebpackNormalModule,
ModuleGraph as WebpackModuleGraph,
Compilation,
} from 'webpack';

import type {
Expand Down Expand Up @@ -166,8 +167,9 @@ export function appendTreeShaking(

if ('moduleGraph' in compilation) {
const exportData = new Map<WebExportInfo, ExportInfo>();
const { moduleGraph: webpackGraph } = compilation;
const allModules = getAllModules(compilation);
const webpackCompilation = compilation as unknown as Compilation;
const { moduleGraph: webpackGraph } = webpackCompilation;
const allModules = getAllModules(webpackCompilation);

allModules.forEach((origin) =>
transformMgm(origin, webpackGraph, moduleGraph, exportData),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ async function appendModuleData(
const transformed = isExternalModule(origin)
? ''
: module.getSource().transformed.length > 0
? module.getSource().transformed
: isFunction(origin?.originalSource)
? origin.originalSource()?.source()?.toString() ?? ''
: '';
? module.getSource().transformed
: isFunction(origin?.originalSource)
? (origin.originalSource()?.source()?.toString() ?? '')
: '';
const transformedSize = isExternalModule(origin)
? 0
: module.getSize().transformedSize > 0
? module.getSize().transformedSize
: Buffer.from(transformed).byteLength;
? module.getSize().transformedSize
: Buffer.from(transformed).byteLength;

module.setSource({
transformed,
Expand Down Expand Up @@ -247,11 +247,10 @@ export async function appendModuleGraphByCompilation(
context?: TransformContext,
) {
try {

// Only webpack will execute the following logic.
const { moduleGraph: webpackGraph, fileSystemInfo } =
compilation as Webpack.Compilation;
const allModules = getAllModules(compilation as Webpack.Compilation);
const webpackCompilation = compilation as unknown as Webpack.Compilation;
const { moduleGraph: webpackGraph, fileSystemInfo } = webpackCompilation;
const allModules = getAllModules(webpackCompilation);

await Promise.all(
allModules.map((module: Webpack.NormalModule) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/inner-plugins/plugins/bundleTagPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class InternalBundleTagPlugin<

compilation.updateAsset(
file,
(old) => {
(old: any) => {
const concatSource = new ConcatSource();
let header = "\n console.log('RSDOCTOR_START::');\n";
let footer = "\n console.log('RSDOCTOR_END::');\n";
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/plugin/baseCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type BaseCompiler = BaseCompilerType | BaseCompilerType<'rspack'>;

export type BaseCompilationType<T extends 'rspack' | 'webpack' = 'webpack'> =
T extends 'rspack'
? Compilation & { updateAsset: updateAsset }
? Compilation
: RspackCompilation & { updateAsset: updateAsset };
export type BaseCompilation =
| BaseCompilationType
Expand Down

0 comments on commit b9b6e1f

Please sign in to comment.