@rspack/dev-server 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/dist/alias.js +9 -10
  2. package/package.json +1 -1
package/dist/alias.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.removeResolveAlias = exports.addResolveAlias = void 0;
4
- const Module = require("module");
4
+ const Module = require("node:module");
5
5
  const MODULE_MAP = {};
6
6
  const RESOLVER_MAP = {};
7
7
  const addResolveAlias = (name, aliasMap) => {
8
8
  const modulePath = require.resolve(name);
9
- if (RESOLVER_MAP[modulePath]) {
9
+ if (modulePath in RESOLVER_MAP) {
10
10
  throw new Error(`Should not add resolve alias to ${name} again.`);
11
11
  }
12
12
  const m = require.cache[modulePath];
@@ -14,13 +14,14 @@ const addResolveAlias = (name, aliasMap) => {
14
14
  throw new Error("Failed to resolve webpack-dev-server.");
15
15
  }
16
16
  RESOLVER_MAP[modulePath] = m.require.resolve;
17
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
17
18
  m.require.resolve = ((id, options) => aliasMap[id] ||
18
19
  RESOLVER_MAP[modulePath].apply(m.require, [
19
20
  id,
20
- options
21
+ options,
21
22
  ]));
22
23
  MODULE_MAP[modulePath] = Module._resolveFilename;
23
- Module._resolveFilename = Module._resolveFilename = (request, mod, ...args) => {
24
+ Module._resolveFilename = (request, mod, ...args) => {
24
25
  if (mod.filename === modulePath && aliasMap[request]) {
25
26
  return aliasMap[request];
26
27
  }
@@ -30,17 +31,15 @@ const addResolveAlias = (name, aliasMap) => {
30
31
  exports.addResolveAlias = addResolveAlias;
31
32
  const removeResolveAlias = (name) => {
32
33
  const modulePath = require.resolve(name);
33
- if (!RESOLVER_MAP[modulePath]) {
34
+ if (!(modulePath in RESOLVER_MAP)) {
34
35
  return;
35
36
  }
36
37
  const m = require.cache[modulePath];
37
38
  if (!m) {
38
39
  throw new Error("Failed to resolve webpack-dev-server");
39
40
  }
40
- if (RESOLVER_MAP[modulePath]) {
41
- Module._resolveFilename = RESOLVER_MAP[modulePath];
42
- m.require.resolve = RESOLVER_MAP[modulePath];
43
- delete RESOLVER_MAP[modulePath];
44
- }
41
+ Module._resolveFilename = MODULE_MAP[modulePath];
42
+ m.require.resolve = RESOLVER_MAP[modulePath];
43
+ delete RESOLVER_MAP[modulePath];
45
44
  };
46
45
  exports.removeResolveAlias = removeResolveAlias;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/dev-server",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "license": "MIT",
5
5
  "description": "Development server for rspack",
6
6
  "main": "./dist/index.js",