@modern-js/server 2.0.0-beta.4 → 2.0.0-beta.7

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 (36) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/dist/js/modern/dev-tools/dev-middleware/hmr-client/index.js +2 -2
  3. package/dist/js/modern/dev-tools/dev-middleware/index.js +22 -52
  4. package/dist/js/modern/dev-tools/https/index.js +19 -2
  5. package/dist/js/modern/index.js +1 -1
  6. package/dist/js/modern/server/dev-server.js +1 -2
  7. package/dist/js/node/constants.js +7 -3
  8. package/dist/js/node/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +8 -3
  9. package/dist/js/node/dev-tools/dev-middleware/hmr-client/index.js +2 -2
  10. package/dist/js/node/dev-tools/dev-middleware/index.js +45 -75
  11. package/dist/js/node/dev-tools/dev-middleware/socket-server.js +5 -3
  12. package/dist/js/node/dev-tools/https/index.js +28 -13
  13. package/dist/js/node/dev-tools/mock/getMockData.js +29 -27
  14. package/dist/js/node/dev-tools/mock/index.js +13 -9
  15. package/dist/js/node/dev-tools/register/index.js +24 -22
  16. package/dist/js/node/dev-tools/watcher/dependency-tree.js +8 -3
  17. package/dist/js/node/dev-tools/watcher/index.js +23 -19
  18. package/dist/js/node/dev-tools/watcher/stats-cache.js +7 -3
  19. package/dist/js/node/index.js +8 -4
  20. package/dist/js/node/server/dev-server.js +39 -54
  21. package/dist/js/node/server/index.js +7 -3
  22. package/dist/js/node/types.js +15 -0
  23. package/dist/js/treeshaking/dev-tools/dev-middleware/hmr-client/index.js +156 -156
  24. package/dist/js/treeshaking/dev-tools/dev-middleware/index.js +23 -65
  25. package/dist/js/treeshaking/dev-tools/https/index.js +39 -7
  26. package/dist/js/treeshaking/index.js +1 -1
  27. package/dist/js/treeshaking/server/dev-server.js +1 -2
  28. package/dist/types/dev-tools/dev-middleware/index.d.ts +1 -8
  29. package/dist/types/dev-tools/https/index.d.ts +1 -1
  30. package/dist/types/types.d.ts +22 -5
  31. package/package.json +13 -10
  32. package/dist/js/modern/dev-tools/dev-middleware/dev-server-plugin.js +0 -32
  33. package/dist/js/node/dev-tools/dev-middleware/dev-server-plugin.js +0 -57
  34. package/dist/js/treeshaking/dev-tools/dev-middleware/dev-server-plugin.js +0 -74
  35. package/dist/types/dev-tools/dev-middleware/dev-server-plugin.d.ts +0 -8
  36. package/temp-fix-hmr.js +0 -483
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.4",
14
+ "version": "2.0.0-beta.7",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -31,14 +31,13 @@
31
31
  "@babel/core": "^7.18.0",
32
32
  "@babel/register": "^7.17.7",
33
33
  "connect-history-api-fallback": "^2.0.0",
34
- "devcert": "^1.2.2",
35
34
  "minimatch": "^3.0.4",
36
35
  "path-to-regexp": "^6.2.0",
37
36
  "ws": "^8.2.0",
38
- "@modern-js/prod-server": "2.0.0-beta.4",
39
- "@modern-js/server-utils": "2.0.0-beta.4",
40
- "@modern-js/types": "2.0.0-beta.4",
41
- "@modern-js/utils": "2.0.0-beta.4"
37
+ "@modern-js/prod-server": "2.0.0-beta.7",
38
+ "@modern-js/server-utils": "2.0.0-beta.7",
39
+ "@modern-js/types": "2.0.0-beta.7",
40
+ "@modern-js/utils": "2.0.0-beta.7"
42
41
  },
