@modern-js/plugin-docsite 1.2.11 → 1.2.12
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/CHANGELOG.md +17 -0
- package/dist/js/modern/build-task.js +6 -13
- package/dist/js/modern/features/index.js +8 -3
- package/dist/js/modern/features/utils/webpack.js +10 -5
- package/dist/js/modern/index.js +9 -11
- package/dist/js/node/build-task.js +6 -13
- package/dist/js/node/features/index.js +8 -3
- package/dist/js/node/features/utils/webpack.js +12 -5
- package/dist/js/node/index.js +9 -11
- package/dist/types/features/index.d.ts +5 -4
- package/dist/types/features/utils/webpack.d.ts +2 -1
- package/package.json +8 -6
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# @modern-js/plugin-docsite
|
2
2
|
|
3
|
+
## 1.2.12
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- df5e115ad: fix run docsite fail
|
8
|
+
- Updated dependencies [06b411dc3]
|
9
|
+
- Updated dependencies [5d4806f86]
|
10
|
+
- Updated dependencies [63c354ad5]
|
11
|
+
- Updated dependencies [4165e50c7]
|
12
|
+
- Updated dependencies [073e9ad78]
|
13
|
+
- Updated dependencies [cda99c441]
|
14
|
+
- Updated dependencies [b96dcf364]
|
15
|
+
- Updated dependencies [f4a7d49e1]
|
16
|
+
- Updated dependencies [9e36d3a01]
|
17
|
+
- @modern-js/webpack@1.11.1
|
18
|
+
- @modern-js/utils@1.7.8
|
19
|
+
|
3
20
|
## 1.2.11
|
4
21
|
|
5
22
|
### Patch Changes
|
@@ -2,16 +2,10 @@ import { Import } from '@modern-js/utils';
|
|
2
2
|
const core = Import.lazy('@modern-js/core', require);
|
3
3
|
const features = Import.lazy('./features', require);
|
4
4
|
|
5
|
-
const taskMain = async ({
|
6
|
-
appContext
|
7
|
-
}) => {
|
8
|
-
const {
|
9
|
-
appDirectory,
|
10
|
-
internalDirectory
|
11
|
-
} = appContext;
|
5
|
+
const taskMain = async (appContext, modernConfig) => {
|
12
6
|
await features.buildDocs({
|
13
|
-
|
14
|
-
|
7
|
+
appContext,
|
8
|
+
modernConfig
|
15
9
|
});
|
16
10
|
};
|
17
11
|
|
@@ -25,13 +19,12 @@ const taskMain = async ({
|
|
25
19
|
}
|
26
20
|
|
27
21
|
const {
|
28
|
-
appContext
|
22
|
+
appContext,
|
23
|
+
resolved
|
29
24
|
} = await core.cli.init([], options);
|
30
25
|
await core.manager.run(async () => {
|
31
26
|
try {
|
32
|
-
await taskMain(
|
33
|
-
appContext
|
34
|
-
});
|
27
|
+
await taskMain(appContext, resolved);
|
35
28
|
} catch (e) {
|
36
29
|
console.error(e.message);
|
37
30
|
}
|
@@ -6,11 +6,16 @@ const devFeat = Import.lazy('./dev', require);
|
|
6
6
|
const wp = Import.lazy('./utils/webpack', require);
|
7
7
|
const DEFAULT_PORT = 5000;
|
8
8
|
export async function buildDocs({
|
9
|
-
|
10
|
-
|
9
|
+
appContext,
|
10
|
+
modernConfig,
|
11
11
|
isDev = false,
|
12
12
|
port = DEFAULT_PORT
|
13
13
|
}) {
|
14
|
+
const {
|
15
|
+
appDirectory,
|
16
|
+
internalDirectory
|
17
|
+
} = appContext;
|
18
|
+
|
14
19
|
if (!valid({
|
15
20
|
appDirectory,
|
16
21
|
docsDir: 'docs'
|
@@ -36,7 +41,7 @@ export async function buildDocs({
|
|
36
41
|
|
37
42
|
const tmpDir = path.join(internalDirectory, './docs');
|
38
43
|
fs.ensureDirSync(tmpDir);
|
39
|
-
const finalWebpackConfig = wp.generatorWebpackConfig(
|
44
|
+
const finalWebpackConfig = wp.generatorWebpackConfig(appContext, modernConfig, tmpDir, isDev);
|
40
45
|
|
41
46
|
if (!isDev) {
|
42
47
|
logger.info('build docs');
|
@@ -4,9 +4,12 @@ import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
4
4
|
import webpack from 'webpack';
|
5
5
|
import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack';
|
6
6
|
import { UTILS_STATIC } from "../constant";
|
7
|
-
export function generatorWebpackConfig(
|
8
|
-
|
9
|
-
|
7
|
+
export function generatorWebpackConfig(appContext, modernConfig, tmpDir, isDev) {
|
8
|
+
const {
|
9
|
+
appDirectory
|
10
|
+
} = appContext; // FIXME: 这个包现在没有使用,待使用时再重构 webpack 配置的获取
|
11
|
+
|
12
|
+
const originConfig = getWebpackConfig(WebpackConfigTarget.CLIENT, appContext, modernConfig);
|
10
13
|
const plugins = (originConfig.plugins || []).filter(p => p.constructor !== webpack.HotModuleReplacementPlugin);
|
11
14
|
const config = {
|
12
15
|
mode: isDev ? 'development' : 'production',
|
@@ -25,9 +28,11 @@ export function generatorWebpackConfig(appDirectory, tmpDir, isDev) {
|
|
25
28
|
templateContent: fs.readFileSync(path.resolve(UTILS_STATIC, 'index.html.ejs'), 'utf8')
|
26
29
|
})]
|
27
30
|
};
|
31
|
+
const pluginDocsiteDir = path.dirname(require.resolve('@modern-js/plugin-docsite/package.json'));
|
28
32
|
const docsiteNodeModules = [// for yarn
|
29
|
-
|
30
|
-
path.resolve(
|
33
|
+
pluginDocsiteDir, // for pnpm
|
34
|
+
path.resolve(pluginDocsiteDir, '../..'), // for modern.js repo
|
35
|
+
path.join(pluginDocsiteDir, './node_modules/')]; // maybe check if outside appDir or monorepoDir
|
31
36
|
|
32
37
|
config.resolve.modules = [...(config.resolve.modules || []), ...docsiteNodeModules];
|
33
38
|
config.resolve.alias['@assets'] = path.resolve(appDirectory, 'assets');
|
package/dist/js/modern/index.js
CHANGED
@@ -6,17 +6,15 @@ export default (() => ({
|
|
6
6
|
commands({
|
7
7
|
program
|
8
8
|
}) {
|
9
|
-
const
|
10
|
-
|
11
|
-
internalDirectory
|
12
|
-
} = api.useAppContext();
|
9
|
+
const appContext = api.useAppContext();
|
10
|
+
const modernConfig = api.useResolvedConfigContext();
|
13
11
|
const devCommand = program.commandsMap.get('dev');
|
14
12
|
|
15
13
|
if (devCommand) {
|
16
14
|
devCommand.command('docs').action(async () => {
|
17
15
|
await features.buildDocs({
|
18
|
-
|
19
|
-
|
16
|
+
appContext,
|
17
|
+
modernConfig,
|
20
18
|
isDev: true
|
21
19
|
});
|
22
20
|
});
|
@@ -25,17 +23,17 @@ export default (() => ({
|
|
25
23
|
|
26
24
|
// module-tools menu mode
|
27
25
|
moduleToolsMenu() {
|
26
|
+
const appContext = api.useAppContext();
|
27
|
+
const modernConfig = api.useResolvedConfigContext();
|
28
28
|
const {
|
29
|
-
appDirectory,
|
30
|
-
internalDirectory,
|
31
29
|
port
|
32
|
-
} =
|
30
|
+
} = appContext;
|
33
31
|
return {
|
34
32
|
name: 'Docsite 调试',
|
35
33
|
value: 'docsite',
|
36
34
|
runTask: async () => features.buildDocs({
|
37
|
-
|
38
|
-
|
35
|
+
appContext,
|
36
|
+
modernConfig,
|
39
37
|
isDev: true,
|
40
38
|
port
|
41
39
|
})
|
@@ -6,16 +6,10 @@ const core = _utils.Import.lazy('@modern-js/core', require);
|
|
6
6
|
|
7
7
|
const features = _utils.Import.lazy('./features', require);
|
8
8
|
|
9
|
-
const taskMain = async ({
|
10
|
-
appContext
|
11
|
-
}) => {
|
12
|
-
const {
|
13
|
-
appDirectory,
|
14
|
-
internalDirectory
|
15
|
-
} = appContext;
|
9
|
+
const taskMain = async (appContext, modernConfig) => {
|
16
10
|
await features.buildDocs({
|
17
|
-
|
18
|
-
|
11
|
+
appContext,
|
12
|
+
modernConfig
|
19
13
|
});
|
20
14
|
};
|
21
15
|
|
@@ -29,13 +23,12 @@ const taskMain = async ({
|
|
29
23
|
}
|
30
24
|
|
31
25
|
const {
|
32
|
-
appContext
|
26
|
+
appContext,
|
27
|
+
resolved
|
33
28
|
} = await core.cli.init([], options);
|
34
29
|
await core.manager.run(async () => {
|
35
30
|
try {
|
36
|
-
await taskMain(
|
37
|
-
appContext
|
38
|
-
});
|
31
|
+
await taskMain(appContext, resolved);
|
39
32
|
} catch (e) {
|
40
33
|
console.error(e.message);
|
41
34
|
}
|
@@ -22,11 +22,16 @@ const wp = _utils.Import.lazy('./utils/webpack', require);
|
|
22
22
|
const DEFAULT_PORT = 5000;
|
23
23
|
|
24
24
|
async function buildDocs({
|
25
|
-
|
26
|
-
|
25
|
+
appContext,
|
26
|
+
modernConfig,
|
27
27
|
isDev = false,
|
28
28
|
port = DEFAULT_PORT
|
29
29
|
}) {
|
30
|
+
const {
|
31
|
+
appDirectory,
|
32
|
+
internalDirectory
|
33
|
+
} = appContext;
|
34
|
+
|
30
35
|
if (!(0, _valid.valid)({
|
31
36
|
appDirectory,
|
32
37
|
docsDir: 'docs'
|
@@ -55,7 +60,7 @@ async function buildDocs({
|
|
55
60
|
|
56
61
|
_utils.fs.ensureDirSync(tmpDir);
|
57
62
|
|
58
|
-
const finalWebpackConfig = wp.generatorWebpackConfig(
|
63
|
+
const finalWebpackConfig = wp.generatorWebpackConfig(appContext, modernConfig, tmpDir, isDev);
|
59
64
|
|
60
65
|
if (!isDev) {
|
61
66
|
_utils.logger.info('build docs');
|
@@ -20,9 +20,12 @@ var _constant = require("../constant");
|
|
20
20
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
22
22
|
|
23
|
-
function generatorWebpackConfig(
|
24
|
-
|
25
|
-
|
23
|
+
function generatorWebpackConfig(appContext, modernConfig, tmpDir, isDev) {
|
24
|
+
const {
|
25
|
+
appDirectory
|
26
|
+
} = appContext; // FIXME: 这个包现在没有使用,待使用时再重构 webpack 配置的获取
|
27
|
+
|
28
|
+
const originConfig = (0, _webpack2.getWebpackConfig)(_webpack2.WebpackConfigTarget.CLIENT, appContext, modernConfig);
|
26
29
|
const plugins = (originConfig.plugins || []).filter(p => p.constructor !== _webpack.default.HotModuleReplacementPlugin);
|
27
30
|
const config = {
|
28
31
|
mode: isDev ? 'development' : 'production',
|
@@ -41,9 +44,13 @@ function generatorWebpackConfig(appDirectory, tmpDir, isDev) {
|
|
41
44
|
templateContent: _utils.fs.readFileSync(_path.default.resolve(_constant.UTILS_STATIC, 'index.html.ejs'), 'utf8')
|
42
45
|
})]
|
43
46
|
};
|
47
|
+
|
48
|
+
const pluginDocsiteDir = _path.default.dirname(require.resolve('@modern-js/plugin-docsite/package.json'));
|
49
|
+
|
44
50
|
const docsiteNodeModules = [// for yarn
|
45
|
-
|
46
|
-
_path.default.resolve(
|
51
|
+
pluginDocsiteDir, // for pnpm
|
52
|
+
_path.default.resolve(pluginDocsiteDir, '../..'), // for modern.js repo
|
53
|
+
_path.default.join(pluginDocsiteDir, './node_modules/')]; // maybe check if outside appDir or monorepoDir
|
47
54
|
|
48
55
|
config.resolve.modules = [...(config.resolve.modules || []), ...docsiteNodeModules];
|
49
56
|
config.resolve.alias['@assets'] = _path.default.resolve(appDirectory, 'assets');
|
package/dist/js/node/index.js
CHANGED
@@ -15,17 +15,15 @@ var _default = () => ({
|
|
15
15
|
commands({
|
16
16
|
program
|
17
17
|
}) {
|
18
|
-
const
|
19
|
-
|
20
|
-
internalDirectory
|
21
|
-
} = api.useAppContext();
|
18
|
+
const appContext = api.useAppContext();
|
19
|
+
const modernConfig = api.useResolvedConfigContext();
|
22
20
|
const devCommand = program.commandsMap.get('dev');
|
23
21
|
|
24
22
|
if (devCommand) {
|
25
23
|
devCommand.command('docs').action(async () => {
|
26
24
|
await features.buildDocs({
|
27
|
-
|
28
|
-
|
25
|
+
appContext,
|
26
|
+
modernConfig,
|
29
27
|
isDev: true
|
30
28
|
});
|
31
29
|
});
|
@@ -34,17 +32,17 @@ var _default = () => ({
|
|
34
32
|
|
35
33
|
// module-tools menu mode
|
36
34
|
moduleToolsMenu() {
|
35
|
+
const appContext = api.useAppContext();
|
36
|
+
const modernConfig = api.useResolvedConfigContext();
|
37
37
|
const {
|
38
|
-
appDirectory,
|
39
|
-
internalDirectory,
|
40
38
|
port
|
41
|
-
} =
|
39
|
+
} = appContext;
|
42
40
|
return {
|
43
41
|
name: 'Docsite 调试',
|
44
42
|
value: 'docsite',
|
45
43
|
runTask: async () => features.buildDocs({
|
46
|
-
|
47
|
-
|
44
|
+
appContext,
|
45
|
+
modernConfig,
|
48
46
|
isDev: true,
|
49
47
|
port
|
50
48
|
})
|
@@ -1,14 +1,15 @@
|
|
1
|
+
import type { IAppContext, NormalizedConfig } from '@modern-js/core';
|
1
2
|
import type { Configuration } from 'webpack';
|
2
3
|
interface IBuildDocsParams {
|
3
|
-
|
4
|
-
|
4
|
+
appContext: IAppContext;
|
5
|
+
modernConfig: NormalizedConfig;
|
5
6
|
webpackConfig?: Configuration;
|
6
7
|
isDev?: boolean;
|
7
8
|
port?: number;
|
8
9
|
}
|
9
10
|
export declare function buildDocs({
|
10
|
-
|
11
|
-
|
11
|
+
appContext,
|
12
|
+
modernConfig,
|
12
13
|
isDev,
|
13
14
|
port
|
14
15
|
}: IBuildDocsParams): Promise<void>;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { IAppContext, NormalizedConfig } from '@modern-js/core';
|
1
2
|
import { Configuration } from 'webpack';
|
2
|
-
export declare function generatorWebpackConfig(
|
3
|
+
export declare function generatorWebpackConfig(appContext: IAppContext, modernConfig: NormalizedConfig, tmpDir: string, isDev: boolean): Configuration;
|
3
4
|
export declare function runWebpack(config: Configuration): Promise<void>;
|
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.12",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -37,8 +37,8 @@
|
|
37
37
|
"@babel/runtime": "^7.18.0",
|
38
38
|
"@mdx-js/mdx": "^1.6.22",
|
39
39
|
"@mdx-js/react": "^1.6.22",
|
40
|
-
"@modern-js/utils": "^1.7.
|
41
|
-
"@modern-js/webpack": "^1.
|
40
|
+
"@modern-js/utils": "^1.7.8",
|
41
|
+
"@modern-js/webpack": "^1.11.1",
|
42
42
|
"antd": "^4.16.13",
|
43
43
|
"core-js": "^3.17.2",
|
44
44
|
"github-slugger": "^1.4.0",
|
@@ -55,10 +55,11 @@
|
|
55
55
|
"unist-builder": "^2.0.3",
|
56
56
|
"unist-util-visit": "^2.0.3",
|
57
57
|
"webpack": "^5.71.0",
|
58
|
-
"webpack-dev-server": "^4.1.1"
|
58
|
+
"webpack-dev-server": "^4.1.1",
|
59
|
+
"styled-components": "^5.3.5"
|
59
60
|
},
|
60
61
|
"devDependencies": {
|
61
|
-
"@modern-js/core": "1.
|
62
|
+
"@modern-js/core": "1.12.1",
|
62
63
|
"@scripts/build": "0.0.0",
|
63
64
|
"@scripts/jest-config": "0.0.0",
|
64
65
|
"@types/core-js": "^2.5.5",
|
@@ -114,7 +115,8 @@
|
|
114
115
|
"scripts": {
|
115
116
|
"new": "modern new",
|
116
117
|
"build": "wireit",
|
117
|
-
"test": "wireit"
|
118
|
+
"test": "wireit",
|
119
|
+
"dev": "modern build --watch"
|
118
120
|
},
|
119
121
|
"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"
|
120
122
|
}
|