Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: leverage webpack types and remove casting #42104

Merged
merged 1 commit into from Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -31,12 +31,12 @@ export class AppBuildManifestPlugin {
PLUGIN_NAME,
(compilation: any, { normalModuleFactory }: any) => {
compilation.dependencyFactories.set(
(webpack as any).dependencies.ModuleDependency,
webpack.dependencies.ModuleDependency,
normalModuleFactory
)
compilation.dependencyTemplates.set(
(webpack as any).dependencies.ModuleDependency,
new (webpack as any).dependencies.NullDependency.Template()
webpack.dependencies.ModuleDependency,
new webpack.dependencies.NullDependency.Template()
)
}
)
Expand Down
38 changes: 20 additions & 18 deletions packages/next/build/webpack/plugins/flight-client-entry-plugin.ts
@@ -1,16 +1,17 @@
import type {
CssImports,
ClientComponentImports,
NextFlightClientEntryLoaderOptions,
} from '../loaders/next-flight-client-entry-loader'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { stringify } from 'querystring'
import path from 'path'
import { webpack, sources } from 'next/dist/compiled/webpack/webpack'
import { sources } from 'next/dist/compiled/webpack/webpack'
import {
getInvalidator,
entries,
EntryTypes,
} from '../../../server/dev/on-demand-entry-handler'
import type {
CssImports,
ClientComponentImports,
NextFlightClientEntryLoaderOptions,
} from '../loaders/next-flight-client-entry-loader'
import { APP_DIR_ALIAS, WEBPACK_LAYERS } from '../../../lib/constants'
import {
APP_CLIENT_INTERNALS,
Expand Down Expand Up @@ -52,12 +53,12 @@ export class FlightClientEntryPlugin {
PLUGIN_NAME,
(compilation, { normalModuleFactory }) => {
compilation.dependencyFactories.set(
(webpack as any).dependencies.ModuleDependency,
webpack.dependencies.ModuleDependency,
normalModuleFactory
)
compilation.dependencyTemplates.set(
(webpack as any).dependencies.ModuleDependency,
new (webpack as any).dependencies.NullDependency.Template()
webpack.dependencies.ModuleDependency,
new webpack.dependencies.NullDependency.Template()
)
}
)
Expand Down Expand Up @@ -464,8 +465,8 @@ export class FlightClientEntryPlugin {
clientComponentImports,
bundlePath,
}: {
compiler: any
compilation: any
compiler: webpack.Compiler
compilation: webpack.Compilation
entryName: string
clientComponentImports: ClientComponentImports
bundlePath: string
Expand Down Expand Up @@ -524,11 +525,12 @@ export class FlightClientEntryPlugin {
}

// Inject the entry to the server compiler (__sc_client__).
const clientComponentEntryDep = (
webpack as any
).EntryPlugin.createDependency(clientSSRLoader, {
name: bundlePath,
})
const clientComponentEntryDep = webpack.EntryPlugin.createDependency(
clientSSRLoader,
{
name: bundlePath,
}
)

// Add the dependency to the server compiler.
await this.addEntry(
Expand All @@ -552,8 +554,8 @@ export class FlightClientEntryPlugin {
addEntry(
compilation: any,
context: string,
dependency: any /* Dependency */,
options: any /* EntryOptions */
dependency: webpack.Dependency,
options: webpack.EntryOptions
): Promise<any> /* Promise<module> */ {
return new Promise((resolve, reject) => {
const entry = compilation.entries.get(options.name)
Expand Down
Expand Up @@ -96,12 +96,12 @@ export class FlightManifestPlugin {
PLUGIN_NAME,
(compilation, { normalModuleFactory }) => {
compilation.dependencyFactories.set(
(webpack as any).dependencies.ModuleDependency,
webpack.dependencies.ModuleDependency,
normalModuleFactory
)
compilation.dependencyTemplates.set(
(webpack as any).dependencies.ModuleDependency,
new (webpack as any).dependencies.NullDependency.Template()
webpack.dependencies.ModuleDependency,
new webpack.dependencies.NullDependency.Template()
)
}
)
Expand Down
2 changes: 1 addition & 1 deletion packages/next/build/webpack/plugins/middleware-plugin.ts
Expand Up @@ -861,7 +861,7 @@ export default class MiddlewarePlugin {
compilation.hooks.processAssets.tap(
{
name: 'NextJsMiddlewareManifest',
stage: (webpack as any).Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
},
getCreateAssets({
compilation,
Expand Down