@rspack/plugin-react-refresh
Advanced tools
Comparing version 1.0.0-alpha.0 to 1.0.0-alpha.1
import type { Compiler } from "@rspack/core"; | ||
import { type PluginOptions } from "./options"; | ||
import { type NormalizedPluginOptions, type PluginOptions } from "./options"; | ||
export type { PluginOptions }; | ||
@@ -10,3 +10,3 @@ /** | ||
declare class ReactRefreshRspackPlugin { | ||
options: PluginOptions; | ||
options: NormalizedPluginOptions; | ||
static deprecated_runtimePaths: string[]; | ||
@@ -13,0 +13,0 @@ constructor(options?: PluginOptions); |
@@ -7,2 +7,4 @@ "use strict"; | ||
const options_1 = require("./options"); | ||
const getAdditionalEntries_1 = require("./utils/getAdditionalEntries"); | ||
const getSocketIntegration_1 = __importDefault(require("./utils/getSocketIntegration")); | ||
const reactRefreshPath = require.resolve("../client/reactRefresh.js"); | ||
@@ -40,5 +42,16 @@ const reactRefreshEntryPath = require.resolve("../client/reactRefreshEntry.js"); | ||
} | ||
new compiler.webpack.EntryPlugin(compiler.context, reactRefreshEntryPath, { | ||
name: undefined | ||
}).apply(compiler); | ||
const addEntries = (0, getAdditionalEntries_1.getAdditionalEntries)({ | ||
devServer: compiler.options.devServer, | ||
options: this.options | ||
}); | ||
addEntries.prependEntries.forEach(entry => { | ||
new compiler.webpack.EntryPlugin(compiler.context, entry, { | ||
name: undefined | ||
}).apply(compiler); | ||
}); | ||
addEntries.overlayEntries.forEach(entry => { | ||
new compiler.webpack.EntryPlugin(compiler.context, entry, { | ||
name: undefined | ||
}).apply(compiler); | ||
}); | ||
new compiler.webpack.ProvidePlugin({ | ||
@@ -60,3 +73,20 @@ $ReactRefreshRuntime$: reactRefreshPath | ||
}; | ||
const providedModules = { | ||
__react_refresh_utils__: refreshUtilsPath | ||
}; | ||
if (this.options.overlay === false) { | ||
// Stub errorOverlay module so their calls can be erased | ||
definedModules.__react_refresh_error_overlay__ = false; | ||
definedModules.__react_refresh_socket__ = false; | ||
} | ||
else { | ||
if (this.options.overlay.module) { | ||
providedModules.__react_refresh_error_overlay__ = require.resolve(this.options.overlay.module); | ||
} | ||
if (this.options.overlay.sockIntegration) { | ||
providedModules.__react_refresh_socket__ = (0, getSocketIntegration_1.default)(this.options.overlay.sockIntegration); | ||
} | ||
} | ||
new compiler.webpack.DefinePlugin(definedModules).apply(compiler); | ||
new compiler.webpack.ProvidePlugin(providedModules).apply(compiler); | ||
const refreshPath = path_1.default.dirname(require.resolve("react-refresh")); | ||
@@ -63,0 +93,0 @@ compiler.options.resolve.alias = { |
@@ -0,1 +1,11 @@ | ||
import type { IntegrationType } from "./utils/getSocketIntegration"; | ||
interface OverlayOptions { | ||
entry: string; | ||
module: string; | ||
sockIntegration: IntegrationType; | ||
sockHost?: string; | ||
sockPath?: string; | ||
sockPort?: string; | ||
sockProtocol?: string; | ||
} | ||
export type PluginOptions = { | ||
@@ -6,3 +16,8 @@ include?: string | RegExp | (string | RegExp)[] | null; | ||
forceEnable?: boolean; | ||
overlay?: boolean | OverlayOptions; | ||
}; | ||
export declare function normalizeOptions(options: PluginOptions): PluginOptions; | ||
export interface NormalizedPluginOptions extends Required<PluginOptions> { | ||
overlay: false | OverlayOptions; | ||
} | ||
export declare function normalizeOptions(options: PluginOptions): NormalizedPluginOptions; | ||
export {}; |
@@ -12,2 +12,20 @@ "use strict"; | ||
}; | ||
const normalizeOverlay = (options) => { | ||
const defaultOverlay = { | ||
entry: require.resolve("../client/errorOverlayEntry.js"), | ||
module: require.resolve("../client/overlay/index.js"), | ||
sockIntegration: "wds" | ||
}; | ||
if (!options) { | ||
return false; | ||
} | ||
if (typeof options === "undefined" || options === true) { | ||
return defaultOverlay; | ||
} | ||
options.entry = options.entry ?? defaultOverlay.entry; | ||
options.module = options.module ?? defaultOverlay.module; | ||
options.sockIntegration = | ||
options.sockIntegration ?? defaultOverlay.sockIntegration; | ||
return options; | ||
}; | ||
function normalizeOptions(options) { | ||
@@ -18,4 +36,5 @@ d(options, "exclude", /node_modules/i); | ||
d(options, "forceEnable", false); | ||
options.overlay = normalizeOverlay(options.overlay); | ||
return options; | ||
} | ||
exports.normalizeOptions = normalizeOptions; |
{ | ||
"name": "@rspack/plugin-react-refresh", | ||
"version": "1.0.0-alpha.0", | ||
"version": "1.0.0-alpha.1", | ||
"license": "MIT", | ||
@@ -33,5 +33,9 @@ "description": "React refresh plugin for rspack", | ||
"react-refresh": "0.14.0", | ||
"@rspack/core": "1.0.0-alpha.0", | ||
"@rspack/plugin-react-refresh": "1.0.0-alpha.0" | ||
"@rspack/core": "1.0.0-alpha.1", | ||
"@rspack/plugin-react-refresh": "1.0.0-alpha.1" | ||
}, | ||
"dependencies": { | ||
"html-entities": "^2.1.0", | ||
"error-stack-parser": "^2.0.6" | ||
}, | ||
"peerDependencies": { | ||
@@ -38,0 +42,0 @@ "react-refresh": ">=0.10.0 <1.0.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79129
40
2237
3
7
2
+ Addederror-stack-parser@^2.0.6
+ Addedhtml-entities@^2.1.0
+ Addederror-stack-parser@2.1.4(transitive)
+ Addedhtml-entities@2.5.2(transitive)
+ Addedstackframe@1.3.4(transitive)