@modern-js/plugin-docsite 1.2.8 → 1.2.11-alhpa.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # @modern-js/plugin-docsite
2
2
 
3
+ ## 1.2.11
4
+
5
+ ### Patch Changes
6
+
7
+ - a1198d509: feat: bump babel 7.18.0
8
+ - Updated dependencies [8d508c6ed]
9
+ - Updated dependencies [a1198d509]
10
+ - Updated dependencies [29728812e]
11
+ - Updated dependencies [147e090f7]
12
+ - Updated dependencies [18892c65c]
13
+ - Updated dependencies [a1198d509]
14
+ - @modern-js/webpack@1.10.0
15
+
16
+ ## 1.2.10
17
+
18
+ ### Patch Changes
19
+
20
+ - d32f35134: chore: add modern/jest/eslint/ts config files to .npmignore
21
+ - Updated dependencies [d2995e7d7]
22
+ - Updated dependencies [47934c4da]
23
+ - Updated dependencies [d32f35134]
24
+ - Updated dependencies [b1f7d2aa6]
25
+ - Updated dependencies [97086dde8]
26
+ - Updated dependencies [6ae4a34ae]
27
+ - Updated dependencies [97086dde8]
28
+ - Updated dependencies [97086dde8]
29
+ - Updated dependencies [b80229c79]
30
+ - Updated dependencies [ff6219909]
31
+ - Updated dependencies [948cc4436]
32
+ - @modern-js/webpack@1.7.0
33
+ - @modern-js/utils@1.7.3
34
+
35
+ ## 1.2.9
36
+
37
+ ### Patch Changes
38
+
39
+ - 69a728375: fix: remove exports.jsnext:source after publish
40
+ - Updated dependencies [b7b8075dc]
41
+ - Updated dependencies [cd7346b0d]
42
+ - Updated dependencies [0e0537005]
43
+ - Updated dependencies [738c55d39]
44
+ - Updated dependencies [69a728375]
45
+ - @modern-js/webpack@1.6.2
46
+ - @modern-js/utils@1.7.2
47
+
3
48
  ## 1.2.8
4
49
 
5
50
  ### 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
- appDirectory,
14
- internalDirectory
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
- appDirectory,
10
- internalDirectory,
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(appDirectory, tmpDir, isDev);
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(appDirectory, tmpDir, isDev) {
8
- // FIXME: 这个包现在没有使用,待使用时再重构 webpack 配置的获取
9
- const originConfig = getWebpackConfig(WebpackConfigTarget.CLIENT, {}, {});
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,12 @@ 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
- path.dirname(require.resolve('@modern-js/plugin-docsite/package.json')), // for pnpm
30
- path.resolve(path.dirname(require.resolve('@modern-js/plugin-docsite/package.json')), '../..')]; // maybe check if outside appDir or monorepoDir
33
+ pluginDocsiteDir, // for pnpm
34
+ path.resolve(pluginDocsiteDir, '../..'), // for modern.js repo
35
+ path.join(pluginDocsiteDir, './node_modules/')];
36
+ console.info(docsiteNodeModules); // maybe check if outside appDir or monorepoDir
31
37
 
32
38
  config.resolve.modules = [...(config.resolve.modules || []), ...docsiteNodeModules];
33
39
  config.resolve.alias['@assets'] = path.resolve(appDirectory, 'assets');
