@modern-js/server 2.0.0-beta.3 → 2.0.0-beta.6

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 (62) hide show
  1. package/CHANGELOG.md +159 -0
  2. package/dist/js/modern/constants.js +10 -9
  3. package/dist/js/modern/dev-tools/dev-middleware/dev-server-plugin.js +14 -20
  4. package/dist/js/modern/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +14 -19
  5. package/dist/js/modern/dev-tools/dev-middleware/hmr-client/index.js +134 -184
  6. package/dist/js/modern/dev-tools/dev-middleware/hmr-client/types.d.js +0 -0
  7. package/dist/js/modern/dev-tools/dev-middleware/index.js +65 -60
  8. package/dist/js/modern/dev-tools/dev-middleware/socket-server.js +33 -59
  9. package/dist/js/modern/dev-tools/https/global.d.js +0 -0
  10. package/dist/js/modern/dev-tools/https/index.js +28 -5
  11. package/dist/js/modern/dev-tools/mock/getMockData.js +71 -45
  12. package/dist/js/modern/dev-tools/mock/index.js +34 -15
  13. package/dist/js/modern/dev-tools/register/index.js +71 -54
  14. package/dist/js/modern/dev-tools/watcher/dependency-tree.js +25 -34
  15. package/dist/js/modern/dev-tools/watcher/index.js +51 -33
  16. package/dist/js/modern/dev-tools/watcher/stats-cache.js +13 -20
  17. package/dist/js/modern/index.js +7 -4
  18. package/dist/js/modern/server/dev-server.js +191 -215
  19. package/dist/js/modern/server/index.js +7 -4
  20. package/dist/js/node/constants.js +31 -14
  21. package/dist/js/node/dev-tools/dev-middleware/dev-server-plugin.js +38 -24
  22. package/dist/js/node/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +36 -24
  23. package/dist/js/node/dev-tools/dev-middleware/hmr-client/index.js +56 -98
  24. package/dist/js/node/dev-tools/dev-middleware/hmr-client/types.d.js +0 -0
  25. package/dist/js/node/dev-tools/dev-middleware/index.js +94 -72
  26. package/dist/js/node/dev-tools/dev-middleware/socket-server.js +59 -66
  27. package/dist/js/node/dev-tools/https/global.d.js +0 -0
  28. package/dist/js/node/dev-tools/https/index.js +56 -13
  29. package/dist/js/node/dev-tools/mock/getMockData.js +90 -51
  30. package/dist/js/node/dev-tools/mock/index.js +66 -28
  31. package/dist/js/node/dev-tools/register/index.js +100 -64
  32. package/dist/js/node/dev-tools/watcher/dependency-tree.js +55 -43
  33. package/dist/js/node/dev-tools/watcher/index.js +83 -47
  34. package/dist/js/node/dev-tools/watcher/stats-cache.js +44 -30
  35. package/dist/js/node/index.js +29 -15
  36. package/dist/js/node/server/dev-server.js +220 -237
  37. package/dist/js/node/server/index.js +30 -11
  38. package/dist/js/node/types.js +15 -0
  39. package/dist/js/treeshaking/constants.js +21 -0
  40. package/dist/js/treeshaking/dev-tools/dev-middleware/dev-server-plugin.js +74 -0
  41. package/dist/js/treeshaking/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +51 -0
  42. package/dist/js/treeshaking/dev-tools/dev-middleware/hmr-client/index.js +157 -0
  43. package/dist/js/treeshaking/dev-tools/dev-middleware/hmr-client/types.d.js +1 -0
  44. package/dist/js/treeshaking/dev-tools/dev-middleware/index.js +363 -0
  45. package/dist/js/treeshaking/dev-tools/dev-middleware/socket-server.js +209 -0
  46. package/dist/js/treeshaking/dev-tools/https/global.d.js +1 -0
  47. package/dist/js/treeshaking/dev-tools/https/index.js +161 -0
  48. package/dist/js/treeshaking/dev-tools/mock/getMockData.js +327 -0
  49. package/dist/js/treeshaking/dev-tools/mock/index.js +191 -0
  50. package/dist/js/treeshaking/dev-tools/register/index.js +153 -0
  51. package/dist/js/treeshaking/dev-tools/watcher/dependency-tree.js +150 -0
  52. package/dist/js/treeshaking/dev-tools/watcher/index.js +200 -0
  53. package/dist/js/treeshaking/dev-tools/watcher/stats-cache.js +128 -0
  54. package/dist/js/treeshaking/index.js +9 -0
  55. package/dist/js/treeshaking/server/dev-server.js +800 -0
  56. package/dist/js/treeshaking/server/index.js +92 -0
  57. package/dist/js/treeshaking/types.js +1 -0
  58. package/dist/types/dev-tools/mock/getMockData.d.ts +2 -0
  59. package/dist/types/dev-tools/watcher/dependency-tree.d.ts +2 -0
  60. package/dist/types/dev-tools/watcher/index.d.ts +1 -1
  61. package/dist/types/index.d.ts +2 -0
  62. package/package.json +15 -12
