@modern-js/plugin-server 1.1.7 → 1.1.10
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 +45 -0
- package/dist/js/modern/server.js +21 -10
- package/dist/js/node/server.js +21 -10
- package/dist/js/treeshaking/cli.js +1 -5
- package/dist/js/treeshaking/server.js +30 -20
- package/package.json +32 -11
- package/.eslintrc.js +0 -7
- package/jest.config.js +0 -7
- package/tsconfig.json +0 -10
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,50 @@
|
|
1
1
|
# @modern-js/plugin-server
|
2
2
|
|
3
|
+
## 1.1.10
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- d32f35134: chore: add modern/jest/eslint/ts config files to .npmignore
|
8
|
+
- d4c456761: plugin-server should run next if hook not exist
|
9
|
+
- Updated dependencies [d32f35134]
|
10
|
+
- Updated dependencies [6ae4a34ae]
|
11
|
+
- Updated dependencies [b80229c79]
|
12
|
+
- Updated dependencies [1a30be07b]
|
13
|
+
- Updated dependencies [948cc4436]
|
14
|
+
- @modern-js/server-utils@1.2.6
|
15
|
+
- @modern-js/babel-compiler@1.2.5
|
16
|
+
- @modern-js/utils@1.7.3
|
17
|
+
|
18
|
+
## 1.1.9
|
19
|
+
|
20
|
+
### Patch Changes
|
21
|
+
|
22
|
+
- 69a728375: fix: remove exports.jsnext:source after publish
|
23
|
+
- Updated dependencies [cd7346b0d]
|
24
|
+
- Updated dependencies [0e0537005]
|
25
|
+
- Updated dependencies [69a728375]
|
26
|
+
- @modern-js/utils@1.7.2
|
27
|
+
- @modern-js/server-utils@1.2.5
|
28
|
+
- @modern-js/babel-compiler@1.2.4
|
29
|
+
|
30
|
+
## 1.1.8
|
31
|
+
|
32
|
+
### Patch Changes
|
33
|
+
|
34
|
+
- 895fa0ff: chore: using "workspace:\*" in devDependencies
|
35
|
+
- Updated dependencies [2d155c4c]
|
36
|
+
- Updated dependencies [123e432d]
|
37
|
+
- Updated dependencies [e5a9b26d]
|
38
|
+
- Updated dependencies [0b26b93b]
|
39
|
+
- Updated dependencies [123e432d]
|
40
|
+
- Updated dependencies [f9f66ef9]
|
41
|
+
- Updated dependencies [592edabc]
|
42
|
+
- Updated dependencies [895fa0ff]
|
43
|
+
- Updated dependencies [3578913e]
|
44
|
+
- Updated dependencies [1c3beab3]
|
45
|
+
- @modern-js/utils@1.6.0
|
46
|
+
- @modern-js/server-utils@1.2.4
|
47
|
+
|
3
48
|
## 1.1.7
|
4
49
|
|
5
50
|
### Patch Changes
|
package/dist/js/modern/server.js
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
2
|
+
|
1
3
|
import path from 'path';
|
2
4
|
import { isProd, requireExistModule, SERVER_DIR } from '@modern-js/utils';
|
3
5
|
const WEB_APP_NAME = 'index';
|
4
6
|
|
5
7
|
class Storage {
|
6
8
|
constructor() {
|
7
|
-
this
|
8
|
-
|
9
|
+
_defineProperty(this, "middlewares", []);
|
10
|
+
|
11
|
+
_defineProperty(this, "hooks", {});
|
9
12
|
}
|
10
13
|
|
11
14
|
reset() {
|
@@ -68,37 +71,45 @@ export default (() => ({
|
|
68
71
|
beforeMatch({
|
69
72
|
context
|
70
73
|
}, next) {
|
71
|
-
|
74
|
+
if (!storage.hooks.beforeMatch) {
|
75
|
+
return next();
|
76
|
+
}
|
72
77
|
|
73
|
-
return
|
78
|
+
return storage.hooks.beforeMatch(context, next);
|
74
79
|
},
|
75
80
|
|
76
81
|
afterMatch({
|
77
82
|
context,
|
78
83
|
routeAPI
|
79
84
|
}, next) {
|
80
|
-
|
85
|
+
if (!storage.hooks.afterMatch) {
|
86
|
+
return next();
|
87
|
+
}
|
81
88
|
|
82
89
|
context.router = routeAPI;
|
83
|
-
return
|
90
|
+
return storage.hooks.afterMatch(context, next);
|
84
91
|
},
|
85
92
|
|
86
93
|
beforeRender({
|
87
94
|
context
|
88
95
|
}, next) {
|
89
|
-
|
96
|
+
if (!storage.hooks.beforeRender) {
|
97
|
+
return next();
|
98
|
+
}
|
90
99
|
|
91
|
-
return
|
100
|
+
return storage.hooks.beforeRender(context, next);
|
92
101
|
},
|
93
102
|
|
94
103
|
afterRender({
|
95
104
|
context,
|
96
105
|
templateAPI
|
97
106
|
}, next) {
|
98
|
-
|
107
|
+
if (!storage.hooks.afterRender) {
|
108
|
+
return next();
|
109
|
+
}
|
99
110
|
|
100
111
|
context.template = templateAPI;
|
101
|
-
return
|
112
|
+
return storage.hooks.afterRender(context, next);
|
102
113
|
}
|
103
114
|
|
104
115
|
};
|
package/dist/js/node/server.js
CHANGED
@@ -11,12 +11,15 @@ var _utils = require("@modern-js/utils");
|
|
11
11
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
13
|
|
14
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
15
|
+
|
14
16
|
const WEB_APP_NAME = 'index';
|
15
17
|
|
16
18
|
class Storage {
|
17
19
|
constructor() {
|
18
|
-
this
|
19
|
-
|
20
|
+
_defineProperty(this, "middlewares", []);
|
21
|
+
|
22
|
+
_defineProperty(this, "hooks", {});
|
20
23
|
}
|
21
24
|
|
22
25
|
reset() {
|
@@ -81,37 +84,45 @@ var _default = () => ({
|
|
81
84
|
beforeMatch({
|
82
85
|
context
|
83
86
|
}, next) {
|
84
|
-
|
87
|
+
if (!storage.hooks.beforeMatch) {
|
88
|
+
return next();
|
89
|
+
}
|
85
90
|
|
86
|
-
return
|
91
|
+
return storage.hooks.beforeMatch(context, next);
|
87
92
|
},
|
88
93
|
|
89
94
|
afterMatch({
|
90
95
|
context,
|
91
96
|
routeAPI
|
92
97
|
}, next) {
|
93
|
-
|
98
|
+
if (!storage.hooks.afterMatch) {
|
99
|
+
return next();
|
100
|
+
}
|
94
101
|
|
95
102
|
context.router = routeAPI;
|
96
|
-
return
|
103
|
+
return storage.hooks.afterMatch(context, next);
|
97
104
|
},
|
98
105
|
|
99
106
|
beforeRender({
|
100
107
|
context
|
101
108
|
}, next) {
|
102
|
-
|
109
|
+
if (!storage.hooks.beforeRender) {
|
110
|
+
return next();
|
111
|
+
}
|
103
112
|
|
104
|
-
return
|
113
|
+
return storage.hooks.beforeRender(context, next);
|
105
114
|
},
|
106
115
|
|
107
116
|
afterRender({
|
108
117
|
context,
|
109
118
|
templateAPI
|
110
119
|
}, next) {
|
111
|
-
|
120
|
+
if (!storage.hooks.afterRender) {
|
121
|
+
return next();
|
122
|
+
}
|
112
123
|
|
113
124
|
context.template = templateAPI;
|
114
|
-
return
|
125
|
+
return storage.hooks.afterRender(context, next);
|
115
126
|
}
|
116
127
|
|
117
128
|
};
|
@@ -1,9 +1,5 @@
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
1
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
2
|
-
|
3
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
4
|
-
|
5
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
6
|
-
|
7
3
|
import fs from 'fs';
|
8
4
|
import path from 'path';
|
9
5
|
import { compiler } from '@modern-js/babel-compiler';
|
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
6
|
-
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
7
4
|
import path from 'path';
|
8
5
|
import { isProd, requireExistModule, SERVER_DIR } from '@modern-js/utils';
|
9
6
|
var WEB_APP_NAME = 'index';
|
@@ -12,8 +9,9 @@ var Storage = /*#__PURE__*/function () {
|
|
12
9
|
function Storage() {
|
13
10
|
_classCallCheck(this, Storage);
|
14
11
|
|
15
|
-
this
|
16
|
-
|
12
|
+
_defineProperty(this, "middlewares", []);
|
13
|
+
|
14
|
+
_defineProperty(this, "hooks", {});
|
17
15
|
}
|
18
16
|
|
19
17
|
_createClass(Storage, [{
|
@@ -80,32 +78,44 @@ export default (function () {
|
|
80
78
|
});
|
81
79
|
},
|
82
80
|
beforeMatch: function beforeMatch(_ref2, next) {
|
83
|
-
var _storage$hooks$before, _storage$hooks;
|
84
|
-
|
85
81
|
var context = _ref2.context;
|
86
|
-
|
82
|
+
|
83
|
+
if (!storage.hooks.beforeMatch) {
|
84
|
+
return next();
|
85
|
+
}
|
86
|
+
|
87
|
+
return storage.hooks.beforeMatch(context, next);
|
87
88
|
},
|
88
89
|
afterMatch: function afterMatch(_ref3, next) {
|
89
|
-
var _storage$hooks$afterM, _storage$hooks2;
|
90
|
-
|
91
90
|
var context = _ref3.context,
|
92
91
|
routeAPI = _ref3.routeAPI;
|
92
|
+
|
93
|
+
if (!storage.hooks.afterMatch) {
|
94
|
+
return next();
|
95
|
+
}
|
96
|
+
|
93
97
|
context.router = routeAPI;
|
94
|
-
return
|
98
|
+
return storage.hooks.afterMatch(context, next);
|
95
99
|
},
|
96
100
|
beforeRender: function beforeRender(_ref4, next) {
|
97
|
-
var _storage$hooks$before2, _storage$hooks3;
|
98
|
-
|
99
101
|
var context = _ref4.context;
|
100
|
-
|
102
|
+
|
103
|
+
if (!storage.hooks.beforeRender) {
|
104
|
+
return next();
|
105
|
+
}
|
106
|
+
|
107
|
+
return storage.hooks.beforeRender(context, next);
|
101
108
|
},
|
102
109
|
afterRender: function afterRender(_ref5, next) {
|
103
|
-
var _storage$hooks$afterR, _storage$hooks4;
|
104
|
-
|
105
110
|
var context = _ref5.context,
|
106
111
|
templateAPI = _ref5.templateAPI;
|
112
|
+
|
113
|
+
if (!storage.hooks.afterRender) {
|
114
|
+
return next();
|
115
|
+
}
|
116
|
+
|
107
117
|
context.template = templateAPI;
|
108
|
-
return
|
118
|
+
return storage.hooks.afterRender(context, next);
|
109
119
|
}
|
110
120
|
};
|
111
121
|
}
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.1.
|
14
|
+
"version": "1.1.10",
|
15
15
|
"types": "./dist/types/server.d.ts",
|
16
16
|
"jsnext:source": "./src/server.ts",
|
17
17
|
"main": "./dist/js/node/server.js",
|
@@ -48,18 +48,17 @@
|
|
48
48
|
},
|
49
49
|
"dependencies": {
|
50
50
|
"@babel/runtime": "^7",
|
51
|
-
"@modern-js/babel-compiler": "^1.2.
|
52
|
-
"@modern-js/server-utils": "^1.2.
|
53
|
-
"@modern-js/utils": "^1.
|
51
|
+
"@modern-js/babel-compiler": "^1.2.5",
|
52
|
+
"@modern-js/server-utils": "^1.2.6",
|
53
|
+
"@modern-js/utils": "^1.7.3"
|
54
54
|
},
|
55
55
|
"devDependencies": {
|
56
|
-
"@modern-js/server-core": "1.3.
|
57
|
-
"@modern-js/core": "1.
|
56
|
+
"@modern-js/server-core": "1.3.5",
|
57
|
+
"@modern-js/core": "1.10.2",
|
58
58
|
"@scripts/build": "0.0.0",
|
59
|
-
"@modern-js/types": "
|
60
|
-
"del-cli": "^4.0.1",
|
59
|
+
"@modern-js/types": "1.5.3",
|
61
60
|
"typescript": "^4",
|
62
|
-
"@types/jest": "^
|
61
|
+
"@types/jest": "^27",
|
63
62
|
"@types/node": "^14",
|
64
63
|
"jest": "^27",
|
65
64
|
"@scripts/jest-config": "0.0.0"
|
@@ -74,11 +73,33 @@
|
|
74
73
|
"access": "public",
|
75
74
|
"registry": "https://registry.npmjs.org/"
|
76
75
|
},
|
76
|
+
"wireit": {
|
77
|
+
"build": {
|
78
|
+
"command": "modern build",
|
79
|
+
"files": [
|
80
|
+
"src/**/*",
|
81
|
+
"tsconfig.json",
|
82
|
+
"package.json"
|
83
|
+
],
|
84
|
+
"output": [
|
85
|
+
"dist/**/*"
|
86
|
+
]
|
87
|
+
},
|
88
|
+
"test": {
|
89
|
+
"command": "jest --passWithNoTests",
|
90
|
+
"files": [
|
91
|
+
"src/**/*",
|
92
|
+
"tsconfig.json",
|
93
|
+
"package.json"
|
94
|
+
],
|
95
|
+
"output": []
|
96
|
+
}
|
97
|
+
},
|
77
98
|
"scripts": {
|
78
99
|
"dev": "modern dev",
|
79
|
-
"build": "
|
100
|
+
"build": "wireit",
|
80
101
|
"new": "modern new",
|
81
|
-
"test": "
|
102
|
+
"test": "wireit"
|
82
103
|
},
|
83
104
|
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
84
105
|
}
|
package/.eslintrc.js
DELETED
package/jest.config.js
DELETED