Skip to content

Commit

Permalink
fix: Fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
xymopen committed Aug 27, 2024
1 parent 17dff20 commit 5f4aeb4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export interface IPreactRefreshRspackPluginOptions {
};
}

interface NormalizedPluginOptions extends IPreactRefreshRspackPluginOptions {
include: NonNullable<IPreactRefreshRspackPluginOptions['include']>;
exclude: NonNullable<IPreactRefreshRspackPluginOptions['exclude']>;
}

const PREACT_PATHS = [
'preact',
'preact/compat',
Expand Down Expand Up @@ -56,8 +61,9 @@ const NAME = 'PreactRefreshRspackPlugin';

class PreactRefreshRspackPlugin implements RspackPluginInstance {
name = NAME;
private options: NormalizedPluginOptions;

constructor(private options: IPreactRefreshRspackPluginOptions) {
constructor(options: IPreactRefreshRspackPluginOptions) {
this.options = {
include: options?.include ?? /\.([jt]sx?)$/,
exclude: options?.exclude ?? /node_modules/,
Expand Down Expand Up @@ -93,7 +99,6 @@ class PreactRefreshRspackPlugin implements RspackPluginInstance {
compiler.options.module.rules.unshift({
include: this.options.include,
exclude: {

or: [this.options.exclude, ...INTERNAL_PATHS].filter(Boolean),
},
use: 'builtin:preact-refresh-loader',
Expand Down

0 comments on commit 5f4aeb4

Please sign in to comment.