@@ -0,0 +1,92 @@
1
+ function _assertThisInitialized(self) {
2
+ if (self === void 0) {
3
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4
+ }
5
+ return self;
6
+ }
7
+ function _classCallCheck(instance, Constructor) {
8
+ if (!(instance instanceof Constructor)) {
9
+ throw new TypeError("Cannot call a class as a function");
10
+ }
11
+ }
12
+ function _getPrototypeOf(o) {
13
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
14
+ return o.__proto__ || Object.getPrototypeOf(o);
15
+ };
16
+ return _getPrototypeOf(o);
17
+ }
18
+ function _inherits(subClass, superClass) {
19
+ if (typeof superClass !== "function" && superClass !== null) {
20
+ throw new TypeError("Super expression must either be null or a function");
21
+ }
22
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
23
+ constructor: {
24
+ value: subClass,
25
+ writable: true,
26
+ configurable: true
27
+ }
28
+ });
29
+ if (superClass) _setPrototypeOf(subClass, superClass);
30
+ }
31
+ function _possibleConstructorReturn(self, call) {
32
+ if (call && (_typeof(call) === "object" || typeof call === "function")) {
33
+ return call;
34
+ }
35
+ return _assertThisInitialized(self);
36
+ }
37
+ function _setPrototypeOf(o, p) {
38
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
39
+ o.__proto__ = p;
40
+ return o;
41
+ };
42
+ return _setPrototypeOf(o, p);
43
+ }
44
+ var _typeof = function(obj) {
45
+ "@swc/helpers - typeof";
46
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
47
+ };
48
+ function _isNativeReflectConstruct() {
49
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
50
+ if (Reflect.construct.sham) return false;
51
+ if (typeof Proxy === "function") return true;
52
+ try {
53
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
54
+ return true;
55
+ } catch (e) {
56
+ return false;
57
+ }
58
+ }
59
+ function _createSuper(Derived) {
60
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
61
+ return function _createSuperInternal() {
62
+ var Super = _getPrototypeOf(Derived), result;
63
+ if (hasNativeReflectConstruct) {
64
+ var NewTarget = _getPrototypeOf(this).constructor;
65
+ result = Reflect.construct(Super, arguments, NewTarget);
66
+ } else {
67
+ result = Super.apply(this, arguments);
68
+ }
69
+ return _possibleConstructorReturn(this, result);
70
+ };
71
+ }
72
+ import { Server } from "@modern-js/prod-server";
73
+ import { ModernDevServer } from "./dev-server";
74
+ var createDevServer = function(options) {
75
+ return new ModernDevServer(options);
76
+ };
77
+ var DevServer = /*#__PURE__*/ function(Server) {
78
+ "use strict";
79
+ _inherits(DevServer, Server);
80
+ var _super = _createSuper(DevServer);
81
+ function DevServer(options) {
82
+ _classCallCheck(this, DevServer);
83
+ var _this;
84
+ _this = _super.call(this, options);
85
+ if (options.dev) {
86
+ _this.serverImpl = createDevServer;
87
+ }
88
+ return _this;
89
+ }
90
+ return DevServer;
91
+ }(Server);
92
+ export { DevServer };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -11,6 +11,8 @@ export declare type MockApi = {
11
11
  };
