@modern-js/plugin-server 0.0.0-next-20221209071922 → 0.0.0-next-20221209140613
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 +42 -4
- package/dist/js/modern/cli.js +48 -67
- package/dist/js/modern/server.js +59 -64
- package/dist/js/node/cli.js +54 -90
- package/dist/js/node/server.js +68 -85
- package/dist/js/treeshaking/cli.js +59 -186
- package/dist/js/treeshaking/server.js +131 -186
- package/dist/types/cli.d.ts +0 -2
- package/dist/types/server.d.ts +0 -2
- package/package.json +9 -9
- package/dist/js/modern/modern-app-env.d.js +0 -0
- package/dist/js/node/modern-app-env.d.js +0 -0
- package/dist/js/treeshaking/modern-app-env.d.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @modern-js/plugin-server
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20221209140613
|
|
4
4
|
|
|
5
5
|
### Major Changes
|
|
6
6
|
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
- 3bbea92b2: feat: support Hook、Middleware new API
|
|
12
12
|
feat: 支持 Hook、Middleware 的新 API
|
|
13
13
|
- Updated dependencies [9b915e0c1]
|
|
14
|
+
- Updated dependencies [7879e8f71]
|
|
14
15
|
- Updated dependencies [d4e8e6fb9]
|
|
15
16
|
- Updated dependencies [6aca87501]
|
|
16
17
|
- Updated dependencies [2e6031955]
|
|
@@ -26,14 +27,51 @@
|
|
|
26
27
|
- Updated dependencies [dda38c9c3]
|
|
27
28
|
- Updated dependencies [3bbea92b2]
|
|
28
29
|
- Updated dependencies [b710adb84]
|
|
30
|
+
- Updated dependencies [ea7cf0625]
|
|
29
31
|
- Updated dependencies [bbe4c4ab6]
|
|
30
32
|
- Updated dependencies [e4558a0bc]
|
|
31
33
|
- Updated dependencies [abf3421a7]
|
|
32
34
|
- Updated dependencies [543be9558]
|
|
33
35
|
- Updated dependencies [14b712da8]
|
|
34
|
-
- @modern-js/server-utils@0.0.0-next-
|
|
35
|
-
- @modern-js/utils@0.0.0-next-
|
|
36
|
-
- @modern-js/babel-compiler@0.0.0-next-
|
|
36
|
+
- @modern-js/server-utils@0.0.0-next-20221209140613
|
|
37
|
+
- @modern-js/utils@0.0.0-next-20221209140613
|
|
38
|
+
- @modern-js/babel-compiler@0.0.0-next-20221209140613
|
|
39
|
+
|
|
40
|
+
## 2.0.0-beta.3
|
|
41
|
+
|
|
42
|
+
### Major Changes
|
|
43
|
+
|
|
44
|
+
- dda38c9c3e: chore: v2
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- 3bbea92b2a: feat: support Hook、Middleware new API
|
|
49
|
+
feat: 支持 Hook、Middleware 的新 API
|
|
50
|
+
- Updated dependencies [9b915e0c10]
|
|
51
|
+
- Updated dependencies [d4e8e6f]
|
|
52
|
+
- Updated dependencies [6aca875]
|
|
53
|
+
- Updated dependencies [2e60319]
|
|
54
|
+
- Updated dependencies [92f0eade39]
|
|
55
|
+
- Updated dependencies [edd1cfb1af]
|
|
56
|
+
- Updated dependencies [cc971eabfc]
|
|
57
|
+
- Updated dependencies [5b9049f2e9]
|
|
58
|
+
- Updated dependencies [a8642da58f]
|
|
59
|
+
- Updated dependencies [92004d1906]
|
|
60
|
+
- Updated dependencies [b8bbe036c7]
|
|
61
|
+
- Updated dependencies [c2bb0f1]
|
|
62
|
+
- Updated dependencies [d5a31df781]
|
|
63
|
+
- Updated dependencies [dda38c9c3e]
|
|
64
|
+
- Updated dependencies [3bbea92b2a]
|
|
65
|
+
- Updated dependencies [b710adb]
|
|
66
|
+
- Updated dependencies [ea7cf06]
|
|
67
|
+
- Updated dependencies [bbe4c4a]
|
|
68
|
+
- Updated dependencies [e4558a0]
|
|
69
|
+
- Updated dependencies [abf3421a75]
|
|
70
|
+
- Updated dependencies [543be9558e]
|
|
71
|
+
- Updated dependencies [14b712da84]
|
|
72
|
+
- @modern-js/server-utils@2.0.0-beta.3
|
|
73
|
+
- @modern-js/utils@2.0.0-beta.3
|
|
74
|
+
- @modern-js/babel-compiler@2.0.0-beta.3
|
|
37
75
|
|
|
38
76
|
## 2.0.0-beta.2
|
|
39
77
|
|
package/dist/js/modern/cli.js
CHANGED
|
@@ -1,72 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
import fs from "fs";
|
|
22
|
-
import path from "path";
|
|
23
|
-
import { compile } from "@modern-js/server-utils";
|
|
24
|
-
import { SHARED_DIR, SERVER_DIR } from "@modern-js/utils";
|
|
25
|
-
const TS_CONFIG_FILENAME = "tsconfig.json";
|
|
26
|
-
var cli_default = () => ({
|
|
27
|
-
name: "@modern-js/plugin-server",
|
|
28
|
-
setup: (api) => ({
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { compile } from '@modern-js/server-utils';
|
|
4
|
+
import { SHARED_DIR, SERVER_DIR } from '@modern-js/utils';
|
|
5
|
+
const TS_CONFIG_FILENAME = 'tsconfig.json';
|
|
6
|
+
export default (() => ({
|
|
7
|
+
name: '@modern-js/plugin-server',
|
|
8
|
+
setup: api => ({
|
|
29
9
|
config() {
|
|
30
10
|
return {};
|
|
31
11
|
},
|
|
32
|
-
afterBuild() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
12
|
+
async afterBuild() {
|
|
13
|
+
const {
|
|
14
|
+
appDirectory,
|
|
15
|
+
distDirectory
|
|
16
|
+
} = api.useAppContext();
|
|
17
|
+
const modernConfig = api.useResolvedConfigContext();
|
|
18
|
+
const distDir = path.resolve(distDirectory);
|
|
19
|
+
const serverDir = path.resolve(appDirectory, SERVER_DIR);
|
|
20
|
+
const sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
|
21
|
+
const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
22
|
+
const sourceDirs = [];
|
|
23
|
+
if (fs.existsSync(serverDir)) {
|
|
24
|
+
sourceDirs.push(serverDir);
|
|
25
|
+
}
|
|
26
|
+
if (fs.existsSync(sharedDir)) {
|
|
27
|
+
sourceDirs.push(sharedDir);
|
|
28
|
+
}
|
|
29
|
+
const {
|
|
30
|
+
server
|
|
31
|
+
} = modernConfig;
|
|
32
|
+
const {
|
|
33
|
+
alias,
|
|
34
|
+
globalVars
|
|
35
|
+
} = modernConfig.source;
|
|
36
|
+
const {
|
|
37
|
+
babel
|
|
38
|
+
} = modernConfig.tools;
|
|
39
|
+
if (sourceDirs.length > 0) {
|
|
40
|
+
await compile(appDirectory, {
|
|
41
|
+
server,
|
|
42
|
+
alias,
|
|
43
|
+
globalVars,
|
|
44
|
+
babelConfig: babel
|
|
45
|
+
}, {
|
|
46
|
+
sourceDirs,
|
|
47
|
+
distDir,
|
|
48
|
+
tsconfigPath
|
|
49
|
+
});
|
|
50
|
+
}
|
|
67
51
|
}
|
|
68
52
|
})
|
|
69
|
-
});
|
|
70
|
-
export {
|
|
71
|
-
cli_default as default
|
|
72
|
-
};
|
|
53
|
+
}));
|
package/dist/js/modern/server.js
CHANGED
|
@@ -1,75 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
import path from "path";
|
|
17
|
-
import {
|
|
18
|
-
isProd,
|
|
19
|
-
logger,
|
|
20
|
-
requireExistModule,
|
|
21
|
-
SERVER_DIR
|
|
22
|
-
} from "@modern-js/utils";
|
|
23
|
-
const WEB_APP_NAME = "index";
|
|
24
|
-
var HOOKS = /* @__PURE__ */ ((HOOKS2) => {
|
|
25
|
-
HOOKS2["AFTER_MATCH"] = "afterMatch";
|
|
26
|
-
HOOKS2["AFTER_RENDER"] = "afterRender";
|
|
27
|
-
return HOOKS2;
|
|
28
|
-
})(HOOKS || {});
|
|
1
|
+
const _excluded = ["default", "middleware"];
|
|
2
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
3
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { isProd, logger, requireExistModule, SERVER_DIR } from '@modern-js/utils';
|
|
9
|
+
const WEB_APP_NAME = 'index';
|
|
10
|
+
var HOOKS;
|
|
11
|
+
(function (HOOKS) {
|
|
12
|
+
HOOKS["AFTER_MATCH"] = "afterMatch";
|
|
13
|
+
HOOKS["AFTER_RENDER"] = "afterRender";
|
|
14
|
+
})(HOOKS || (HOOKS = {}));
|
|
29
15
|
class Storage {
|
|
30
16
|
constructor() {
|
|
31
|
-
this
|
|
32
|
-
this
|
|
17
|
+
_defineProperty(this, "middlewares", []);
|
|
18
|
+
_defineProperty(this, "hooks", {});
|
|
33
19
|
}
|
|
34
20
|
reset() {
|
|
35
21
|
this.middlewares = [];
|
|
36
22
|
this.hooks = {};
|
|
37
23
|
}
|
|
38
24
|
}
|
|
39
|
-
const createTransformAPI =
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (name === "addMiddleware") {
|
|
44
|
-
return (fn) => storage.middlewares.push(fn);
|
|
45
|
-
}
|
|
46
|
-
return (fn) => {
|
|
47
|
-
logger.warn(
|
|
48
|
-
"declare hook in default export is to be deprecated, use named export instead"
|
|
49
|
-
);
|
|
50
|
-
storage.hooks[name] = fn;
|
|
51
|
-
};
|
|
25
|
+
const createTransformAPI = storage => new Proxy({}, {
|
|
26
|
+
get(target, name) {
|
|
27
|
+
if (name === 'addMiddleware') {
|
|
28
|
+
return fn => storage.middlewares.push(fn);
|
|
52
29
|
}
|
|
30
|
+
return fn => {
|
|
31
|
+
logger.warn('declare hook in default export is to be deprecated, use named export instead');
|
|
32
|
+
storage.hooks[name] = fn;
|
|
33
|
+
};
|
|
53
34
|
}
|
|
54
|
-
);
|
|
55
|
-
const compose =
|
|
35
|
+
});
|
|
36
|
+
const compose = middlewares => {
|
|
56
37
|
return (ctx, resolve, reject) => {
|
|
57
38
|
let i = 0;
|
|
58
39
|
const dispatch = () => {
|
|
59
|
-
var
|
|
40
|
+
var _handler, _handler$catch;
|
|
60
41
|
const handler = middlewares[i++];
|
|
61
42
|
if (!handler) {
|
|
62
43
|
return resolve();
|
|
63
44
|
}
|
|
64
|
-
return (
|
|
45
|
+
return (_handler = handler(ctx, dispatch)) === null || _handler === void 0 ? void 0 : (_handler$catch = _handler.catch) === null || _handler$catch === void 0 ? void 0 : _handler$catch.call(_handler, reject);
|
|
65
46
|
};
|
|
66
47
|
return dispatch;
|
|
67
48
|
};
|
|
68
49
|
};
|
|
69
|
-
|
|
70
|
-
name:
|
|
71
|
-
setup:
|
|
72
|
-
const {
|
|
50
|
+
export default (() => ({
|
|
51
|
+
name: '@modern-js/plugin-server',
|
|
52
|
+
setup: api => {
|
|
53
|
+
const {
|
|
54
|
+
appDirectory,
|
|
55
|
+
distDirectory
|
|
56
|
+
} = api.useAppContext();
|
|
73
57
|
const storage = new Storage();
|
|
74
58
|
const transformAPI = createTransformAPI(storage);
|
|
75
59
|
const pwd = isProd() ? distDirectory : appDirectory;
|
|
@@ -78,11 +62,17 @@ var server_default = () => ({
|
|
|
78
62
|
const mod = requireExistModule(webAppPath, {
|
|
79
63
|
interop: false
|
|
80
64
|
});
|
|
81
|
-
const
|
|
65
|
+
const {
|
|
66
|
+
default: defaultExports,
|
|
67
|
+
middleware
|
|
68
|
+
} = mod,
|
|
69
|
+
hooks = _objectWithoutProperties(mod, _excluded);
|
|
82
70
|
if (defaultExports) {
|
|
83
71
|
defaultExports(transformAPI);
|
|
84
72
|
}
|
|
85
|
-
|
|
73
|
+
|
|
74
|
+
// named export hooks will overrides hooks in default export function
|
|
75
|
+
Object.values(HOOKS).forEach(key => {
|
|
86
76
|
const fn = hooks[key];
|
|
87
77
|
if (fn) {
|
|
88
78
|
storage.hooks[key] = fn;
|
|
@@ -100,8 +90,10 @@ var server_default = () => ({
|
|
|
100
90
|
storage.reset();
|
|
101
91
|
loadMod();
|
|
102
92
|
},
|
|
103
|
-
gather({
|
|
104
|
-
|
|
93
|
+
gather({
|
|
94
|
+
addWebMiddleware
|
|
95
|
+
}) {
|
|
96
|
+
storage.middlewares.forEach(mid => {
|
|
105
97
|
addWebMiddleware(mid);
|
|
106
98
|
});
|
|
107
99
|
},
|
|
@@ -117,15 +109,21 @@ var server_default = () => ({
|
|
|
117
109
|
}
|
|
118
110
|
return storage.hooks.afterRender(context, next);
|
|
119
111
|
},
|
|
120
|
-
prepareWebServer({
|
|
121
|
-
|
|
112
|
+
prepareWebServer({
|
|
113
|
+
config
|
|
114
|
+
}) {
|
|
115
|
+
const {
|
|
116
|
+
middleware
|
|
117
|
+
} = config;
|
|
122
118
|
const factory = compose(middleware);
|
|
123
|
-
return
|
|
119
|
+
return ctx => {
|
|
124
120
|
const {
|
|
125
|
-
source: {
|
|
121
|
+
source: {
|
|
122
|
+
res
|
|
123
|
+
}
|
|
126
124
|
} = ctx;
|
|
127
125
|
return new Promise((resolve, reject) => {
|
|
128
|
-
res.on(
|
|
126
|
+
res.on('finish', err => {
|
|
129
127
|
if (err) {
|
|
130
128
|
return reject(err);
|
|
131
129
|
}
|
|
@@ -138,7 +136,4 @@ var server_default = () => ({
|
|
|
138
136
|
}
|
|
139
137
|
};
|
|
140
138
|
}
|
|
141
|
-
});
|
|
142
|
-
export {
|
|
143
|
-
server_default as default
|
|
144
|
-
};
|
|
139
|
+
}));
|
package/dist/js/node/cli.js
CHANGED
|
@@ -1,97 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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: () => cli_default
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
27
5
|
});
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} catch (e) {
|
|
39
|
-
reject(e);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
var rejected = (value) => {
|
|
43
|
-
try {
|
|
44
|
-
step(generator.throw(value));
|
|
45
|
-
} catch (e) {
|
|
46
|
-
reject(e);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
50
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
const TS_CONFIG_FILENAME = "tsconfig.json";
|
|
54
|
-
var cli_default = () => ({
|
|
55
|
-
name: "@modern-js/plugin-server",
|
|
56
|
-
setup: (api) => ({
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _serverUtils = require("@modern-js/server-utils");
|
|
10
|
+
var _utils = require("@modern-js/utils");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
const TS_CONFIG_FILENAME = 'tsconfig.json';
|
|
13
|
+
var _default = () => ({
|
|
14
|
+
name: '@modern-js/plugin-server',
|
|
15
|
+
setup: api => ({
|
|
57
16
|
config() {
|
|
58
17
|
return {};
|
|
59
18
|
},
|
|
60
|
-
afterBuild() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
19
|
+
async afterBuild() {
|
|
20
|
+
const {
|
|
21
|
+
appDirectory,
|
|
22
|
+
distDirectory
|
|
23
|
+
} = api.useAppContext();
|
|
24
|
+
const modernConfig = api.useResolvedConfigContext();
|
|
25
|
+
const distDir = _path.default.resolve(distDirectory);
|
|
26
|
+
const serverDir = _path.default.resolve(appDirectory, _utils.SERVER_DIR);
|
|
27
|
+
const sharedDir = _path.default.resolve(appDirectory, _utils.SHARED_DIR);
|
|
28
|
+
const tsconfigPath = _path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
29
|
+
const sourceDirs = [];
|
|
30
|
+
if (_fs.default.existsSync(serverDir)) {
|
|
31
|
+
sourceDirs.push(serverDir);
|
|
32
|
+
}
|
|
33
|
+
if (_fs.default.existsSync(sharedDir)) {
|
|
34
|
+
sourceDirs.push(sharedDir);
|
|
35
|
+
}
|
|
36
|
+
const {
|
|
37
|
+
server
|
|
38
|
+
} = modernConfig;
|
|
39
|
+
const {
|
|
40
|
+
alias,
|
|
41
|
+
globalVars
|
|
42
|
+
} = modernConfig.source;
|
|
43
|
+
const {
|
|
44
|
+
babel
|
|
45
|
+
} = modernConfig.tools;
|
|
46
|
+
if (sourceDirs.length > 0) {
|
|
47
|
+
await (0, _serverUtils.compile)(appDirectory, {
|
|
48
|
+
server,
|
|
49
|
+
alias,
|
|
50
|
+
globalVars,
|
|
51
|
+
babelConfig: babel
|
|
52
|
+
}, {
|
|
53
|
+
sourceDirs,
|
|
54
|
+
distDir,
|
|
55
|
+
tsconfigPath
|
|
56
|
+
});
|
|
57
|
+
}
|
|
95
58
|
}
|
|
96
59
|
})
|
|
97
60
|
});
|
|
61
|
+
exports.default = _default;
|