@modern-js/plugin-server 1.1.9 → 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 CHANGED
@@ -1,5 +1,20 @@
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
+
3
18
  ## 1.1.9
4
19
 
5
20
  ### Patch Changes
@@ -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.middlewares = [];
8
- this.hooks = {};
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
- var _storage$hooks$before, _storage$hooks;
74
+ if (!storage.hooks.beforeMatch) {
75
+ return next();
76
+ }
72
77
 
73
- return (_storage$hooks$before = (_storage$hooks = storage.hooks).beforeMatch) === null || _storage$hooks$before === void 0 ? void 0 : _storage$hooks$before.call(_storage$hooks, context, next);
78
+ return storage.hooks.beforeMatch(context, next);
74
79
  },
75
80
 
76
81
  afterMatch({
77
82
  context,
78
83
  routeAPI
79
84
  }, next) {
80
- var _storage$hooks$afterM, _storage$hooks2;
85
+ if (!storage.hooks.afterMatch) {
86
+ return next();
87
+ }
81
88
 
82
89
  context.router = routeAPI;
83
- return (_storage$hooks$afterM = (_storage$hooks2 = storage.hooks).afterMatch) === null || _storage$hooks$afterM === void 0 ? void 0 : _storage$hooks$afterM.call(_storage$hooks2, context, next);
90
+ return storage.hooks.afterMatch(context, next);
84
91
  },
85
92
 
86
93
  beforeRender({
87
94
  context
88
95
  }, next) {
89
- var _storage$hooks$before2, _storage$hooks3;
96
+ if (!storage.hooks.beforeRender) {
97
+ return next();
98
+ }
90
99
 
91
- return (_storage$hooks$before2 = (_storage$hooks3 = storage.hooks).beforeRender) === null || _storage$hooks$before2 === void 0 ? void 0 : _storage$hooks$before2.call(_storage$hooks3, context, next);
100
+ return storage.hooks.beforeRender(context, next);
92
101
  },
93
102
 
94
103
  afterRender({
95
104
  context,
96
105
  templateAPI
97
106
  }, next) {
98
- var _storage$hooks$afterR, _storage$hooks4;
107
+ if (!storage.hooks.afterRender) {
108
+ return next();
109
+ }
99
110
 
100
111
  context.template = templateAPI;
101
- return (_storage$hooks$afterR = (_storage$hooks4 = storage.hooks).afterRender) === null || _storage$hooks$afterR === void 0 ? void 0 : _storage$hooks$afterR.call(_storage$hooks4, context, next);
112
+ return storage.hooks.afterRender(context, next);
102
113
  }
103
114
 
104
115
  };
@@ -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.middlewares = [];
19
- this.hooks = {};
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
- var _storage$hooks$before, _storage$hooks;
87
+ if (!storage.hooks.beforeMatch) {
88
+ return next();
89
+ }
85
90
 
86
- return (_storage$hooks$before = (_storage$hooks = storage.hooks).beforeMatch) === null || _storage$hooks$before === void 0 ? void 0 : _storage$hooks$before.call(_storage$hooks, context, next);
91
+ return storage.hooks.beforeMatch(context, next);
87
92
  },
88
93
 
89
94
  afterMatch({
90
95
  context,
91
96
  routeAPI
92
97
  }, next) {
93
- var _storage$hooks$afterM, _storage$hooks2;
98
+ if (!storage.hooks.afterMatch) {
99
+ return next();
100
+ }
94
101
 
95
102
  context.router = routeAPI;
96
- return (_storage$hooks$afterM = (_storage$hooks2 = storage.hooks).afterMatch) === null || _storage$hooks$afterM === void 0 ? void 0 : _storage$hooks$afterM.call(_storage$hooks2, context, next);
103
+ return storage.hooks.afterMatch(context, next);
97
104
  },
98
105
 
99
106
  beforeRender({
100
107
  context
101
108
  }, next) {
102
- var _storage$hooks$before2, _storage$hooks3;
109
+ if (!storage.hooks.beforeRender) {
110
+ return next();
111
+ }
103
112
 
104
- return (_storage$hooks$before2 = (_storage$hooks3 = storage.hooks).beforeRender) === null || _storage$hooks$before2 === void 0 ? void 0 : _storage$hooks$before2.call(_storage$hooks3, context, next);
113
+ return storage.hooks.beforeRender(context, next);
105
114
  },
106
115
 
107
116
  afterRender({
108
117
  context,
109
118
  templateAPI
110
119
  }, next) {
111
- var _storage$hooks$afterR, _storage$hooks4;
120
+ if (!storage.hooks.afterRender) {
121
+ return next();
122
+ }
112
123
 
113
124
  context.template = templateAPI;
114
- return (_storage$hooks$afterR = (_storage$hooks4 = storage.hooks).afterRender) === null || _storage$hooks$afterR === void 0 ? void 0 : _storage$hooks$afterR.call(_storage$hooks4, context, next);
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
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
-
3
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
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.middlewares = [];
16
- this.hooks = {};
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
- return (_storage$hooks$before = (_storage$hooks = storage.hooks).beforeMatch) === null || _storage$hooks$before === void 0 ? void 0 : _storage$hooks$before.call(_storage$hooks, context, next);
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 (_storage$hooks$afterM = (_storage$hooks2 = storage.hooks).afterMatch) === null || _storage$hooks$afterM === void 0 ? void 0 : _storage$hooks$afterM.call(_storage$hooks2, context, next);
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
- return (_storage$hooks$before2 = (_storage$hooks3 = storage.hooks).beforeRender) === null || _storage$hooks$before2 === void 0 ? void 0 : _storage$hooks$before2.call(_storage$hooks3, context, next);
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 (_storage$hooks$afterR = (_storage$hooks4 = storage.hooks).afterRender) === null || _storage$hooks$afterR === void 0 ? void 0 : _storage$hooks$afterR.call(_storage$hooks4, context, next);
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.9",
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,17 +48,17 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@babel/runtime": "^7",
51
- "@modern-js/babel-compiler": "^1.2.4",
52
- "@modern-js/server-utils": "^1.2.5",
53
- "@modern-js/utils": "^1.7.2"
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.4",
57
- "@modern-js/core": "1.10.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": "1.5.2",
59
+ "@modern-js/types": "1.5.3",
60
60
  "typescript": "^4",
61
- "@types/jest": "^26.0.9",
61
+ "@types/jest": "^27",
62
62
  "@types/node": "^14",
63
63
  "jest": "^27",
64
64
  "@scripts/jest-config": "0.0.0"
@@ -73,11 +73,33 @@
73
73
  "access": "public",
74
74
  "registry": "https://registry.npmjs.org/"
75
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
+ },
76
98
  "scripts": {
77
99
  "dev": "modern dev",
78
- "build": "modern build",
100
+ "build": "wireit",
79
101
  "new": "modern new",
80
- "test": "jest --passWithNoTests"
102
+ "test": "wireit"
81
103
  },
82
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"
83
105
  }
package/.eslintrc.js DELETED
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- extends: ['@modern-js'],
3
- parserOptions: {
4
- project: require.resolve('./tsconfig.json'),
5
- },
6
- ignorePatterns: ['types.d.ts'],
7
- };
package/jest.config.js DELETED
@@ -1,7 +0,0 @@
1
- const sharedConfig = require('@scripts/jest-config');
2
-
3
- /** @type {import('@jest/types').Config.InitialOptions} */
4
- module.exports = {
5
- ...sharedConfig,
6
- rootDir: __dirname,
7
- };
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "paths": {}
8
- },
9
- "include": ["src"]
10
- }