@modern-js/plugin-server-build 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +13 -0
- package/package.json +7 -7
- package/src/index.ts +0 -98
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# @modern-js/plugin-server-build
|
2
2
|
|
3
|
+
## 1.2.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 83166714: change .npmignore
|
8
|
+
- Updated dependencies [83166714]
|
9
|
+
- Updated dependencies [c3de9882]
|
10
|
+
- Updated dependencies [33ff48af]
|
11
|
+
- @modern-js/core@1.3.2
|
12
|
+
- @modern-js/server-utils@1.2.1
|
13
|
+
- @modern-js/babel-compiler@1.2.1
|
14
|
+
- @modern-js/utils@1.2.2
|
15
|
+
|
3
16
|
## 1.2.0
|
4
17
|
|
5
18
|
### Minor Changes
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.2.
|
14
|
+
"version": "1.2.1",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -29,26 +29,26 @@
|
|
29
29
|
},
|
30
30
|
"dependencies": {
|
31
31
|
"@babel/runtime": "^7",
|
32
|
-
"@modern-js/babel-compiler": "^1.2.
|
33
|
-
"@modern-js/server-utils": "^1.2.
|
34
|
-
"@modern-js/utils": "^1.2.
|
32
|
+
"@modern-js/babel-compiler": "^1.2.1",
|
33
|
+
"@modern-js/server-utils": "^1.2.1",
|
34
|
+
"@modern-js/utils": "^1.2.2",
|
35
35
|
"globby": "^12.0.2",
|
36
36
|
"json5": "^2.2.0"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
|
-
"@modern-js/plugin-analyze": "^1.2.
|
39
|
+
"@modern-js/plugin-analyze": "^1.2.1",
|
40
40
|
"@types/babel__core": "^7.1.15",
|
41
41
|
"@types/jest": "^26",
|
42
42
|
"@types/node": "^14",
|
43
43
|
"ts-jest": "^27.0.5",
|
44
44
|
"typescript": "^4",
|
45
|
-
"@modern-js/core": "^1.3.
|
45
|
+
"@modern-js/core": "^1.3.2",
|
46
46
|
"@scripts/build": "0.0.0",
|
47
47
|
"jest": "^27",
|
48
48
|
"@scripts/jest-config": "0.0.0"
|
49
49
|
},
|
50
50
|
"peerDependencies": {
|
51
|
-
"@modern-js/core": "^1.3.
|
51
|
+
"@modern-js/core": "^1.3.2"
|
52
52
|
},
|
53
53
|
"sideEffects": false,
|
54
54
|
"modernConfig": {
|
package/src/index.ts
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
import fs from 'fs';
|
2
|
-
import path from 'path';
|
3
|
-
import {
|
4
|
-
createPlugin,
|
5
|
-
useAppContext,
|
6
|
-
useResolvedConfigContext,
|
7
|
-
NormalizedConfig,
|
8
|
-
} from '@modern-js/core';
|
9
|
-
import { compiler } from '@modern-js/babel-compiler';
|
10
|
-
import { resolveBabelConfig } from '@modern-js/server-utils';
|
11
|
-
|
12
|
-
const SERVER_DIR = './server';
|
13
|
-
const SHARED_DIR = './shared';
|
14
|
-
const TS_CONFIG_FILENAME = 'tsconfig.json';
|
15
|
-
const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs'];
|
16
|
-
|
17
|
-
interface Pattern {
|
18
|
-
from: string;
|
19
|
-
to: string;
|
20
|
-
tsconfigPath?: string;
|
21
|
-
}
|
22
|
-
|
23
|
-
interface CompileOptions {
|
24
|
-
patterns: Pattern[];
|
25
|
-
}
|
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
|
-
|
59
|
-
export default createPlugin(
|
60
|
-
() => ({
|
61
|
-
config() {
|
62
|
-
return {};
|
63
|
-
},
|
64
|
-
async afterBuild() {
|
65
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
66
|
-
const { appDirectory, distDirectory } = useAppContext();
|
67
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
68
|
-
const modernConfig = useResolvedConfigContext();
|
69
|
-
|
70
|
-
const distDir = path.resolve(distDirectory);
|
71
|
-
const serverDir = path.resolve(appDirectory, SERVER_DIR);
|
72
|
-
const sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
73
|
-
const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
74
|
-
|
75
|
-
const patterns = [];
|
76
|
-
if (fs.existsSync(serverDir)) {
|
77
|
-
patterns.push({
|
78
|
-
from: serverDir,
|
79
|
-
to: distDir,
|
80
|
-
tsconfigPath,
|
81
|
-
});
|
82
|
-
}
|
83
|
-
|
84
|
-
if (fs.existsSync(sharedDir)) {
|
85
|
-
patterns.push({
|
86
|
-
from: sharedDir,
|
87
|
-
to: distDir,
|
88
|
-
tsconfigPath,
|
89
|
-
});
|
90
|
-
}
|
91
|
-
|
92
|
-
if (patterns.length > 0) {
|
93
|
-
await compile(appDirectory, modernConfig, { patterns });
|
94
|
-
}
|
95
|
-
},
|
96
|
-
}),
|
97
|
-
{ name: '@modern-js/plugin-server-build' },
|
98
|
-
) as any;
|