@modern-js/plugin-server-build 1.1.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +41 -68
- package/jest.config.js +8 -0
- package/modern.config.js +1 -9
- package/package.json +16 -12
- package/tests/index.test.ts +7 -0
- package/tsconfig.json +1 -3
- package/src/index.ts +0 -98
package/CHANGELOG.md
CHANGED
@@ -1,85 +1,58 @@
|
|
1
1
|
# @modern-js/plugin-server-build
|
2
2
|
|
3
|
-
## 1.1
|
4
|
-
|
5
|
-
### Minor Changes
|
6
|
-
|
7
|
-
- 96119db2: Relese v1.1.0
|
8
|
-
|
9
|
-
1. 全面支持 Windows 平台
|
10
|
-
|
11
|
-
ISSUE:
|
12
|
-
|
13
|
-
- [182](https://github.com/modern-js-dev/modern.js/issues/182)
|
14
|
-
- [236](https://github.com/modern-js-dev/modern.js/issues/236)
|
15
|
-
|
16
|
-
PR
|
17
|
-
|
18
|
-
- [219](https://github.com/modern-js-dev/modern.js/pull/219)
|
19
|
-
- [247](https://github.com/modern-js-dev/modern.js/pull/247)
|
20
|
-
- [249](https://github.com/modern-js-dev/modern.js/pull/249)
|
21
|
-
- [253](https://github.com/modern-js-dev/modern.js/pull/253)
|
22
|
-
- [268](https://github.com/modern-js-dev/modern.js/pull/268)
|
23
|
-
- [270](https://github.com/modern-js-dev/modern.js/pull/270)
|
24
|
-
- [273](https://github.com/modern-js-dev/modern.js/pull/273)
|
25
|
-
- [276](https://github.com/modern-js-dev/modern.js/pull/276)
|
26
|
-
|
27
|
-
2. 修复 Unbundled 模式启用问题
|
28
|
-
|
29
|
-
ISSUE
|
30
|
-
|
31
|
-
- [186](https://github.com/modern-js-dev/modern.js/issues/186)
|
32
|
-
- [224](https://github.com/modern-js-dev/modern.js/issues/224)
|
33
|
-
- [225](https://github.com/modern-js-dev/modern.js/issues/225)
|
34
|
-
- [238](https://github.com/modern-js-dev/modern.js/issues/238)
|
35
|
-
|
36
|
-
PR
|
37
|
-
|
38
|
-
- [226](https://github.com/modern-js-dev/modern.js/pull/226)
|
39
|
-
- [264](https://github.com/modern-js-dev/modern.js/pull/264)
|
40
|
-
- [codesmith-12](https://github.com/modern-js-dev/codesmith/pull/12)
|
3
|
+
## 1.2.1
|
41
4
|
|
42
|
-
|
43
|
-
|
44
|
-
ISSUE
|
45
|
-
|
46
|
-
- [198](https://github.com/modern-js-dev/modern.js/issues/198)
|
47
|
-
|
48
|
-
PR
|
49
|
-
|
50
|
-
- [209](https://github.com/modern-js-dev/modern.js/pull/209)
|
51
|
-
|
52
|
-
4. 修复 Storybook 使用时浏览器打开页面报错
|
53
|
-
|
54
|
-
ISSUE
|
55
|
-
|
56
|
-
- [228](https://github.com/modern-js-dev/modern.js/issues/228)
|
57
|
-
|
58
|
-
PR
|
5
|
+
### Patch Changes
|
59
6
|
|
60
|
-
|
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
|
61
15
|
|
62
|
-
|
16
|
+
## 1.2.0
|
63
17
|
|
64
|
-
|
18
|
+
### Minor Changes
|
65
19
|
|
66
|
-
|
67
|
-
- [257](https://github.com/modern-js-dev/modern.js/issues/257)
|
20
|
+
- cfe11628: Make Modern.js self bootstraping
|
68
21
|
|
69
|
-
|
22
|
+
### Patch Changes
|
70
23
|
|
71
|
-
|
72
|
-
|
24
|
+
- Updated dependencies [2da09c69]
|
25
|
+
- Updated dependencies [fc71e36f]
|
26
|
+
- Updated dependencies [146dcd85]
|
27
|
+
- Updated dependencies [c3d46ee4]
|
28
|
+
- Updated dependencies [cfe11628]
|
29
|
+
- Updated dependencies [146dcd85]
|
30
|
+
- Updated dependencies [146dcd85]
|
31
|
+
- Updated dependencies [1ebc7ee2]
|
32
|
+
- @modern-js/utils@1.2.0
|
33
|
+
- @modern-js/core@1.3.0
|
34
|
+
- @modern-js/server-utils@1.2.0
|
35
|
+
- @modern-js/babel-compiler@1.2.0
|
36
|
+
|
37
|
+
## 1.1.1
|
73
38
|
|
74
|
-
|
39
|
+
### Patch Changes
|
75
40
|
|
76
|
-
|
41
|
+
- 0fa83663: support more .env files
|
42
|
+
- Updated dependencies [6f7fe574]
|
43
|
+
- Updated dependencies [b011e0c5]
|
44
|
+
- Updated dependencies [0fa83663]
|
45
|
+
- Updated dependencies [f594fbc8]
|
46
|
+
- @modern-js/core@1.1.2
|
47
|
+
- @modern-js/server-utils@1.1.1
|
48
|
+
- @modern-js/babel-compiler@1.1.2
|
49
|
+
- @modern-js/utils@1.1.2
|
77
50
|
|
78
|
-
|
51
|
+
## 1.1.0
|
79
52
|
|
80
|
-
|
53
|
+
### Minor Changes
|
81
54
|
|
82
|
-
|
55
|
+
- 96119db2: Relese v1.1.0
|
83
56
|
|
84
57
|
### Patch Changes
|
85
58
|
|
package/jest.config.js
ADDED
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.1
|
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",
|
@@ -20,6 +20,7 @@
|
|
20
20
|
"exports": {
|
21
21
|
".": {
|
22
22
|
"node": {
|
23
|
+
"jsnext:source": "./src/index.ts",
|
23
24
|
"import": "./dist/js/modern/index.js",
|
24
25
|
"require": "./dist/js/node/index.js"
|
25
26
|
},
|
@@ -28,25 +29,26 @@
|
|
28
29
|
},
|
29
30
|
"dependencies": {
|
30
31
|
"@babel/runtime": "^7",
|
31
|
-
"@modern-js/babel-compiler": "^1.1
|
32
|
-
"@modern-js/server-utils": "^1.1
|
33
|
-
"@modern-js/utils": "^1.
|
32
|
+
"@modern-js/babel-compiler": "^1.2.1",
|
33
|
+
"@modern-js/server-utils": "^1.2.1",
|
34
|
+
"@modern-js/utils": "^1.2.2",
|
34
35
|
"globby": "^12.0.2",
|
35
36
|
"json5": "^2.2.0"
|
36
37
|
},
|
37
38
|
"devDependencies": {
|
38
|
-
"@modern-js/plugin-analyze": "^1.1
|
39
|
+
"@modern-js/plugin-analyze": "^1.2.1",
|
39
40
|
"@types/babel__core": "^7.1.15",
|
40
41
|
"@types/jest": "^26",
|
41
42
|
"@types/node": "^14",
|
42
43
|
"ts-jest": "^27.0.5",
|
43
44
|
"typescript": "^4",
|
44
|
-
"@modern-js/core": "^1.
|
45
|
-
"@
|
46
|
-
"
|
45
|
+
"@modern-js/core": "^1.3.2",
|
46
|
+
"@scripts/build": "0.0.0",
|
47
|
+
"jest": "^27",
|
48
|
+
"@scripts/jest-config": "0.0.0"
|
47
49
|
},
|
48
50
|
"peerDependencies": {
|
49
|
-
"@modern-js/core": "^1.
|
51
|
+
"@modern-js/core": "^1.3.2"
|
50
52
|
},
|
51
53
|
"sideEffects": false,
|
52
54
|
"modernConfig": {
|
@@ -56,12 +58,14 @@
|
|
56
58
|
},
|
57
59
|
"publishConfig": {
|
58
60
|
"registry": "https://registry.npmjs.org/",
|
59
|
-
"access": "public"
|
61
|
+
"access": "public",
|
62
|
+
"types": "./dist/types/index.d.ts"
|
60
63
|
},
|
61
64
|
"scripts": {
|
62
65
|
"new": "modern new",
|
63
66
|
"build": "modern build",
|
64
67
|
"dev": "modern build --watch",
|
65
|
-
"test": "
|
66
|
-
}
|
68
|
+
"test": "jest --passWithNoTests"
|
69
|
+
},
|
70
|
+
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
67
71
|
}
|
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;
|