@@ -6,17 +6,15 @@ export default (() => ({
6
6
  commands({
7
7
  program
8
8
  }) {
9
- const {
10
- appDirectory,
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
- appDirectory,
19
- internalDirectory,
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
- } = api.useAppContext();
30
+ } = appContext;
33
31
  return {
34
32
  name: 'Docsite 调试',
35
33
  value: 'docsite',
36
34
  runTask: async () => features.buildDocs({
37
- appDirectory,
38
- internalDirectory,
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
- appDirectory,
18
- internalDirectory
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
- appDirectory,
26
- internalDirectory,
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(appDirectory, tmpDir, isDev);
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(appDirectory, tmpDir, isDev) {
24
- // FIXME: 这个包现在没有使用,待使用时再重构 webpack 配置的获取
25
- const originConfig = (0, _webpack2.getWebpackConfig)(_webpack2.WebpackConfigTarget.CLIENT, {}, {});
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,14 @@ 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
- _path.default.dirname(require.resolve('@modern-js/plugin-docsite/package.json')), // for pnpm
46
- _path.default.resolve(_path.default.dirname(require.resolve('@modern-js/plugin-docsite/package.json')), '../..')]; // maybe check if outside appDir or monorepoDir
51
+ pluginDocsiteDir, // for pnpm
52
+ _path.default.resolve(pluginDocsiteDir, '../..'), // for modern.js repo
53
+ _path.default.join(pluginDocsiteDir, './node_modules/')];
54
+ console.info(docsiteNodeModules); // maybe check if outside appDir or monorepoDir
47
55
 
48
56
  config.resolve.modules = [...(config.resolve.modules || []), ...docsiteNodeModules];
49
57
  config.resolve.alias['@assets'] = _path.default.resolve(appDirectory, 'assets');
@@ -15,17 +15,15 @@ var _default = () => ({
15
15
  commands({
16
16
  program
17
17
  }) {
18
- const {
19
- appDirectory,
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
- appDirectory,
28
- internalDirectory,
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
- } = api.useAppContext();
39
+ } = appContext;
42
40
  return {
43
41
  name: 'Docsite 调试',
44
42
  value: 'docsite',
45
43
  runTask: async () => features.buildDocs({
46
- appDirectory,
47
- internalDirectory,
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
- appDirectory: string;
4
- internalDirectory: string;
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
- appDirectory,
11
- internalDirectory,
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(appDirectory: string, tmpDir: string, isDev: boolean): Configuration;
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.8",
14
+ "version": "1.2.11-alhpa.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -33,12 +33,12 @@
33
33
  "./package.json": "./package.json"
34
34
  },
35
35
  "dependencies": {
36
- "@babel/parser": "^7.15.2",
37
- "@babel/runtime": "^7",
36
+ "@babel/parser": "^7.18.0",
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.6.0",
41
- "@modern-js/webpack": "^1.5.7",
40
+ "@modern-js/utils": "^1.7.7",
41
+ "@modern-js/webpack": "^1.11.0",
42
42
  "antd": "^4.16.13",
43
43
  "core-js": "^3.17.2",
44
44
  "github-slugger": "^1.4.0",
@@ -55,16 +55,17 @@
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.9.0",
62
+ "@modern-js/core": "1.12.0",
62
63
  "@scripts/build": "0.0.0",
63
64
  "@scripts/jest-config": "0.0.0",
64
65
  "@types/core-js": "^2.5.5",
65
66
  "@types/github-slugger": "^1.3.0",
66
67
  "@types/glob": "^7.1.4",
67
- "@types/jest": "^26",
68
+ "@types/jest": "^27",
68
69
  "@types/node": "^14",
69
70
  "@types/react": "^17",
70
71
  "@types/react-dom": "^17",
@@ -88,10 +89,34 @@
88
89
  "registry": "https://registry.npmjs.org/",
89
90
  "access": "public"
90
91
  },
92
+ "wireit": {
93
+ "build": {
94
+ "command": "modern build",
95
+ "files": [
96
+ "src/**/*",
97
+ "tsconfig.json",
98
+ "package.json"
99
+ ],
100
+ "output": [
101
+ "dist/**/*"
102
+ ]
103
+ },
104
+ "test": {
105
+ "command": "jest --passWithNoTests",
106
+ "files": [
107
+ "src/**/*",
108
+ "tsconfig.json",
109
+ "package.json",
110
+ "tests/**/*"
111
+ ],
112
+ "output": []
113
+ }
114
+ },
91
115
  "scripts": {
92
116
  "new": "modern new",
93
- "build": "modern build",
94
- "test": "jest --passWithNoTests"
117
+ "build": "wireit",
118
+ "test": "wireit",
119
+ "dev": "modern build --watch"
95
120
  },
96
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"
97
122
  }
package/.eslintrc.js DELETED
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- extends: ['@modern-js'],
4
- parserOptions: {
5
- tsconfigRootDir: __dirname,
6
- project: ['./tsconfig.json'],
7
- },
8
- };
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "module": "esnext",
5
- "baseUrl": "./",
6
- "paths": {
7
- "@*": ["./*"]
8
- },
9
- "lib": ["dom", "dom.iterable", "esnext"],
10
- "allowJs": true,
11
- "skipLibCheck": true,
12
- "esModuleInterop": true,
13
- "allowSyntheticDefaultImports": true,
14
- "strict": true,
15
- "noImplicitReturns": true,
16
- "noUnusedLocals": true,
17
- "noUnusedParameters": true,
18
- "forceConsistentCasingInFileNames": true,
19
- "moduleResolution": "node",
20
- "resolveJsonModule": true,
21
- "noEmit": true,
22
- "jsx": "react"
23
- },
24
- "include": ["src"]
25
- }
package/jest.config.js DELETED
@@ -1,7 +0,0 @@
1
- const sharedConfig = require('@scripts/jest-config');
2
-
3
- /** @type {import('@jest/types').Config.InitialOptions} */
4
- module.exports = {
5
- ...sharedConfig,
6
- rootDir: __dirname,
7
- };
package/modern.config.js DELETED
@@ -1,2 +0,0 @@
1
- /** @type {import('@modern-js/module-tools').UserConfig} */
2
- module.exports = {};
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "module": "esnext",
5
- "baseUrl": "./",
6
- "paths": {
7
- "@*": ["./*"]
8
- },
9
- "lib": ["dom", "dom.iterable", "esnext"],
10
- "allowJs": true,
11
- "skipLibCheck": true,
12
- "esModuleInterop": true,
13
- "allowSyntheticDefaultImports": true,
14
- "strict": true,
15
- "noImplicitReturns": true,
16
- "noUnusedLocals": true,
17
- "noUnusedParameters": true,
18
- "forceConsistentCasingInFileNames": true,
19
- "moduleResolution": "node",
20
- "resolveJsonModule": true,
21
- "noEmit": true,
22
- "jsx": "react"
23
- },
24
- "include": ["src"]
25
- }
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true,
8
- "paths": {}
9
- },
10
- "include": ["src"]
11
- }