12
12
  declare const createFunctionDataHandler: (method: string, handler: (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void) => (context: ModernServerContext, next: NextFunction) => Promise<void>;
13
13
  declare const createStaticDataHandler: (method: string, handler: Record<string, any>) => (context: ModernServerContext) => void;
14
+
14
15
  declare const _default: (filepath: string) => MockApi[];
16
+
15
17
  export default _default;
16
18
  export declare const getMatched: (context: ModernServerContext, mockApiList: MockApi[]) => MockApi | undefined;
@@ -14,6 +14,7 @@ export interface TreeNode {
14
14
  * `module.parent` is the module that first required. so we have to implement
15
15
  * a new tree which revisit the cache tree to find all parent node
16
16
  */
17
+
17
18
  export declare class DependencyTree {
18
19
  private readonly tree;
19
20
  private readonly ignore;
@@ -24,6 +25,7 @@ export declare class DependencyTree {
24
25
  *
25
26
  * @param cache
26
27
  */
28
+
27
29
  update(cache: any): void;
28
30
  private shouldIgnore;
29
31
  }
@@ -5,7 +5,7 @@ export declare const defaultWatchOptions: {
5
5
  ignored: RegExp;
6
6
  };
7
7
  export declare const getWatchedFiles: (watcher: FSWatcher) => string[];
8
- export declare const mergeWatchOptions: (options?: any) => any;
8
+ export declare const mergeWatchOptions: (options?: WatchOptions) => WatchOptions;
9
9
  export default class Watcher {
10
10
  private dependencyTree;
11
11
  private watcher;
@@ -2,5 +2,7 @@ import { DevServer as Server } from './server';
2
2
  import type { ModernDevServerOptions } from './types';
3
3
  export { Server };
4
4
  export type { ModernDevServerOptions };
5
+
5
6
  declare const _default: (options: ModernDevServerOptions) => Promise<Server>;
7
+
6
8
  export default _default;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.3",
14
+ "version": "2.0.0-beta.6",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -35,10 +35,10 @@
35
35
  "minimatch": "^3.0.4",
36
36
  "path-to-regexp": "^6.2.0",
37
37
  "ws": "^8.2.0",
38
- "@modern-js/prod-server": "2.0.0-beta.3",
39
- "@modern-js/server-utils": "2.0.0-beta.3",
40
- "@modern-js/types": "2.0.0-beta.3",
41
- "@modern-js/utils": "2.0.0-beta.3"
38
+ "@modern-js/prod-server": "2.0.0-beta.6",
39
+ "@modern-js/server-utils": "2.0.0-beta.6",
40
+ "@modern-js/types": "2.0.0-beta.6",
41
+ "@modern-js/utils": "2.0.0-beta.6"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/connect-history-api-fallback": "^1.3.5",
@@ -53,20 +53,23 @@
53
53
  "typescript": "^4",
54
54
  "webpack": "^5.75.0",
55
55
  "websocket": "^1",
56
- "@modern-js/server-core": "2.0.0-beta.3",
57
- "@scripts/build": "2.0.0-beta.3",
58
- "@scripts/jest-config": "2.0.0-beta.3"
56
+ "@modern-js/server-core": "2.0.0-beta.6",
57
+ "@scripts/jest-config": "2.0.0-beta.6",
58
+ "@scripts/build": "2.0.0-beta.6"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "ts-node": "^10.1.0",
62
62
  "tsconfig-paths": ">= 3.0.0 || >= 4.0.0"
63
63
  },
64
- "sideEffects": false,
65
- "modernConfig": {
66
- "output": {
67
- "packageMode": "node-js"
64
+ "peerDependenciesMeta": {
65
+ "ts-node": {
66
+ "optional": true
67
+ },
68
+ "tsconfig-paths": {
69
+ "optional": true
68
70
  }
69
71
  },
72
+ "sideEffects": false,
70
73
  "publishConfig": {
71
74
  "registry": "https://registry.npmjs.org/",
72
75
  "access": "public"