43
42
  "devDependencies": {
44
43
  "@types/connect-history-api-fallback": "^1.3.5",
@@ -53,15 +52,19 @@
53
52
  "typescript": "^4",
54
53
  "webpack": "^5.75.0",
55
54
  "websocket": "^1",
56
- "@modern-js/server-core": "2.0.0-beta.4",
57
- "@scripts/build": "2.0.0-beta.4",
58
- "@scripts/jest-config": "2.0.0-beta.4"
55
+ "@modern-js/server-core": "2.0.0-beta.7",
56
+ "@scripts/build": "2.0.0-beta.7",
57
+ "@scripts/jest-config": "2.0.0-beta.7"
59
58
  },
60
59
  "peerDependencies": {
60
+ "devcert": "^1.0.0",
61
61
  "ts-node": "^10.1.0",
62
62
  "tsconfig-paths": ">= 3.0.0 || >= 4.0.0"
63
63
  },
64
64
  "peerDependenciesMeta": {
65
+ "devcert": {
66
+ "optional": true
67
+ },
65
68
  "ts-node": {
66
69
  "optional": true
67
70
  },
@@ -76,7 +79,7 @@
76
79
  },
77
80
  "scripts": {
78
81
  "new": "modern-lib new",
79
- "build": "modern-lib build && node ./temp-fix-hmr.js",
82
+ "build": "modern-lib build",
80
83
  "dev": "modern-lib build --watch",
81
84
  "test": "jest"
82
85
  }
