@modern-js/plugin-server 1.15.0 → 1.15.1-beta.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.
- package/dist/js/modern/cli.js +40 -32
- package/dist/js/node/cli.js +40 -33
- package/dist/js/treeshaking/cli.js +47 -57
- package/package.json +4 -3
package/dist/js/modern/cli.js
CHANGED
@@ -1,39 +1,47 @@
|
|
1
1
|
import fs from 'fs';
|
2
2
|
import path from 'path';
|
3
|
-
import {
|
4
|
-
import { resolveBabelConfig } from '@modern-js/server-utils';
|
3
|
+
import { compile } from '@modern-js/server-utils';
|
5
4
|
import { SHARED_DIR, SERVER_DIR } from '@modern-js/utils';
|
6
5
|
const TS_CONFIG_FILENAME = 'tsconfig.json';
|
7
|
-
const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs'];
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
+
// };
|
37
45
|
|
38
46
|
export default (() => ({
|
39
47
|
name: '@modern-js/plugin-server',
|
package/dist/js/node/cli.js
CHANGED
@@ -9,8 +9,6 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
9
9
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
11
11
|
|
12
|
-
var _babelCompiler = require("@modern-js/babel-compiler");
|
13
|
-
|
14
12
|
var _serverUtils = require("@modern-js/server-utils");
|
15
13
|
|
16
14
|
var _utils = require("@modern-js/utils");
|
@@ -18,36 +16,45 @@ var _utils = require("@modern-js/utils");
|
|
18
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
17
|
|
20
18
|
const TS_CONFIG_FILENAME = 'tsconfig.json';
|
21
|
-
const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs'];
|
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
|
-
|
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
|
+
// };
|
51
58
|
|
52
59
|
var _default = () => ({
|
53
60
|
name: '@modern-js/plugin-server',
|
@@ -90,7 +97,7 @@ var _default = () => ({
|
|
90
97
|
}
|
91
98
|
|
92
99
|
if (patterns.length > 0) {
|
93
|
-
await compile(appDirectory, modernConfig, {
|
100
|
+
await (0, _serverUtils.compile)(appDirectory, modernConfig, {
|
94
101
|
patterns
|
95
102
|
});
|
96
103
|
}
|
@@ -2,58 +2,48 @@ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
3
3
|
import fs from 'fs';
|
4
4
|
import path from 'path';
|
5
|
-
import {
|
6
|
-
import { resolveBabelConfig } from '@modern-js/server-utils';
|
5
|
+
import { compile } from '@modern-js/server-utils';
|
7
6
|
import { SHARED_DIR, SERVER_DIR } from '@modern-js/utils';
|
8
7
|
var TS_CONFIG_FILENAME = 'tsconfig.json';
|
9
|
-
var FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs'];
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
}, _callee);
|
51
|
-
}));
|
52
|
-
|
53
|
-
return function compile(_x, _x2, _x3) {
|
54
|
-
return _ref.apply(this, arguments);
|
55
|
-
};
|
56
|
-
}();
|
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
|
+
// };
|
57
47
|
|
58
48
|
export default (function () {
|
59
49
|
return {
|
@@ -64,12 +54,12 @@ export default (function () {
|
|
64
54
|
return {};
|
65
55
|
},
|
66
56
|
afterBuild: function afterBuild() {
|
67
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
57
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
68
58
|
var _api$useAppContext, appDirectory, distDirectory, modernConfig, distDir, serverDir, sharedDir, tsconfigPath, patterns;
|
69
59
|
|
70
|
-
return _regeneratorRuntime().wrap(function
|
60
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
71
61
|
while (1) {
|
72
|
-
switch (
|
62
|
+
switch (_context.prev = _context.next) {
|
73
63
|
case 0:
|
74
64
|
_api$useAppContext = api.useAppContext(), appDirectory = _api$useAppContext.appDirectory, distDirectory = _api$useAppContext.distDirectory;
|
75
65
|
modernConfig = api.useResolvedConfigContext();
|
@@ -96,21 +86,21 @@ export default (function () {
|
|
96
86
|
}
|
97
87
|
|
98
88
|
if (!(patterns.length > 0)) {
|
99
|
-
|
89
|
+
_context.next = 12;
|
100
90
|
break;
|
101
91
|
}
|
102
92
|
|
103
|
-
|
93
|
+
_context.next = 12;
|
104
94
|
return compile(appDirectory, modernConfig, {
|
105
95
|
patterns: patterns
|
106
96
|
});
|
107
97
|
|
108
98
|
case 12:
|
109
99
|
case "end":
|
110
|
-
return
|
100
|
+
return _context.stop();
|
111
101
|
}
|
112
102
|
}
|
113
|
-
},
|
103
|
+
}, _callee);
|
114
104
|
}))();
|
115
105
|
}
|
116
106
|
};
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.15.0",
|
14
|
+
"version": "1.15.1-beta.0",
|
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.0",
|
52
|
+
"@modern-js/server-utils": "1.15.1-beta.0",
|
53
53
|
"@modern-js/utils": "1.15.0"
|
54
54
|
},
|
55
55
|
"devDependencies": {
|
@@ -71,7 +71,8 @@
|
|
71
71
|
],
|
72
72
|
"publishConfig": {
|
73
73
|
"access": "public",
|
74
|
-
"registry": "https://registry.npmjs.org/"
|
74
|
+
"registry": "https://registry.npmjs.org/",
|
75
|
+
"types": "./dist/types/server.d.ts"
|
75
76
|
},
|
76
77
|
"wireit": {
|
77
78
|
"build": {
|