@modern-js/plugin-server 2.0.0-beta.3 → 2.0.0-beta.6
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 +77 -0
- package/dist/js/modern/cli.js +73 -48
- package/dist/js/modern/modern-app-env.d.js +0 -0
- package/dist/js/modern/server.js +70 -57
- package/dist/js/node/cli.js +98 -54
- package/dist/js/node/modern-app-env.d.js +0 -0
- package/dist/js/node/server.js +92 -66
- package/dist/js/treeshaking/cli.js +194 -58
- package/dist/js/treeshaking/modern-app-env.d.js +1 -0
- package/dist/js/treeshaking/server.js +192 -131
- package/dist/types/cli.d.ts +4 -5
- package/dist/types/server.d.ts +2 -0
- package/package.json +15 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,82 @@
|
|
|
1
1
|
# @modern-js/plugin-server
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.6
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- dda38c9c3e: chore: v2
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 3bbea92b2a: feat: support Hook、Middleware new API
|
|
12
|
+
feat: 支持 Hook、Middleware 的新 API
|
|
13
|
+
- Updated dependencies [9b915e0c10]
|
|
14
|
+
- Updated dependencies [7879e8f711]
|
|
15
|
+
- Updated dependencies [d4e8e6fb90]
|
|
16
|
+
- Updated dependencies [6aca875011]
|
|
17
|
+
- Updated dependencies [2e6031955e]
|
|
18
|
+
- Updated dependencies [7b7d12cf8f]
|
|
19
|
+
- Updated dependencies [7efeed4]
|
|
20
|
+
- Updated dependencies [92f0eade39]
|
|
21
|
+
- Updated dependencies [edd1cfb1af]
|
|
22
|
+
- Updated dependencies [cc971eabfc]
|
|
23
|
+
- Updated dependencies [5b9049f2e9]
|
|
24
|
+
- Updated dependencies [a8642da58f]
|
|
25
|
+
- Updated dependencies [92004d1906]
|
|
26
|
+
- Updated dependencies [b8bbe036c7]
|
|
27
|
+
- Updated dependencies [c2bb0f1745]
|
|
28
|
+
- Updated dependencies [d5a31df781]
|
|
29
|
+
- Updated dependencies [dda38c9c3e]
|
|
30
|
+
- Updated dependencies [3bbea92b2a]
|
|
31
|
+
- Updated dependencies [b710adb843]
|
|
32
|
+
- Updated dependencies [ea7cf06257]
|
|
33
|
+
- Updated dependencies [bbe4c4ab64]
|
|
34
|
+
- Updated dependencies [e4558a0bc4]
|
|
35
|
+
- Updated dependencies [abf3421a75]
|
|
36
|
+
- Updated dependencies [543be9558e]
|
|
37
|
+
- Updated dependencies [14b712da84]
|
|
38
|
+
- @modern-js/server-utils@2.0.0-beta.6
|
|
39
|
+
- @modern-js/utils@2.0.0-beta.6
|
|
40
|
+
- @modern-js/babel-compiler@2.0.0-beta.6
|
|
41
|
+
|
|
42
|
+
## 2.0.0-beta.4
|
|
43
|
+
|
|
44
|
+
### Major Changes
|
|
45
|
+
|
|
46
|
+
- dda38c9c3e: chore: v2
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- 3bbea92b2a: feat: support Hook、Middleware new API
|
|
51
|
+
feat: 支持 Hook、Middleware 的新 API
|
|
52
|
+
- Updated dependencies [9b915e0c10]
|
|
53
|
+
- Updated dependencies [7879e8f]
|
|
54
|
+
- Updated dependencies [d4e8e6fb90]
|
|
55
|
+
- Updated dependencies [6aca875]
|
|
56
|
+
- Updated dependencies [2e6031955e]
|
|
57
|
+
- Updated dependencies [7b7d12c]
|
|
58
|
+
- Updated dependencies [92f0eade39]
|
|
59
|
+
- Updated dependencies [edd1cfb1af]
|
|
60
|
+
- Updated dependencies [cc971eabfc]
|
|
61
|
+
- Updated dependencies [5b9049f2e9]
|
|
62
|
+
- Updated dependencies [a8642da58f]
|
|
63
|
+
- Updated dependencies [92004d1906]
|
|
64
|
+
- Updated dependencies [b8bbe036c7]
|
|
65
|
+
- Updated dependencies [c2bb0f1745]
|
|
66
|
+
- Updated dependencies [d5a31df781]
|
|
67
|
+
- Updated dependencies [dda38c9c3e]
|
|
68
|
+
- Updated dependencies [3bbea92b2a]
|
|
69
|
+
- Updated dependencies [b710adb843]
|
|
70
|
+
- Updated dependencies [ea7cf06]
|
|
71
|
+
- Updated dependencies [bbe4c4a]
|
|
72
|
+
- Updated dependencies [e4558a0]
|
|
73
|
+
- Updated dependencies [abf3421a75]
|
|
74
|
+
- Updated dependencies [543be9558e]
|
|
75
|
+
- Updated dependencies [14b712da84]
|
|
76
|
+
- @modern-js/server-utils@2.0.0-beta.4
|
|
77
|
+
- @modern-js/utils@2.0.0-beta.4
|
|
78
|
+
- @modern-js/babel-compiler@2.0.0-beta.4
|
|
79
|
+
|
|
3
80
|
## 2.0.0-beta.3
|
|
4
81
|
|
|
5
82
|
### Major Changes
|
package/dist/js/modern/cli.js
CHANGED
|
@@ -1,53 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
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) => ({
|
|
9
29
|
config() {
|
|
10
30
|
return {};
|
|
11
31
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
appDirectory,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
afterBuild() {
|
|
33
|
+
return __async(this, null, function* () {
|
|
34
|
+
const { appDirectory, distDirectory } = api.useAppContext();
|
|
35
|
+
const modernConfig = api.useResolvedConfigContext();
|
|
36
|
+
const distDir = path.resolve(distDirectory);
|
|
37
|
+
const serverDir = path.resolve(appDirectory, SERVER_DIR);
|
|
38
|
+
const sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
|
39
|
+
const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
40
|
+
const sourceDirs = [];
|
|
41
|
+
if (fs.existsSync(serverDir)) {
|
|
42
|
+
sourceDirs.push(serverDir);
|
|
43
|
+
}
|
|
44
|
+
if (fs.existsSync(sharedDir)) {
|
|
45
|
+
sourceDirs.push(sharedDir);
|
|
46
|
+
}
|
|
47
|
+
const { server } = modernConfig;
|
|
48
|
+
const { alias, globalVars } = modernConfig.source;
|
|
49
|
+
const { babel } = modernConfig.tools;
|
|
50
|
+
if (sourceDirs.length > 0) {
|
|
51
|
+
yield compile(
|
|
52
|
+
appDirectory,
|
|
53
|
+
{
|
|
54
|
+
server,
|
|
55
|
+
alias,
|
|
56
|
+
globalVars,
|
|
57
|
+
babelConfig: babel
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
sourceDirs,
|
|
61
|
+
distDir,
|
|
62
|
+
tsconfigPath
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
collectServerPlugins({ plugins }) {
|
|
69
|
+
plugins.push({
|
|
70
|
+
"@modern-js/plugin-server": "@modern-js/plugin-server/server"
|
|
71
|
+
});
|
|
72
|
+
return { plugins };
|
|
51
73
|
}
|
|
52
74
|
})
|
|
53
|
-
})
|
|
75
|
+
});
|
|
76
|
+
export {
|
|
77
|
+
cli_default as default
|
|
78
|
+
};
|
|
File without changes
|
package/dist/js/modern/server.js
CHANGED
|
@@ -1,76 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var __objRest = (source, exclude) => {
|
|
5
|
+
var target = {};
|
|
6
|
+
for (var prop in source)
|
|
7
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
8
|
+
target[prop] = source[prop];
|
|
9
|
+
if (source != null && __getOwnPropSymbols)
|
|
10
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
11
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
12
|
+
target[prop] = source[prop];
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
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 || {});
|
|
13
29
|
class Storage {
|
|
14
30
|
constructor() {
|
|
15
|
-
|
|
16
|
-
|
|
31
|
+
this.middlewares = [];
|
|
32
|
+
this.hooks = {};
|
|
17
33
|
}
|
|
18
34
|
reset() {
|
|
19
35
|
this.middlewares = [];
|
|
20
36
|
this.hooks = {};
|
|
21
37
|
}
|
|
22
38
|
}
|
|
23
|
-
const createTransformAPI = storage => new Proxy(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
39
|
+
const createTransformAPI = (storage) => new Proxy(
|
|
40
|
+
{},
|
|
41
|
+
{
|
|
42
|
+
get(target, name) {
|
|
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
|
+
};
|
|
27
52
|
}
|
|
28
|
-
return fn => {
|
|
29
|
-
logger.warn('declare hook in default export is to be deprecated, use named export instead');
|
|
30
|
-
storage.hooks[name] = fn;
|
|
31
|
-
};
|
|
32
53
|
}
|
|
33
|
-
|
|
34
|
-
const compose = middlewares => {
|
|
54
|
+
);
|
|
55
|
+
const compose = (middlewares) => {
|
|
35
56
|
return (ctx, resolve, reject) => {
|
|
36
57
|
let i = 0;
|
|
37
58
|
const dispatch = () => {
|
|
38
|
-
var
|
|
59
|
+
var _a, _b;
|
|
39
60
|
const handler = middlewares[i++];
|
|
40
61
|
if (!handler) {
|
|
41
62
|
return resolve();
|
|
42
63
|
}
|
|
43
|
-
return (
|
|
64
|
+
return (_b = (_a = handler(ctx, dispatch)) == null ? void 0 : _a.catch) == null ? void 0 : _b.call(_a, reject);
|
|
44
65
|
};
|
|
45
66
|
return dispatch;
|
|
46
67
|
};
|
|
47
68
|
};
|
|
48
|
-
|
|
49
|
-
name:
|
|
50
|
-
setup: api => {
|
|
51
|
-
const {
|
|
52
|
-
appDirectory,
|
|
53
|
-
distDirectory
|
|
54
|
-
} = api.useAppContext();
|
|
69
|
+
var server_default = () => ({
|
|
70
|
+
name: "@modern-js/plugin-server",
|
|
71
|
+
setup: (api) => {
|
|
72
|
+
const { appDirectory, distDirectory } = api.useAppContext();
|
|
55
73
|
const storage = new Storage();
|
|
56
74
|
const transformAPI = createTransformAPI(storage);
|
|
57
75
|
const pwd = isProd() ? distDirectory : appDirectory;
|
|
58
76
|
const webAppPath = path.resolve(pwd, SERVER_DIR, WEB_APP_NAME);
|
|
77
|
+
const middlewarePath = path.resolve(pwd, SERVER_DIR, "_middleware");
|
|
59
78
|
const loadMod = () => {
|
|
60
79
|
const mod = requireExistModule(webAppPath, {
|
|
61
80
|
interop: false
|
|
62
81
|
});
|
|
63
|
-
const {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
const middlewareMode = requireExistModule(middlewarePath, {
|
|
83
|
+
interop: false
|
|
84
|
+
});
|
|
85
|
+
const _a = mod || {}, { default: defaultExports, middleware } = _a, hooks = __objRest(_a, ["default", "middleware"]);
|
|
86
|
+
const { middleware: unstableMiddleware = [] } = middlewareMode || {};
|
|
68
87
|
if (defaultExports) {
|
|
69
88
|
defaultExports(transformAPI);
|
|
70
89
|
}
|
|
71
|
-
|
|
72
|
-
// named export hooks will overrides hooks in default export function
|
|
73
|
-
Object.values(HOOKS).forEach(key => {
|
|
90
|
+
Object.values(HOOKS).forEach((key) => {
|
|
74
91
|
const fn = hooks[key];
|
|
75
92
|
if (fn) {
|
|
76
93
|
storage.hooks[key] = fn;
|
|
@@ -79,6 +96,7 @@ export default (() => ({
|
|
|
79
96
|
if (middleware) {
|
|
80
97
|
storage.middlewares = [].concat(middleware);
|
|
81
98
|
}
|
|
99
|
+
storage.middlewares = storage.middlewares.concat(unstableMiddleware);
|
|
82
100
|
};
|
|
83
101
|
return {
|
|
84
102
|
prepare() {
|
|
@@ -88,10 +106,8 @@ export default (() => ({
|
|
|
88
106
|
storage.reset();
|
|
89
107
|
loadMod();
|
|
90
108
|
},
|
|
91
|
-
gather({
|
|
92
|
-
|
|
93
|
-
}) {
|
|
94
|
-
storage.middlewares.forEach(mid => {
|
|
109
|
+
gather({ addWebMiddleware }) {
|
|
110
|
+
storage.middlewares.forEach((mid) => {
|
|
95
111
|
addWebMiddleware(mid);
|
|
96
112
|
});
|
|
97
113
|
},
|
|
@@ -107,21 +123,15 @@ export default (() => ({
|
|
|
107
123
|
}
|
|
108
124
|
return storage.hooks.afterRender(context, next);
|
|
109
125
|
},
|
|
110
|
-
prepareWebServer({
|
|
111
|
-
config
|
|
112
|
-
}) {
|
|
113
|
-
const {
|
|
114
|
-
middleware
|
|
115
|
-
} = config;
|
|
126
|
+
prepareWebServer({ config }) {
|
|
127
|
+
const { middleware } = config;
|
|
116
128
|
const factory = compose(middleware);
|
|
117
|
-
return ctx => {
|
|
129
|
+
return (ctx) => {
|
|
118
130
|
const {
|
|
119
|
-
source: {
|
|
120
|
-
res
|
|
121
|
-
}
|
|
131
|
+
source: { res }
|
|
122
132
|
} = ctx;
|
|
123
133
|
return new Promise((resolve, reject) => {
|
|
124
|
-
res.on(
|
|
134
|
+
res.on("finish", (err) => {
|
|
125
135
|
if (err) {
|
|
126
136
|
return reject(err);
|
|
127
137
|
}
|
|
@@ -134,4 +144,7 @@ export default (() => ({
|
|
|
134
144
|
}
|
|
135
145
|
};
|
|
136
146
|
}
|
|
137
|
-
})
|
|
147
|
+
});
|
|
148
|
+
export {
|
|
149
|
+
server_default as default
|
|
150
|
+
};
|
package/dist/js/node/cli.js
CHANGED
|
@@ -1,61 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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 __async = (__this, __arguments, generator) => {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
var fulfilled = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.next(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var rejected = (value) => {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.throw(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var cli_exports = {};
|
|
45
|
+
__export(cli_exports, {
|
|
46
|
+
default: () => cli_default
|
|
5
47
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
setup: api => ({
|
|
48
|
+
module.exports = __toCommonJS(cli_exports);
|
|
49
|
+
var import_fs = __toESM(require("fs"));
|
|
50
|
+
var import_path = __toESM(require("path"));
|
|
51
|
+
var import_server_utils = require("@modern-js/server-utils");
|
|
52
|
+
var import_utils = require("@modern-js/utils");
|
|
53
|
+
const TS_CONFIG_FILENAME = "tsconfig.json";
|
|
54
|
+
var cli_default = () => ({
|
|
55
|
+
name: "@modern-js/plugin-server",
|
|
56
|
+
setup: (api) => ({
|
|
16
57
|
config() {
|
|
17
58
|
return {};
|
|
18
59
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
appDirectory,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
60
|
+
afterBuild() {
|
|
61
|
+
return __async(this, null, function* () {
|
|
62
|
+
const { appDirectory, distDirectory } = api.useAppContext();
|
|
63
|
+
const modernConfig = api.useResolvedConfigContext();
|
|
64
|
+
const distDir = import_path.default.resolve(distDirectory);
|
|
65
|
+
const serverDir = import_path.default.resolve(appDirectory, import_utils.SERVER_DIR);
|
|
66
|
+
const sharedDir = import_path.default.resolve(appDirectory, import_utils.SHARED_DIR);
|
|
67
|
+
const tsconfigPath = import_path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
68
|
+
const sourceDirs = [];
|
|
69
|
+
if (import_fs.default.existsSync(serverDir)) {
|
|
70
|
+
sourceDirs.push(serverDir);
|
|
71
|
+
}
|
|
72
|
+
if (import_fs.default.existsSync(sharedDir)) {
|
|
73
|
+
sourceDirs.push(sharedDir);
|
|
74
|
+
}
|
|
75
|
+
const { server } = modernConfig;
|
|
76
|
+
const { alias, globalVars } = modernConfig.source;
|
|
77
|
+
const { babel } = modernConfig.tools;
|
|
78
|
+
if (sourceDirs.length > 0) {
|
|
79
|
+
yield (0, import_server_utils.compile)(
|
|
80
|
+
appDirectory,
|
|
81
|
+
{
|
|
82
|
+
server,
|
|
83
|
+
alias,
|
|
84
|
+
globalVars,
|
|
85
|
+
babelConfig: babel
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
sourceDirs,
|
|
89
|
+
distDir,
|
|
90
|
+
tsconfigPath
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
collectServerPlugins({ plugins }) {
|
|
97
|
+
plugins.push({
|
|
98
|
+
"@modern-js/plugin-server": "@modern-js/plugin-server/server"
|
|
99
|
+
});
|
|
100
|
+
return { plugins };
|
|
58
101
|
}
|
|
59
102
|
})
|
|
60
103
|
});
|
|
61
|
-
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {});
|
|
File without changes
|