@modern-js/plugin-server 2.42.2 → 2.44.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/cli.js +21 -16
- package/dist/esm/cli.js +23 -16
- package/dist/esm-node/cli.js +20 -15
- package/package.json +9 -9
package/dist/cjs/cli.js
CHANGED
@@ -32,30 +32,43 @@ __export(cli_exports, {
|
|
32
32
|
serverPlugin: () => serverPlugin
|
33
33
|
});
|
34
34
|
module.exports = __toCommonJS(cli_exports);
|
35
|
-
var import_fs = __toESM(require("fs"));
|
36
35
|
var import_path = __toESM(require("path"));
|
37
|
-
var
|
36
|
+
var import_fs_extra = __toESM(require("@modern-js/utils/fs-extra"));
|
38
37
|
var import_utils = require("@modern-js/utils");
|
38
|
+
var import_server_utils = require("@modern-js/server-utils");
|
39
|
+
function checkHasCache(appDir) {
|
40
|
+
const tsFilepath = import_path.default.resolve(appDir, "server", "cache.ts");
|
41
|
+
const jsfilepath = import_path.default.resolve(appDir, "server", "cache.js");
|
42
|
+
return import_fs_extra.default.existsSync(tsFilepath) || import_fs_extra.default.existsSync(jsfilepath);
|
43
|
+
}
|
39
44
|
const TS_CONFIG_FILENAME = "tsconfig.json";
|
40
45
|
const serverPlugin = () => ({
|
41
46
|
name: "@modern-js/plugin-server",
|
42
47
|
setup: (api) => ({
|
43
|
-
|
44
|
-
|
48
|
+
collectServerPlugins({ plugins }) {
|
49
|
+
plugins.push({
|
50
|
+
"@modern-js/plugin-server": "@modern-js/plugin-server/server"
|
51
|
+
});
|
52
|
+
return {
|
53
|
+
plugins
|
54
|
+
};
|
45
55
|
},
|
46
56
|
async afterBuild() {
|
47
57
|
const { appDirectory, distDirectory } = api.useAppContext();
|
58
|
+
if (checkHasCache(appDirectory)) {
|
59
|
+
return;
|
60
|
+
}
|
48
61
|
const modernConfig = api.useResolvedConfigContext();
|
49
62
|
const distDir = import_path.default.resolve(distDirectory);
|
50
63
|
const serverDir = import_path.default.resolve(appDirectory, import_utils.SERVER_DIR);
|
51
64
|
const sharedDir = import_path.default.resolve(appDirectory, import_utils.SHARED_DIR);
|
52
65
|
const tsconfigPath = import_path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
|
53
66
|
const sourceDirs = [];
|
54
|
-
if (
|
67
|
+
if (import_fs_extra.default.existsSync(serverDir)) {
|
55
68
|
sourceDirs.push(serverDir);
|
56
|
-
|
57
|
-
|
58
|
-
|
69
|
+
if (import_fs_extra.default.existsSync(sharedDir)) {
|
70
|
+
sourceDirs.push(sharedDir);
|
71
|
+
}
|
59
72
|
}
|
60
73
|
const { server } = modernConfig;
|
61
74
|
const { alias } = modernConfig.source;
|
@@ -71,14 +84,6 @@ const serverPlugin = () => ({
|
|
71
84
|
tsconfigPath
|
72
85
|
});
|
73
86
|
}
|
74
|
-
},
|
75
|
-
collectServerPlugins({ plugins }) {
|
76
|
-
plugins.push({
|
77
|
-
"@modern-js/plugin-server": "@modern-js/plugin-server/server"
|
78
|
-
});
|
79
|
-
return {
|
80
|
-
plugins
|
81
|
-
};
|
82
87
|
}
|
83
88
|
})
|
84
89
|
});
|
package/dist/esm/cli.js
CHANGED
@@ -1,17 +1,28 @@
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
|
-
import fs from "fs";
|
4
3
|
import path from "path";
|
4
|
+
import fs from "@modern-js/utils/fs-extra";
|
5
|
+
import { SERVER_DIR, SHARED_DIR } from "@modern-js/utils";
|
5
6
|
import { compile } from "@modern-js/server-utils";
|
6
|
-
|
7
|
+
function checkHasCache(appDir) {
|
8
|
+
var tsFilepath = path.resolve(appDir, "server", "cache.ts");
|
9
|
+
var jsfilepath = path.resolve(appDir, "server", "cache.js");
|
10
|
+
return fs.existsSync(tsFilepath) || fs.existsSync(jsfilepath);
|
11
|
+
}
|
7
12
|
var TS_CONFIG_FILENAME = "tsconfig.json";
|
8
13
|
var serverPlugin = function() {
|
9
14
|
return {
|
10
15
|
name: "@modern-js/plugin-server",
|
11
16
|
setup: function(api) {
|
12
17
|
return {
|
13
|
-
|
14
|
-
|
18
|
+
collectServerPlugins: function collectServerPlugins(param) {
|
19
|
+
var plugins = param.plugins;
|
20
|
+
plugins.push({
|
21
|
+
"@modern-js/plugin-server": "@modern-js/plugin-server/server"
|
22
|
+
});
|
23
|
+
return {
|
24
|
+
plugins
|
25
|
+
};
|
15
26
|
},
|
16
27
|
afterBuild: function afterBuild() {
|
17
28
|
return _async_to_generator(function() {
|
@@ -20,6 +31,11 @@ var serverPlugin = function() {
|
|
20
31
|
switch (_state.label) {
|
21
32
|
case 0:
|
22
33
|
_api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, distDirectory = _api_useAppContext.distDirectory;
|
34
|
+
if (checkHasCache(appDirectory)) {
|
35
|
+
return [
|
36
|
+
2
|
37
|
+
];
|
38
|
+
}
|
23
39
|
modernConfig = api.useResolvedConfigContext();
|
24
40
|
distDir = path.resolve(distDirectory);
|
25
41
|
serverDir = path.resolve(appDirectory, SERVER_DIR);
|
@@ -28,9 +44,9 @@ var serverPlugin = function() {
|
|
28
44
|
sourceDirs = [];
|
29
45
|
if (fs.existsSync(serverDir)) {
|
30
46
|
sourceDirs.push(serverDir);
|
31
|
-
|
32
|
-
|
33
|
-
|
47
|
+
if (fs.existsSync(sharedDir)) {
|
48
|
+
sourceDirs.push(sharedDir);
|
49
|
+
}
|
34
50
|
}
|
35
51
|
server = modernConfig.server;
|
36
52
|
alias = modernConfig.source.alias;
|
@@ -62,15 +78,6 @@ var serverPlugin = function() {
|
|
62
78
|
}
|
63
79
|
});
|
64
80
|
})();
|
65
|
-
},
|
66
|
-
collectServerPlugins: function collectServerPlugins(param) {
|
67
|
-
var plugins = param.plugins;
|
68
|
-
plugins.push({
|
69
|
-
"@modern-js/plugin-server": "@modern-js/plugin-server/server"
|
70
|
-
});
|
71
|
-
return {
|
72
|
-
plugins
|
73
|
-
};
|
74
81
|
}
|
75
82
|
};
|
76
83
|
}
|
package/dist/esm-node/cli.js
CHANGED
@@ -1,16 +1,29 @@
|
|
1
|
-
import fs from "fs";
|
2
1
|
import path from "path";
|
2
|
+
import fs from "@modern-js/utils/fs-extra";
|
3
|
+
import { SERVER_DIR, SHARED_DIR } from "@modern-js/utils";
|
3
4
|
import { compile } from "@modern-js/server-utils";
|
4
|
-
|
5
|
+
function checkHasCache(appDir) {
|
6
|
+
const tsFilepath = path.resolve(appDir, "server", "cache.ts");
|
7
|
+
const jsfilepath = path.resolve(appDir, "server", "cache.js");
|
8
|
+
return fs.existsSync(tsFilepath) || fs.existsSync(jsfilepath);
|
9
|
+
}
|
5
10
|
const TS_CONFIG_FILENAME = "tsconfig.json";
|
6
11
|
const serverPlugin = () => ({
|
7
12
|
name: "@modern-js/plugin-server",
|
8
13
|
setup: (api) => ({
|
9
|
-
|
10
|
-
|
14
|
+
collectServerPlugins({ plugins }) {
|
15
|
+
plugins.push({
|
16
|
+
"@modern-js/plugin-server": "@modern-js/plugin-server/server"
|
17
|
+
});
|
18
|
+
return {
|
19
|
+
plugins
|
20
|
+
};
|
11
21
|
},
|
12
22
|
async afterBuild() {
|
13
23
|
const { appDirectory, distDirectory } = api.useAppContext();
|
24
|
+
if (checkHasCache(appDirectory)) {
|
25
|
+
return;
|
26
|
+
}
|
14
27
|
const modernConfig = api.useResolvedConfigContext();
|
15
28
|
const distDir = path.resolve(distDirectory);
|
16
29
|
const serverDir = path.resolve(appDirectory, SERVER_DIR);
|
@@ -19,9 +32,9 @@ const serverPlugin = () => ({
|
|
19
32
|
const sourceDirs = [];
|
20
33
|
if (fs.existsSync(serverDir)) {
|
21
34
|
sourceDirs.push(serverDir);
|
22
|
-
|
23
|
-
|
24
|
-
|
35
|
+
if (fs.existsSync(sharedDir)) {
|
36
|
+
sourceDirs.push(sharedDir);
|
37
|
+
}
|
25
38
|
}
|
26
39
|
const { server } = modernConfig;
|
27
40
|
const { alias } = modernConfig.source;
|
@@ -37,14 +50,6 @@ const serverPlugin = () => ({
|
|
37
50
|
tsconfigPath
|
38
51
|
});
|
39
52
|
}
|
40
|
-
},
|
41
|
-
collectServerPlugins({ plugins }) {
|
42
|
-
plugins.push({
|
43
|
-
"@modern-js/plugin-server": "@modern-js/plugin-server/server"
|
44
|
-
});
|
45
|
-
return {
|
46
|
-
plugins
|
47
|
-
};
|
48
53
|
}
|
49
54
|
})
|
50
55
|
});
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.44.0",
|
19
19
|
"types": "./dist/types/cli.d.ts",
|
20
20
|
"jsnext:source": "./src/cli",
|
21
21
|
"main": "./dist/cjs/cli.js",
|
@@ -51,20 +51,20 @@
|
|
51
51
|
},
|
52
52
|
"dependencies": {
|
53
53
|
"@swc/helpers": "0.5.3",
|
54
|
-
"@modern-js/
|
55
|
-
"@modern-js/utils": "2.
|
54
|
+
"@modern-js/utils": "2.44.0",
|
55
|
+
"@modern-js/server-utils": "2.44.0"
|
56
56
|
},
|
57
57
|
"devDependencies": {
|
58
58
|
"typescript": "^5",
|
59
59
|
"@types/jest": "^29",
|
60
60
|
"@types/node": "^14",
|
61
61
|
"jest": "^29",
|
62
|
-
"@modern-js/server-core": "2.
|
63
|
-
"@modern-js/app-tools": "2.
|
64
|
-
"@modern-js/core": "2.
|
65
|
-
"@scripts/build": "2.
|
66
|
-
"@modern-js/types": "2.
|
67
|
-
"@scripts/jest-config": "2.
|
62
|
+
"@modern-js/server-core": "2.44.0",
|
63
|
+
"@modern-js/app-tools": "2.44.0",
|
64
|
+
"@modern-js/core": "2.44.0",
|
65
|
+
"@scripts/build": "2.44.0",
|
66
|
+
"@modern-js/types": "2.44.0",
|
67
|
+
"@scripts/jest-config": "2.44.0"
|
68
68
|
},
|
69
69
|
"sideEffects": [
|
70
70
|
"*.css",
|