From 510bde4934e9fbdece70bc66046214d16d6ffc76 Mon Sep 17 00:00:00 2001 From: lrworth Date: Sun, 29 Oct 2023 20:50:26 +1100 Subject: [PATCH] chore: import webpack using "* as webpack" syntax (#780) Avoids problems like the following: ``` $ npx tsc node_modules/fork-ts-checker-webpack-plugin/lib/plugin.d.ts:1:13 - error TS1259: Module '".../node_modules/webpack/types"' can only be default-imported using the 'allowSyntheticDefaultImports' flag 1 import type webpack from 'webpack'; ~~~~~~~ node_modules/webpack/types.d.ts:13189:1 13189 export = exports; ~~~~~~~~~~~~~~~~~ This module is declared with 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag. Found 1 error in node_modules/fork-ts-checker-webpack-plugin/lib/plugin.d.ts:1 ``` --- src/hooks/intercept-done-to-get-dev-server-tap.ts | 2 +- src/hooks/tap-after-compile-to-add-dependencies.ts | 2 +- src/hooks/tap-after-compile-to-get-issues.ts | 2 +- src/hooks/tap-after-environment-to-patch-watching.ts | 2 +- src/hooks/tap-done-to-async-get-issues.ts | 2 +- src/hooks/tap-error-to-log-message.ts | 2 +- src/hooks/tap-stop-to-terminate-workers.ts | 2 +- src/infrastructure-logger.ts | 2 +- src/issue/issue-config.ts | 2 +- src/issue/issue-webpack-error.ts | 2 +- src/plugin-config.ts | 2 +- src/plugin.ts | 2 +- src/typescript/type-script-worker-config.ts | 2 +- src/watch/watch-file-system.ts | 2 +- test/unit/typescript/type-script-worker-config.spec.ts | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/hooks/intercept-done-to-get-dev-server-tap.ts b/src/hooks/intercept-done-to-get-dev-server-tap.ts index 531645b7..4c6bc1dc 100644 --- a/src/hooks/intercept-done-to-get-dev-server-tap.ts +++ b/src/hooks/intercept-done-to-get-dev-server-tap.ts @@ -1,4 +1,4 @@ -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; import { getInfrastructureLogger } from '../infrastructure-logger'; import type { ForkTsCheckerWebpackPluginConfig } from '../plugin-config'; diff --git a/src/hooks/tap-after-compile-to-add-dependencies.ts b/src/hooks/tap-after-compile-to-add-dependencies.ts index 0d013554..e83117b0 100644 --- a/src/hooks/tap-after-compile-to-add-dependencies.ts +++ b/src/hooks/tap-after-compile-to-add-dependencies.ts @@ -1,4 +1,4 @@ -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; import { getInfrastructureLogger } from '../infrastructure-logger'; import type { ForkTsCheckerWebpackPluginConfig } from '../plugin-config'; diff --git a/src/hooks/tap-after-compile-to-get-issues.ts b/src/hooks/tap-after-compile-to-get-issues.ts index 38c0cb97..22e32000 100644 --- a/src/hooks/tap-after-compile-to-get-issues.ts +++ b/src/hooks/tap-after-compile-to-get-issues.ts @@ -1,4 +1,4 @@ -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; import { getInfrastructureLogger } from '../infrastructure-logger'; import type { Issue } from '../issue'; diff --git a/src/hooks/tap-after-environment-to-patch-watching.ts b/src/hooks/tap-after-environment-to-patch-watching.ts index ef5db7f6..5409c017 100644 --- a/src/hooks/tap-after-environment-to-patch-watching.ts +++ b/src/hooks/tap-after-environment-to-patch-watching.ts @@ -1,4 +1,4 @@ -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; import { getInfrastructureLogger } from '../infrastructure-logger'; import type { ForkTsCheckerWebpackPluginState } from '../plugin-state'; diff --git a/src/hooks/tap-done-to-async-get-issues.ts b/src/hooks/tap-done-to-async-get-issues.ts index 0dc4c894..4352d23d 100644 --- a/src/hooks/tap-done-to-async-get-issues.ts +++ b/src/hooks/tap-done-to-async-get-issues.ts @@ -1,5 +1,5 @@ import chalk from 'chalk'; -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; import { statsFormatter } from '../formatter/stats-formatter'; import { createWebpackFormatter } from '../formatter/webpack-formatter'; diff --git a/src/hooks/tap-error-to-log-message.ts b/src/hooks/tap-error-to-log-message.ts index d8fa5a35..e5fcf433 100644 --- a/src/hooks/tap-error-to-log-message.ts +++ b/src/hooks/tap-error-to-log-message.ts @@ -1,5 +1,5 @@ import chalk from 'chalk'; -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; import type { ForkTsCheckerWebpackPluginConfig } from '../plugin-config'; import { getPluginHooks } from '../plugin-hooks'; diff --git a/src/hooks/tap-stop-to-terminate-workers.ts b/src/hooks/tap-stop-to-terminate-workers.ts index 0ed5b904..d2ad42f9 100644 --- a/src/hooks/tap-stop-to-terminate-workers.ts +++ b/src/hooks/tap-stop-to-terminate-workers.ts @@ -1,4 +1,4 @@ -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; import { getInfrastructureLogger } from '../infrastructure-logger'; import type { ForkTsCheckerWebpackPluginState } from '../plugin-state'; diff --git a/src/infrastructure-logger.ts b/src/infrastructure-logger.ts index fa47f099..1cbb40f0 100644 --- a/src/infrastructure-logger.ts +++ b/src/infrastructure-logger.ts @@ -1,4 +1,4 @@ -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; export interface InfrastructureLogger { log(...args: unknown[]): void; diff --git a/src/issue/issue-config.ts b/src/issue/issue-config.ts index fea3b0a7..58cdad29 100644 --- a/src/issue/issue-config.ts +++ b/src/issue/issue-config.ts @@ -1,4 +1,4 @@ -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; import { createIssuePredicateFromIssueMatch } from './issue-match'; import type { IssuePredicateOption, IssueOptions } from './issue-options'; diff --git a/src/issue/issue-webpack-error.ts b/src/issue/issue-webpack-error.ts index 612d69ed..13b6bf2c 100644 --- a/src/issue/issue-webpack-error.ts +++ b/src/issue/issue-webpack-error.ts @@ -1,7 +1,7 @@ import path from 'path'; import chalk from 'chalk'; -import webpack from 'webpack'; +import * as webpack from 'webpack'; import type { FormatterPathType } from '../formatter'; import { forwardSlash } from '../utils/path/forward-slash'; diff --git a/src/plugin-config.ts b/src/plugin-config.ts index 383f9e87..8e5836f0 100644 --- a/src/plugin-config.ts +++ b/src/plugin-config.ts @@ -1,4 +1,4 @@ -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; import type { FormatterConfig } from './formatter'; import { createFormatterConfig } from './formatter'; diff --git a/src/plugin.ts b/src/plugin.ts index 880cc6a9..48d9f20d 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -4,7 +4,7 @@ import { cosmiconfigSync } from 'cosmiconfig'; import merge from 'deepmerge'; import type { JSONSchema7 } from 'json-schema'; import { validate } from 'schema-utils'; -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; import { tapAfterCompileToAddDependencies } from './hooks/tap-after-compile-to-add-dependencies'; import { tapAfterEnvironmentToPatchWatching } from './hooks/tap-after-environment-to-patch-watching'; diff --git a/src/typescript/type-script-worker-config.ts b/src/typescript/type-script-worker-config.ts index a92a4c8a..d154f740 100644 --- a/src/typescript/type-script-worker-config.ts +++ b/src/typescript/type-script-worker-config.ts @@ -1,6 +1,6 @@ import path from 'path'; -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; import type { TypeScriptConfigOverwrite } from './type-script-config-overwrite'; import type { TypeScriptDiagnosticsOptions } from './type-script-diagnostics-options'; diff --git a/src/watch/watch-file-system.ts b/src/watch/watch-file-system.ts index 17395bdf..f9818eb0 100644 --- a/src/watch/watch-file-system.ts +++ b/src/watch/watch-file-system.ts @@ -1,6 +1,6 @@ import type { EventEmitter } from 'events'; -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; // watchpack v1 and v2 internal interface interface Watchpack extends EventEmitter { diff --git a/test/unit/typescript/type-script-worker-config.spec.ts b/test/unit/typescript/type-script-worker-config.spec.ts index 33a84c32..81a1dfb3 100644 --- a/test/unit/typescript/type-script-worker-config.spec.ts +++ b/test/unit/typescript/type-script-worker-config.spec.ts @@ -2,7 +2,7 @@ import path from 'path'; import type { TypeScriptWorkerConfig } from 'src/typescript/type-script-worker-config'; import type { TypeScriptWorkerOptions } from 'src/typescript/type-script-worker-options'; -import type webpack from 'webpack'; +import type * as webpack from 'webpack'; describe('typescript/type-scripts-worker-config', () => { let compiler: webpack.Compiler;