@modern-js/plugin-server 1.15.1-beta.0 → 1.15.1-beta.1
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/dist/js/modern/cli.js +7 -53
- package/dist/js/node/cli.js +7 -52
- package/dist/js/treeshaking/cli.js +8 -54
- package/package.json +2 -2
package/dist/js/modern/cli.js
CHANGED
@@ -3,46 +3,6 @@ import path from 'path';
|
|
3
3
|
import { compile } from '@modern-js/server-utils';
|
4
4
|
import { SHARED_DIR, SERVER_DIR } from '@modern-js/utils';
|
5
5
|
const TS_CONFIG_FILENAME = 'tsconfig.json';
|
6
|
-
const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs']; // interface Pattern {
|
7
|
-
// from: string;
|
8
|
-
// to: string;
|
9
|
-
// tsconfigPath?: string;
|
10
|
-
// }
|
11
|
-
// interface CompileOptions {
|
12
|
-
// patterns: Pattern[];
|
13
|
-
// }
|
14
|
-
// const compile = async (
|
15
|
-
// appDirectory: string,
|
16
|
-
// modernConfig: NormalizedConfig,
|
17
|
-
// compileOptions: CompileOptions,
|
18
|
-
// ) => {
|
19
|
-
// const { patterns } = compileOptions;
|
20
|
-
// const results = await Promise.all(
|
21
|
-
// patterns.map(pattern => {
|
22
|
-
// const { from, to, tsconfigPath } = pattern;
|
23
|
-
// const babelConfig = resolveBabelConfig(appDirectory, modernConfig, {
|
24
|
-
// tsconfigPath: tsconfigPath ? tsconfigPath : '',
|
25
|
-
// syntax: 'es6+',
|
26
|
-
// type: 'commonjs',
|
27
|
-
// });
|
28
|
-
// return compiler(
|
29
|
-
// {
|
30
|
-
// rootDir: appDirectory,
|
31
|
-
// distDir: to,
|
32
|
-
// sourceDir: from,
|
33
|
-
// extensions: FILE_EXTENSIONS,
|
34
|
-
// },
|
35
|
-
// babelConfig,
|
36
|
-
// );
|
37
|
-
// }),
|
38
|
-
// );
|
39
|
-
// results.forEach(result => {
|
40
|
-
// if (result.code === 1) {
|
41
|
-
// throw new Error(result.message);
|
42
|
-
// }
|
43
|
-
// });
|
44
|
-
// };
|
45
|
-
|
46
6
|
export default (() => ({
|
47
7
|
name: '@modern-js/plugin-server',
|
48
8
|
setup: api => ({
|
@@ -60,27 +20,21 @@ export default (() => ({
|
|
60
20
|
const serverDir = path.resolve(appDirectory, SERVER_DIR);
|
61
21
|
const sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
62
22
|
const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
63
|
-
const
|
23
|
+
const sourceDirs = [];
|
64
24
|
|
65
25
|
if (fs.existsSync(serverDir)) {
|
66
|
-
|
67
|
-
from: serverDir,
|
68
|
-
to: distDir,
|
69
|
-
tsconfigPath
|
70
|
-
});
|
26
|
+
sourceDirs.push(serverDir);
|
71
27
|
}
|
72
28
|
|
73
29
|
if (fs.existsSync(sharedDir)) {
|
74
|
-
|
75
|
-
from: sharedDir,
|
76
|
-
to: distDir,
|
77
|
-
tsconfigPath
|
78
|
-
});
|
30
|
+
sourceDirs.push(sharedDir);
|
79
31
|
}
|
80
32
|
|
81
|
-
if (
|
33
|
+
if (sourceDirs.length > 0) {
|
82
34
|
await compile(appDirectory, modernConfig, {
|
83
|
-
|
35
|
+
sourceDirs,
|
36
|
+
distDir,
|
37
|
+
tsconfigPath
|
84
38
|
});
|
85
39
|
}
|
86
40
|
}
|
package/dist/js/node/cli.js
CHANGED
@@ -16,45 +16,6 @@ var _utils = require("@modern-js/utils");
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
17
|
|
18
18
|
const TS_CONFIG_FILENAME = 'tsconfig.json';
|
19
|
-
const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs']; // interface Pattern {
|
20
|
-
// from: string;
|
21
|
-
// to: string;
|
22
|
-
// tsconfigPath?: string;
|
23
|
-
// }
|
24
|
-
// interface CompileOptions {
|
25
|
-
// patterns: Pattern[];
|
26
|
-
// }
|
27
|
-
// const compile = async (
|
28
|
-
// appDirectory: string,
|
29
|
-
// modernConfig: NormalizedConfig,
|
30
|
-
// compileOptions: CompileOptions,
|
31
|
-
// ) => {
|
32
|
-
// const { patterns } = compileOptions;
|
33
|
-
// const results = await Promise.all(
|
34
|
-
// patterns.map(pattern => {
|
35
|
-
// const { from, to, tsconfigPath } = pattern;
|
36
|
-
// const babelConfig = resolveBabelConfig(appDirectory, modernConfig, {
|
37
|
-
// tsconfigPath: tsconfigPath ? tsconfigPath : '',
|
38
|
-
// syntax: 'es6+',
|
39
|
-
// type: 'commonjs',
|
40
|
-
// });
|
41
|
-
// return compiler(
|
42
|
-
// {
|
43
|
-
// rootDir: appDirectory,
|
44
|
-
// distDir: to,
|
45
|
-
// sourceDir: from,
|
46
|
-
// extensions: FILE_EXTENSIONS,
|
47
|
-
// },
|
48
|
-
// babelConfig,
|
49
|
-
// );
|
50
|
-
// }),
|
51
|
-
// );
|
52
|
-
// results.forEach(result => {
|
53
|
-
// if (result.code === 1) {
|
54
|
-
// throw new Error(result.message);
|
55
|
-
// }
|
56
|
-
// });
|
57
|
-
// };
|
58
19
|
|
59
20
|
var _default = () => ({
|
60
21
|
name: '@modern-js/plugin-server',
|
@@ -78,27 +39,21 @@ var _default = () => ({
|
|
78
39
|
|
79
40
|
const tsconfigPath = _path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
|
80
41
|
|
81
|
-
const
|
42
|
+
const sourceDirs = [];
|
82
43
|
|
83
44
|
if (_fs.default.existsSync(serverDir)) {
|
84
|
-
|
85
|
-
from: serverDir,
|
86
|
-
to: distDir,
|
87
|
-
tsconfigPath
|
88
|
-
});
|
45
|
+
sourceDirs.push(serverDir);
|
89
46
|
}
|
90
47
|
|
91
48
|
if (_fs.default.existsSync(sharedDir)) {
|
92
|
-
|
93
|
-
from: sharedDir,
|
94
|
-
to: distDir,
|
95
|
-
tsconfigPath
|
96
|
-
});
|
49
|
+
sourceDirs.push(sharedDir);
|
97
50
|
}
|
98
51
|
|
99
|
-
if (
|
52
|
+
if (sourceDirs.length > 0) {
|
100
53
|
await (0, _serverUtils.compile)(appDirectory, modernConfig, {
|
101
|
-
|
54
|
+
sourceDirs,
|
55
|
+
distDir,
|
56
|
+
tsconfigPath
|
102
57
|
});
|
103
58
|
}
|
104
59
|
}
|
@@ -5,46 +5,6 @@ import path from 'path';
|
|
5
5
|
import { compile } from '@modern-js/server-utils';
|
6
6
|
import { SHARED_DIR, SERVER_DIR } from '@modern-js/utils';
|
7
7
|
var TS_CONFIG_FILENAME = 'tsconfig.json';
|
8
|
-
var FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs']; // interface Pattern {
|
9
|
-
// from: string;
|
10
|
-
// to: string;
|
11
|
-
// tsconfigPath?: string;
|
12
|
-
// }
|
13
|
-
// interface CompileOptions {
|
14
|
-
// patterns: Pattern[];
|
15
|
-
// }
|
16
|
-
// const compile = async (
|
17
|
-
// appDirectory: string,
|
18
|
-
// modernConfig: NormalizedConfig,
|
19
|
-
// compileOptions: CompileOptions,
|
20
|
-
// ) => {
|
21
|
-
// const { patterns } = compileOptions;
|
22
|
-
// const results = await Promise.all(
|
23
|
-
// patterns.map(pattern => {
|
24
|
-
// const { from, to, tsconfigPath } = pattern;
|
25
|
-
// const babelConfig = resolveBabelConfig(appDirectory, modernConfig, {
|
26
|
-
// tsconfigPath: tsconfigPath ? tsconfigPath : '',
|
27
|
-
// syntax: 'es6+',
|
28
|
-
// type: 'commonjs',
|
29
|
-
// });
|
30
|
-
// return compiler(
|
31
|
-
// {
|
32
|
-
// rootDir: appDirectory,
|
33
|
-
// distDir: to,
|
34
|
-
// sourceDir: from,
|
35
|
-
// extensions: FILE_EXTENSIONS,
|
36
|
-
// },
|
37
|
-
// babelConfig,
|
38
|
-
// );
|
39
|
-
// }),
|
40
|
-
// );
|
41
|
-
// results.forEach(result => {
|
42
|
-
// if (result.code === 1) {
|
43
|
-
// throw new Error(result.message);
|
44
|
-
// }
|
45
|
-
// });
|
46
|
-
// };
|
47
|
-
|
48
8
|
export default (function () {
|
49
9
|
return {
|
50
10
|
name: '@modern-js/plugin-server',
|
@@ -55,7 +15,7 @@ export default (function () {
|
|
55
15
|
},
|
56
16
|
afterBuild: function afterBuild() {
|
57
17
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
58
|
-
var _api$useAppContext, appDirectory, distDirectory, modernConfig, distDir, serverDir, sharedDir, tsconfigPath,
|
18
|
+
var _api$useAppContext, appDirectory, distDirectory, modernConfig, distDir, serverDir, sharedDir, tsconfigPath, sourceDirs;
|
59
19
|
|
60
20
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
61
21
|
while (1) {
|
@@ -67,32 +27,26 @@ export default (function () {
|
|
67
27
|
serverDir = path.resolve(appDirectory, SERVER_DIR);
|
68
28
|
sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
69
29
|
tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
70
|
-
|
30
|
+
sourceDirs = [];
|
71
31
|
|
72
32
|
if (fs.existsSync(serverDir)) {
|
73
|
-
|
74
|
-
from: serverDir,
|
75
|
-
to: distDir,
|
76
|
-
tsconfigPath: tsconfigPath
|
77
|
-
});
|
33
|
+
sourceDirs.push(serverDir);
|
78
34
|
}
|
79
35
|
|
80
36
|
if (fs.existsSync(sharedDir)) {
|
81
|
-
|
82
|
-
from: sharedDir,
|
83
|
-
to: distDir,
|
84
|
-
tsconfigPath: tsconfigPath
|
85
|
-
});
|
37
|
+
sourceDirs.push(sharedDir);
|
86
38
|
}
|
87
39
|
|
88
|
-
if (!(
|
40
|
+
if (!(sourceDirs.length > 0)) {
|
89
41
|
_context.next = 12;
|
90
42
|
break;
|
91
43
|
}
|
92
44
|
|
93
45
|
_context.next = 12;
|
94
46
|
return compile(appDirectory, modernConfig, {
|
95
|
-
|
47
|
+
sourceDirs: sourceDirs,
|
48
|
+
distDir: distDir,
|
49
|
+
tsconfigPath: tsconfigPath
|
96
50
|
});
|
97
51
|
|
98
52
|
case 12:
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.15.1-beta.
|
14
|
+
"version": "1.15.1-beta.1",
|
15
15
|
"types": "./dist/types/server.d.ts",
|
16
16
|
"jsnext:source": "./src/server.ts",
|
17
17
|
"main": "./dist/js/node/server.js",
|
@@ -49,7 +49,7 @@
|
|
49
49
|
"dependencies": {
|
50
50
|
"@babel/runtime": "^7.18.0",
|
51
51
|
"@modern-js/babel-compiler": "1.15.0",
|
52
|
-
"@modern-js/server-utils": "1.15.1-beta.
|
52
|
+
"@modern-js/server-utils": "1.15.1-beta.1",
|
53
53
|
"@modern-js/utils": "1.15.0"
|
54
54
|
},
|
55
55
|
"devDependencies": {
|