@modern-js/plugin-server 1.1.5 → 1.1.6-canary.0

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.
@@ -33,18 +33,21 @@ export default (() => ({
33
33
  appDirectory,
34
34
  distDirectory
35
35
  } = api.useAppContext();
36
- const pwd = isProd() ? distDirectory : appDirectory;
37
- const serverPath = path.resolve(pwd, SERVER_DIR);
38
- const webAppPath = path.resolve(serverPath, WEB_APP_NAME);
39
36
  const storage = new Storage();
40
37
  const transformAPI = createTransformAPI(storage);
41
- const webMod = requireExistModule(webAppPath);
42
-
43
- if (webMod) {
44
- webMod(transformAPI);
45
- }
46
-
38
+ let webAppPath = '';
47
39
  return {
40
+ prepare() {
41
+ const pwd = isProd() ? distDirectory : appDirectory;
42
+ const serverPath = path.resolve(pwd, SERVER_DIR);
43
+ webAppPath = path.resolve(serverPath, WEB_APP_NAME);
44
+ const webMod = requireExistModule(webAppPath);
45
+
46
+ if (webMod) {
47
+ webMod(transformAPI);
48
+ }
49
+ },
50
+
48
51
  reset() {
49
52
  storage.reset();
50
53
  const newWebModule = requireExistModule(webAppPath);
@@ -44,21 +44,23 @@ var _default = () => ({
44
44
  appDirectory,
45
45
  distDirectory
46
46
  } = api.useAppContext();
47
- const pwd = (0, _utils.isProd)() ? distDirectory : appDirectory;
48
-
49
- const serverPath = _path.default.resolve(pwd, _utils.SERVER_DIR);
50
-
51
- const webAppPath = _path.default.resolve(serverPath, WEB_APP_NAME);
52
-
53
47
  const storage = new Storage();
54
48
  const transformAPI = createTransformAPI(storage);
55
- const webMod = (0, _utils.requireExistModule)(webAppPath);
49
+ let webAppPath = '';
50
+ return {
51
+ prepare() {
52
+ const pwd = (0, _utils.isProd)() ? distDirectory : appDirectory;
56
53
 
57
- if (webMod) {
58
- webMod(transformAPI);
59
- }
54
+ const serverPath = _path.default.resolve(pwd, _utils.SERVER_DIR);
55
+
56
+ webAppPath = _path.default.resolve(serverPath, WEB_APP_NAME);
57
+ const webMod = (0, _utils.requireExistModule)(webAppPath);
58
+
59
+ if (webMod) {
60
+ webMod(transformAPI);
61
+ }
62
+ },
60
63
 
61
- return {
62
64
  reset() {
63
65
  storage.reset();
64
66
  const newWebModule = (0, _utils.requireExistModule)(webAppPath);
@@ -51,18 +51,20 @@ export default (function () {
51
51
  appDirectory = _api$useAppContext.appDirectory,
52
52
  distDirectory = _api$useAppContext.distDirectory;
53
53
 
54
- var pwd = isProd() ? distDirectory : appDirectory;
55
- var serverPath = path.resolve(pwd, SERVER_DIR);
56
- var webAppPath = path.resolve(serverPath, WEB_APP_NAME);
57
54
  var storage = new Storage();
58
55
  var transformAPI = createTransformAPI(storage);
59
- var webMod = requireExistModule(webAppPath);
60
-
61
- if (webMod) {
62
- webMod(transformAPI);
63
- }
64
-
56
+ var webAppPath = '';
65
57
  return {
58
+ prepare: function prepare() {
59
+ var pwd = isProd() ? distDirectory : appDirectory;
60
+ var serverPath = path.resolve(pwd, SERVER_DIR);
61
+ webAppPath = path.resolve(serverPath, WEB_APP_NAME);
62
+ var webMod = requireExistModule(webAppPath);
63
+
64
+ if (webMod) {
65
+ webMod(transformAPI);
66
+ }
67
+ },
66
68
  reset: function reset() {
67
69
  storage.reset();
68
70
  var newWebModule = requireExistModule(webAppPath);
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.1.5",
14
+ "version": "1.1.6-canary.0",
15
15
  "types": "./dist/types/server.d.ts",
16
16
  "jsnext:source": "./src/server.ts",
17
17
  "main": "./dist/js/node/server.js",
@@ -72,7 +72,8 @@
72
72
  ],
73
73
  "publishConfig": {
74
74
  "access": "public",
75
- "registry": "https://registry.npmjs.org/"
75
+ "registry": "https://registry.npmjs.org/",
76
+ "types": "./dist/types/server.d.ts"
76
77
  },
77
78
  "scripts": {
78
79
  "dev": "modern dev",
@@ -20,6 +20,8 @@ describe('plugin-server', () => {
20
20
  }),
21
21
  } as any);
22
22
 
23
+ hooks.prepare();
24
+
23
25
  const sign = { status: 0 };
24
26
  hooks.gather({
25
27
  addWebMiddleware: (fn: any) => {