Skip to content

Commit 711d028

Browse files
committed
Use assertion for @vue/preload-webpack-plugin require
1 parent dd47f88 commit 711d028

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

config/webpack/webpack.common.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,24 @@ import dotenv from 'dotenv';
44
import fs from 'fs';
55
import HtmlWebpackPlugin from 'html-webpack-plugin';
66
import path from 'path';
7-
import type {Compiler, Configuration} from 'webpack';
7+
import type {Class} from 'type-fest';
8+
import type {Configuration, WebpackPluginInstance} from 'webpack';
89
import {DefinePlugin, EnvironmentPlugin, IgnorePlugin, ProvidePlugin} from 'webpack';
910
import {BundleAnalyzerPlugin} from 'webpack-bundle-analyzer';
1011
import CustomVersionFilePlugin from './CustomVersionFilePlugin';
1112
import type Environment from './types';
1213

13-
// importing anything from @vue/preload-webpack-plugin causes an error
1414
type Options = {
1515
rel: string;
1616
as: string;
1717
fileWhitelist: RegExp[];
1818
include: string;
1919
};
2020

21-
type PreloadWebpackPluginClass = {
22-
new (options?: Options): PreloadWebpackPluginClass;
23-
apply: (compiler: Compiler) => void;
24-
};
21+
type PreloadWebpackPluginClass = Class<WebpackPluginInstance, [Options]>;
2522

26-
// require is necessary, there are no types for this package and the declaration file can't be seen by the build process which causes an error.
27-
const PreloadWebpackPlugin: PreloadWebpackPluginClass = require('@vue/preload-webpack-plugin');
23+
// require is necessary, importing anything from @vue/preload-webpack-plugin causes an error
24+
const PreloadWebpackPlugin = require('@vue/preload-webpack-plugin') as PreloadWebpackPluginClass;
2825

2926
const includeModules = [
3027
'react-native-animatable',

0 commit comments

Comments
 (0)