@modern-js/plugin-server-build 1.2.0 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +39 -0
- package/dist/js/modern/index.js +35 -41
- package/dist/js/node/index.js +42 -49
- package/dist/types/index.d.ts +3 -1
- package/jest.config.js +0 -1
- package/modern.config.js +5 -1
- package/package.json +7 -18
- package/tests/tsconfig.json +13 -0
- package/tsconfig.json +1 -1
- package/src/index.ts +0 -98
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,44 @@
|
|
1
1
|
# @modern-js/plugin-server-build
|
2
2
|
|
3
|
+
## 1.2.3
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 61e3f623: feat: convert to new plugin
|
8
|
+
- 681a1ff9: feat: remove unnecessary peerDependencies
|
9
|
+
- Updated dependencies [c2046f37]
|
10
|
+
- @modern-js/utils@1.3.6
|
11
|
+
|
12
|
+
## 1.2.2
|
13
|
+
|
14
|
+
### Patch Changes
|
15
|
+
|
16
|
+
- 55e18278: chore: remove unused dependencies and devDependencies
|
17
|
+
- Updated dependencies [969f172f]
|
18
|
+
- Updated dependencies [4c792f68]
|
19
|
+
- Updated dependencies [4b5d4bf4]
|
20
|
+
- Updated dependencies [62f5b8c8]
|
21
|
+
- Updated dependencies [55e18278]
|
22
|
+
- Updated dependencies [4499a674]
|
23
|
+
- Updated dependencies [403f5169]
|
24
|
+
- Updated dependencies [a7f42f48]
|
25
|
+
- @modern-js/core@1.4.4
|
26
|
+
- @modern-js/utils@1.3.3
|
27
|
+
- @modern-js/babel-compiler@1.2.2
|
28
|
+
|
29
|
+
## 1.2.1
|
30
|
+
|
31
|
+
### Patch Changes
|
32
|
+
|
33
|
+
- 83166714: change .npmignore
|
34
|
+
- Updated dependencies [83166714]
|
35
|
+
- Updated dependencies [c3de9882]
|
36
|
+
- Updated dependencies [33ff48af]
|
37
|
+
- @modern-js/core@1.3.2
|
38
|
+
- @modern-js/server-utils@1.2.1
|
39
|
+
- @modern-js/babel-compiler@1.2.1
|
40
|
+
- @modern-js/utils@1.2.2
|
41
|
+
|
3
42
|
## 1.2.0
|
4
43
|
|
5
44
|
### Minor Changes
|
package/dist/js/modern/index.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import fs from 'fs';
|
2
2
|
import path from 'path';
|
3
|
-
import { createPlugin, useAppContext, useResolvedConfigContext } from '@modern-js/core';
|
4
3
|
import { compiler } from '@modern-js/babel-compiler';
|
5
4
|
import { resolveBabelConfig } from '@modern-js/server-utils';
|
6
5
|
const SERVER_DIR = './server';
|
@@ -37,48 +36,43 @@ const compile = async (appDirectory, modernConfig, compileOptions) => {
|
|
37
36
|
});
|
38
37
|
};
|
39
38
|
|
40
|
-
export default
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
export default (() => ({
|
40
|
+
name: '@modern-js/plugin-server-build',
|
41
|
+
setup: api => ({
|
42
|
+
async afterBuild() {
|
43
|
+
const {
|
44
|
+
appDirectory,
|
45
|
+
distDirectory
|
46
|
+
} = api.useAppContext();
|
47
|
+
const modernConfig = api.useResolvedConfigContext();
|
48
|
+
const distDir = path.resolve(distDirectory);
|
49
|
+
const serverDir = path.resolve(appDirectory, SERVER_DIR);
|
50
|
+
const sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
51
|
+
const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
52
|
+
const patterns = [];
|
44
53
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
const modernConfig = useResolvedConfigContext();
|
53
|
-
const distDir = path.resolve(distDirectory);
|
54
|
-
const serverDir = path.resolve(appDirectory, SERVER_DIR);
|
55
|
-
const sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
56
|
-
const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
57
|
-
const patterns = [];
|
54
|
+
if (fs.existsSync(serverDir)) {
|
55
|
+
patterns.push({
|
56
|
+
from: serverDir,
|
57
|
+
to: distDir,
|
58
|
+
tsconfigPath
|
59
|
+
});
|
60
|
+
}
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
if (fs.existsSync(sharedDir)) {
|
68
|
-
patterns.push({
|
69
|
-
from: sharedDir,
|
70
|
-
to: distDir,
|
71
|
-
tsconfigPath
|
72
|
-
});
|
73
|
-
}
|
62
|
+
if (fs.existsSync(sharedDir)) {
|
63
|
+
patterns.push({
|
64
|
+
from: sharedDir,
|
65
|
+
to: distDir,
|
66
|
+
tsconfigPath
|
67
|
+
});
|
68
|
+
}
|
74
69
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
70
|
+
if (patterns.length > 0) {
|
71
|
+
await compile(appDirectory, modernConfig, {
|
72
|
+
patterns
|
73
|
+
});
|
74
|
+
}
|
79
75
|
}
|
80
|
-
}
|
81
76
|
|
82
|
-
})
|
83
|
-
|
84
|
-
});
|
77
|
+
})
|
78
|
+
}));
|
package/dist/js/node/index.js
CHANGED
@@ -9,8 +9,6 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
9
9
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
11
11
|
|
12
|
-
var _core = require("@modern-js/core");
|
13
|
-
|
14
12
|
var _babelCompiler = require("@modern-js/babel-compiler");
|
15
13
|
|
16
14
|
var _serverUtils = require("@modern-js/server-utils");
|
@@ -51,55 +49,50 @@ const compile = async (appDirectory, modernConfig, compileOptions) => {
|
|
51
49
|
});
|
52
50
|
};
|
53
51
|
|
54
|
-
var _default = (
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
await compile(appDirectory, modernConfig, {
|
96
|
-
patterns
|
97
|
-
});
|
52
|
+
var _default = () => ({
|
53
|
+
name: '@modern-js/plugin-server-build',
|
54
|
+
setup: api => ({
|
55
|
+
async afterBuild() {
|
56
|
+
const {
|
57
|
+
appDirectory,
|
58
|
+
distDirectory
|
59
|
+
} = api.useAppContext();
|
60
|
+
const modernConfig = api.useResolvedConfigContext();
|
61
|
+
|
62
|
+
const distDir = _path.default.resolve(distDirectory);
|
63
|
+
|
64
|
+
const serverDir = _path.default.resolve(appDirectory, SERVER_DIR);
|
65
|
+
|
66
|
+
const sharedDir = _path.default.resolve(appDirectory, SHARED_DIR);
|
67
|
+
|
68
|
+
const tsconfigPath = _path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
|
69
|
+
|
70
|
+
const patterns = [];
|
71
|
+
|
72
|
+
if (_fs.default.existsSync(serverDir)) {
|
73
|
+
patterns.push({
|
74
|
+
from: serverDir,
|
75
|
+
to: distDir,
|
76
|
+
tsconfigPath
|
77
|
+
});
|
78
|
+
}
|
79
|
+
|
80
|
+
if (_fs.default.existsSync(sharedDir)) {
|
81
|
+
patterns.push({
|
82
|
+
from: sharedDir,
|
83
|
+
to: distDir,
|
84
|
+
tsconfigPath
|
85
|
+
});
|
86
|
+
}
|
87
|
+
|
88
|
+
if (patterns.length > 0) {
|
89
|
+
await compile(appDirectory, modernConfig, {
|
90
|
+
patterns
|
91
|
+
});
|
92
|
+
}
|
98
93
|
}
|
99
|
-
}
|
100
94
|
|
101
|
-
})
|
102
|
-
name: '@modern-js/plugin-server-build'
|
95
|
+
})
|
103
96
|
});
|
104
97
|
|
105
98
|
exports.default = _default;
|
package/dist/types/index.d.ts
CHANGED
package/jest.config.js
CHANGED
package/modern.config.js
CHANGED
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.3",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -29,37 +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.
|
35
|
-
"globby": "^12.0.2",
|
36
|
-
"json5": "^2.2.0"
|
32
|
+
"@modern-js/babel-compiler": "^1.2.2",
|
33
|
+
"@modern-js/server-utils": "^1.2.1",
|
34
|
+
"@modern-js/utils": "^1.3.6"
|
37
35
|
},
|
38
36
|
"devDependencies": {
|
39
|
-
"@modern-js/plugin-analyze": "^1.
|
37
|
+
"@modern-js/plugin-analyze": "^1.3.4",
|
40
38
|
"@types/babel__core": "^7.1.15",
|
41
39
|
"@types/jest": "^26",
|
42
40
|
"@types/node": "^14",
|
43
41
|
"ts-jest": "^27.0.5",
|
44
42
|
"typescript": "^4",
|
45
|
-
"@modern-js/core": "^1.
|
43
|
+
"@modern-js/core": "^1.6.0",
|
46
44
|
"@scripts/build": "0.0.0",
|
47
45
|
"jest": "^27",
|
48
46
|
"@scripts/jest-config": "0.0.0"
|
49
47
|
},
|
50
|
-
"peerDependencies": {
|
51
|
-
"@modern-js/core": "^1.3.0"
|
52
|
-
},
|
53
48
|
"sideEffects": false,
|
54
|
-
"modernConfig": {
|
55
|
-
"output": {
|
56
|
-
"packageMode": "node-js"
|
57
|
-
}
|
58
|
-
},
|
59
49
|
"publishConfig": {
|
60
50
|
"registry": "https://registry.npmjs.org/",
|
61
|
-
"access": "public"
|
62
|
-
"types": "./dist/types/index.d.ts"
|
51
|
+
"access": "public"
|
63
52
|
},
|
64
53
|
"scripts": {
|
65
54
|
"new": "modern new",
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"extends": "@modern-js/tsconfig/base",
|
3
|
+
"compilerOptions": {
|
4
|
+
"declaration": true,
|
5
|
+
"jsx": "preserve",
|
6
|
+
"baseUrl": "./",
|
7
|
+
"outDir": "./out",
|
8
|
+
"emitDeclarationOnly": true,
|
9
|
+
"isolatedModules": true,
|
10
|
+
"paths": {},
|
11
|
+
"types": ["node", "jest"]
|
12
|
+
}
|
13
|
+
}
|
package/tsconfig.json
CHANGED
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;
|