@rspack/plugin-react-refresh 0.3.11 → 0.3.12-canary-bd2e9a8-20231114131339

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,6 +37,14 @@ var safeThis = (function () {
37
37
  if (process.env.NODE_ENV !== "production") {
38
38
  if (typeof safeThis !== "undefined") {
39
39
  var $RefreshInjected$ = "__reactRefreshInjected";
40
+ // Namespace the injected flag (if necessary) for monorepo compatibility
41
+ if (
42
+ typeof __react_refresh_library__ !== "undefined" &&
43
+ __react_refresh_library__
44
+ ) {
45
+ $RefreshInjected$ += "_" + __react_refresh_library__;
46
+ }
47
+
40
48
  // Only inject the runtime if it hasn't been injected
41
49
  if (!safeThis[$RefreshInjected$]) {
42
50
  RefreshRuntime.injectIntoGlobalHook(safeThis);
package/dist/index.js CHANGED
@@ -3,11 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  const path_1 = __importDefault(require("path"));
6
+ const core_1 = require("@rspack/core");
6
7
  const options_1 = require("./options");
7
- const schema_utils_1 = require("schema-utils");
8
8
  const reactRefreshPath = require.resolve("../client/reactRefresh.js");
9
9
  const reactRefreshEntryPath = require.resolve("../client/reactRefreshEntry.js");
10
- const schema = require("../options.json");
11
10
  const refreshUtilsPath = require.resolve("@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils", {
12
11
  paths: [reactRefreshPath]
13
12
  });
@@ -27,10 +26,6 @@ const runtimePaths = [
27
26
  */
28
27
  class ReactRefreshRspackPlugin {
29
28
  constructor(options = {}) {
30
- (0, schema_utils_1.validate)(schema, options, {
31
- name: "React Refresh Rspack Plugin",
32
- baseDataPath: "options"
33
- });
34
29
  this.options = (0, options_1.normalizeOptions)(options);
35
30
  }
36
31
  apply(compiler) {
@@ -47,6 +42,13 @@ class ReactRefreshRspackPlugin {
47
42
  },
48
43
  use: "builtin:react-refresh-loader"
49
44
  });
45
+ const definedModules = {
46
+ // For Mutiple Instance Mode
47
+ __react_refresh_library__: JSON.stringify(compiler.webpack.Template.toIdentifier(this.options.library ||
48
+ compiler.options.output.uniqueName ||
49
+ compiler.options.output.library))
50
+ };
51
+ new core_1.DefinePlugin(definedModules).apply(compiler);
50
52
  const refreshPath = path_1.default.dirname(require.resolve("react-refresh"));
51
53
  compiler.options.resolve.alias = {
52
54
  "react-refresh": refreshPath,
package/dist/options.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export type PluginOptions = {
2
2
  include?: string | RegExp | (string | RegExp)[] | null;
3
3
  exclude?: string | RegExp | (string | RegExp)[] | null;
4
+ library?: string;
4
5
  };
5
6
  export declare function normalizeOptions(options: PluginOptions): PluginOptions;
package/dist/options.js CHANGED
@@ -11,6 +11,7 @@ const d = (object, property, defaultValue) => {
11
11
  function normalizeOptions(options) {
12
12
  d(options, "exclude", /node_modules/i);
13
13
  d(options, "include", /\.([cm]js|[jt]sx?|flow)$/i);
14
+ d(options, "library");
14
15
  return options;
15
16
  }
16
17
  exports.normalizeOptions = normalizeOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/plugin-react-refresh",
3
- "version": "0.3.11",
3
+ "version": "0.3.12-canary-bd2e9a8-20231114131339",
4
4
  "license": "MIT",
5
5
  "description": "React refresh plugin for rspack",
6
6
  "main": "dist/index.js",
@@ -11,12 +11,12 @@
11
11
  "default": "./dist/index.js"
12
12
  },
13
13
  "./react-refresh": "./client/reactRefresh.js",
14
- "./react-refresh-entry": "./client/reactRefreshEntry.js"
14
+ "./react-refresh-entry": "./client/reactRefreshEntry.js",
15
+ "./package.json": "./package.json"
15
16
  },
16
17
  "files": [
17
18
  "client",
18
- "dist",
19
- "options.json"
19
+ "dist"
20
20
  ],
21
21
  "publishConfig": {
22
22
  "access": "public"
@@ -29,13 +29,12 @@
29
29
  "directory": "packages/rspack-plugin-react-refresh"
30
30
  },
31
31
  "dependencies": {
32
- "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
33
- "schema-utils": "^4.0.0"
32
+ "@pmmmwh/react-refresh-webpack-plugin": "0.5.10"
34
33
  },
35
34
  "devDependencies": {
36
35
  "react-refresh": "0.14.0",
37
- "@rspack/plugin-react-refresh": "0.3.11",
38
- "@rspack/core": "0.3.11"
36
+ "@rspack/core": "0.3.12-canary-bd2e9a8-20231114131339",
37
+ "@rspack/plugin-react-refresh": "0.3.12-canary-bd2e9a8-20231114131339"
39
38
  },
40
39
  "peerDependencies": {
41
40
  "react-refresh": ">=0.10.0 <1.0.0"
package/options.json DELETED
@@ -1,33 +0,0 @@
1
- {
2
- "additionalProperties": false,
3
- "type": "object",
4
- "definitions": {
5
- "Path": { "type": "string" },
6
- "MatchCondition": {
7
- "anyOf": [
8
- { "instanceof": "RegExp" },
9
- { "$ref": "#/definitions/Path" },
10
- { "type": "null" }
11
- ]
12
- },
13
- "MatchConditions": {
14
- "type": "array",
15
- "items": { "$ref": "#/definitions/MatchCondition" },
16
- "minItems": 1
17
- }
18
- },
19
- "properties": {
20
- "exclude": {
21
- "anyOf": [
22
- { "$ref": "#/definitions/MatchCondition" },
23
- { "$ref": "#/definitions/MatchConditions" }
24
- ]
25
- },
26
- "include": {
27
- "anyOf": [
28
- { "$ref": "#/definitions/MatchCondition" },
29
- { "$ref": "#/definitions/MatchConditions" }
30
- ]
31
- }
32
- }
33
- }