@modern-js/plugin-bff 1.6.0 → 1.6.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @modern-js/plugin-bff
2
2
 
3
+ ## 1.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - d86f009: feat: optimize implentation of registerModernRuntimePath
8
+ - Updated dependencies [dc4676b]
9
+ - Updated dependencies [d86f009]
10
+ - @modern-js/utils@1.7.12
11
+ - @modern-js/bff-core@1.1.1
12
+
3
13
  ## 1.6.0
4
14
 
5
15
  ### Minor Changes
@@ -1,38 +1,14 @@
1
- import Module from 'module';
2
1
  import * as path from 'path';
2
+ import { registerPaths } from '@modern-js/bff-core';
3
3
  const serverRuntimeAlias = '@modern-js/runtime/server';
4
4
  const serverRuntimePath = '.runtime-exports/server';
5
5
 
6
6
  const registerModernRuntimePath = internalDirectory => {
7
- const originalResolveFilename = Module._resolveFilename; // eslint-disable-next-line node/no-unsupported-features/node-builtins
8
-
9
- const {
10
- builtinModules
11
- } = Module;
12
-
13
- Module._resolveFilename = function (request, _parent) {
14
- const isCoreModule = builtinModules.includes(request);
15
-
16
- if (!isCoreModule) {
17
- if (request === serverRuntimeAlias) {
18
- const found = path.join(internalDirectory, serverRuntimePath);
19
-
20
- if (found) {
21
- // eslint-disable-next-line prefer-rest-params
22
- const modifiedArguments = [found, ...[].slice.call(arguments, 1)]; // Passes all arguments. Even those that is not specified above.
23
-
24
- return originalResolveFilename.apply(this, modifiedArguments);
25
- }
26
- }
27
- } // eslint-disable-next-line prefer-rest-params
28
-
29
-
30
- return originalResolveFilename.apply(this, arguments);
31
- };
32
-
33
- return () => {
34
- Module._resolveFilename = originalResolveFilename;
7
+ const paths = {
8
+ [serverRuntimeAlias]: path.join(internalDirectory, serverRuntimePath)
35
9
  };
10
+ const unRegister = registerPaths(paths);
11
+ return unRegister;
36
12
  };
37
13
 
38
14
  export { registerModernRuntimePath };
@@ -5,49 +5,23 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.registerModernRuntimePath = void 0;
7
7
 
8
- var _module = _interopRequireDefault(require("module"));
9
-
10
8
  var path = _interopRequireWildcard(require("path"));
11
9
 
10
+ var _bffCore = require("@modern-js/bff-core");
11
+
12
12
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
13
 
14
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
15
 
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
16
  const serverRuntimeAlias = '@modern-js/runtime/server';
19
17
  const serverRuntimePath = '.runtime-exports/server';
20
18
 
21
19
  const registerModernRuntimePath = internalDirectory => {
22
- const originalResolveFilename = _module.default._resolveFilename; // eslint-disable-next-line node/no-unsupported-features/node-builtins
23
-
24
- const {
25
- builtinModules
26
- } = _module.default;
27
-
28
- _module.default._resolveFilename = function (request, _parent) {
29
- const isCoreModule = builtinModules.includes(request);
30
-
31
- if (!isCoreModule) {
32
- if (request === serverRuntimeAlias) {
33
- const found = path.join(internalDirectory, serverRuntimePath);
34
-
35
- if (found) {
36
- // eslint-disable-next-line prefer-rest-params
37
- const modifiedArguments = [found, ...[].slice.call(arguments, 1)]; // Passes all arguments. Even those that is not specified above.
38
-
39
- return originalResolveFilename.apply(this, modifiedArguments);
40
- }
41
- }
42
- } // eslint-disable-next-line prefer-rest-params
43
-
44
-
45
- return originalResolveFilename.apply(this, arguments);
46
- };
47
-
48
- return () => {
49
- _module.default._resolveFilename = originalResolveFilename;
20
+ const paths = {
21
+ [serverRuntimeAlias]: path.join(internalDirectory, serverRuntimePath)
50
22
  };
23
+ const unRegister = (0, _bffCore.registerPaths)(paths);
24
+ return unRegister;
51
25
  };
52
26
 
53
27
  exports.registerModernRuntimePath = registerModernRuntimePath;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.6.0",
14
+ "version": "1.6.1",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -56,17 +56,17 @@
56
56
  "@babel/core": "^7.18.0",
57
57
  "@babel/runtime": "^7.18.0",
58
58
  "@modern-js/babel-compiler": "^1.2.6",
59
- "@modern-js/bff-core": "^1.1.0",
59
+ "@modern-js/bff-core": "^1.1.1",
60
60
  "@modern-js/create-request": "^1.3.0",
61
61
  "@modern-js/server-utils": "^1.2.11",
62
- "@modern-js/utils": "^1.7.9"
62
+ "@modern-js/utils": "^1.7.12"
63
63
  },
64
64
  "devDependencies": {
65
- "@modern-js/core": "1.12.2",
65
+ "@modern-js/core": "1.12.4",
66
66
  "@modern-js/plugin-analyze": "1.4.7",
67
67
  "@modern-js/runtime": "1.3.4",
68
68
  "@modern-js/server-core": "1.4.0",
69
- "@modern-js/types": "1.5.5",
69
+ "@modern-js/types": "1.5.6",
70
70
  "@scripts/build": "0.0.0",
71
71
  "@scripts/jest-config": "0.0.0",
72
72
  "@types/babel__core": "^7.1.15",