@@ -1,32 +0,0 @@
1
- class DevServerPlugin {
2
- constructor(options) {
3
- this.options = options;
4
- }
5
- injectHMRClient(compiler) {
6
- const { client } = this.options;
7
- const host = (client == null ? void 0 : client.host) ? `&host=${client.host}` : "";
8
- const path = (client == null ? void 0 : client.path) ? `&path=${client.path}` : "";
9
- const port = (client == null ? void 0 : client.port) ? `&port=${client.port}` : "";
10
- const clientEntry = `${require.resolve("./hmr-client")}?${host}${path}${port}`;
11
- new compiler.webpack.EntryPlugin(compiler.context, clientEntry, {
12
- name: void 0
13
- }).apply(compiler);
14
- }
15
- apply(compiler) {
16
- if (this.options.hot || this.options.liveReload) {
17
- this.injectHMRClient(compiler);
18
- }
19
- const compilerOptions = compiler.options;
20
- const { HotModuleReplacementPlugin } = compiler.webpack;
21
- compilerOptions.plugins = compilerOptions.plugins || [];
22
- if (!compilerOptions.plugins.find(
23
- (p) => p.constructor === HotModuleReplacementPlugin
24
- )) {
25
- const plugin = new HotModuleReplacementPlugin();
26
- plugin.apply(compiler);
27
- }
28
- }
29
- }
30
- export {
31
- DevServerPlugin as default
32
- };
@@ -1,57 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
23
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
- var stdin_exports = {};
25
- __export(stdin_exports, {
26
- default: () => DevServerPlugin
27
- });
28
- module.exports = __toCommonJS(stdin_exports);
29
- class DevServerPlugin {
30
- constructor(options) {
31
- this.options = options;
32
- }
33
- injectHMRClient(compiler) {
34
- const { client } = this.options;
35
- const host = (client == null ? void 0 : client.host) ? `&host=${client.host}` : "";
36
- const path = (client == null ? void 0 : client.path) ? `&path=${client.path}` : "";
37
- const port = (client == null ? void 0 : client.port) ? `&port=${client.port}` : "";
38
- const clientEntry = `${require.resolve("./hmr-client")}?${host}${path}${port}`;
39
- new compiler.webpack.EntryPlugin(compiler.context, clientEntry, {
40
- name: void 0
41
- }).apply(compiler);
42
- }
43
- apply(compiler) {
44
- if (this.options.hot || this.options.liveReload) {
45
- this.injectHMRClient(compiler);
46
- }
47
- const compilerOptions = compiler.options;
48
- const { HotModuleReplacementPlugin } = compiler.webpack;
49
- compilerOptions.plugins = compilerOptions.plugins || [];
50
- if (!compilerOptions.plugins.find(
51
- (p) => p.constructor === HotModuleReplacementPlugin
52
- )) {
53
- const plugin = new HotModuleReplacementPlugin();
54
- plugin.apply(compiler);
55
- }
56
- }
57
- }
@@ -1,74 +0,0 @@
1
- function _classCallCheck(instance, Constructor) {
2
- if (!(instance instanceof Constructor)) {
3
- throw new TypeError("Cannot call a class as a function");
4
- }
5
- }
6
- function _defineProperties(target, props) {
7
- for(var i = 0; i < props.length; i++){
8
- var descriptor = props[i];
9
- descriptor.enumerable = descriptor.enumerable || false;
10
- descriptor.configurable = true;
11
- if ("value" in descriptor) descriptor.writable = true;
12
- Object.defineProperty(target, descriptor.key, descriptor);
13
- }
14
- }
15
- function _createClass(Constructor, protoProps, staticProps) {
16
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
- if (staticProps) _defineProperties(Constructor, staticProps);
18
- return Constructor;
19
- }
20
- function _defineProperty(obj, key, value) {
21
- if (key in obj) {
22
- Object.defineProperty(obj, key, {
23
- value: value,
24
- enumerable: true,
25
- configurable: true,
26
- writable: true
27
- });
28
- } else {
29
- obj[key] = value;
30
- }
31
- return obj;
32
- }
33
- var DevServerPlugin = /*#__PURE__*/ function() {
34
- "use strict";
35
- function DevServerPlugin(options) {
36
- _classCallCheck(this, DevServerPlugin);
37
- _defineProperty(this, "options", void 0);
38
- this.options = options;
39
- }
40
- _createClass(DevServerPlugin, [
41
- {
42
- key: "injectHMRClient",
43
- value: function injectHMRClient(compiler) {
44
- var client = this.options.client;
45
- var host = (client === null || client === void 0 ? void 0 : client.host) ? "&host=".concat(client.host) : "";
46
- var path = (client === null || client === void 0 ? void 0 : client.path) ? "&path=".concat(client.path) : "";
47
- var port = (client === null || client === void 0 ? void 0 : client.port) ? "&port=".concat(client.port) : "";
48
- var clientEntry = "".concat(require.resolve("./hmr-client"), "?").concat(host).concat(path).concat(port);
49
- new compiler.webpack.EntryPlugin(compiler.context, clientEntry, {
50
- name: void 0
51
- }).apply(compiler);
52
- }
53
- },
54
- {
55
- key: "apply",
56
- value: function apply(compiler) {
57
- if (this.options.hot || this.options.liveReload) {
58
- this.injectHMRClient(compiler);
59
- }
60
- var compilerOptions = compiler.options;
61
- var HotModuleReplacementPlugin = compiler.webpack.HotModuleReplacementPlugin;
62
- compilerOptions.plugins = compilerOptions.plugins || [];
63
- if (!compilerOptions.plugins.find(function(p) {
64
- return p.constructor === HotModuleReplacementPlugin;
65
- })) {
66
- var plugin = new HotModuleReplacementPlugin();
67
- plugin.apply(compiler);
68
- }
69
- }
70
- }
71
- ]);
72
- return DevServerPlugin;
73
- }();
74
- export { DevServerPlugin as default };
@@ -1,8 +0,0 @@
1
- import type webpack from 'webpack';
2
- import type { DevServerOptions } from '../../types';
3
- export default class DevServerPlugin {
4
- private readonly options;
5
- constructor(options: DevServerOptions);
6
- injectHMRClient(compiler: webpack.Compiler): void;
7
- apply(compiler: webpack.Compiler): void;
8
- }