@modern-js/plugin-docsite 1.0.0-rc.13 → 1.0.0-rc.17
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 +56 -0
- package/dist/js/modern/features/constant.js +1 -1
- package/dist/js/modern/features/dev.js +1 -2
- package/dist/js/modern/features/index.js +1 -2
- package/dist/js/modern/features/utils/chokidar.js +1 -2
- package/dist/js/modern/features/utils/generate-files.js +1 -2
- package/dist/js/modern/features/utils/webpack.js +2 -3
- package/dist/js/modern/index.js +2 -2
- package/dist/js/node/features/constant.js +2 -4
- package/dist/js/node/features/dev.js +2 -4
- package/dist/js/node/features/index.js +2 -6
- package/dist/js/node/features/utils/chokidar.js +2 -4
- package/dist/js/node/features/utils/generate-files.js +17 -19
- package/dist/js/node/features/utils/webpack.js +13 -15
- package/dist/js/node/index.js +1 -1
- package/package.json +87 -87
- package/src/features/constant.ts +1 -1
- package/src/features/dev.ts +1 -2
- package/src/features/index.ts +1 -2
- package/src/features/utils/chokidar.ts +1 -2
- package/src/features/utils/generate-files.ts +1 -2
- package/src/features/utils/webpack.ts +2 -3
- package/src/index.ts +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,61 @@
|
|
1
1
|
# @modern-js/plugin-docsite
|
2
2
|
|
3
|
+
## 1.0.0-rc.17
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 224f7fe: fix server route match
|
8
|
+
- 30ac27c: feat: add generator package description
|
9
|
+
- 204c626: feat: initial
|
10
|
+
- fix: #118 #104
|
11
|
+
- Updated dependencies [224f7fe]
|
12
|
+
- Updated dependencies [30ac27c]
|
13
|
+
- Updated dependencies [204c626]
|
14
|
+
- Updated dependencies [undefined]
|
15
|
+
- @modern-js/core@1.0.0-rc.17
|
16
|
+
- @modern-js/webpack@1.0.0-rc.17
|
17
|
+
- @modern-js/utils@1.0.0-rc.17
|
18
|
+
|
19
|
+
## 1.0.0-rc.16
|
20
|
+
|
21
|
+
### Patch Changes
|
22
|
+
|
23
|
+
- 224f7fe: fix server route match
|
24
|
+
- 30ac27c: feat: add generator package description
|
25
|
+
- 204c626: feat: initial
|
26
|
+
- Updated dependencies [224f7fe]
|
27
|
+
- Updated dependencies [30ac27c]
|
28
|
+
- Updated dependencies [204c626]
|
29
|
+
- @modern-js/core@1.0.0-rc.16
|
30
|
+
- @modern-js/webpack@1.0.0-rc.16
|
31
|
+
- @modern-js/utils@1.0.0-rc.16
|
32
|
+
|
33
|
+
## 1.0.0-rc.15
|
34
|
+
|
35
|
+
### Patch Changes
|
36
|
+
|
37
|
+
- 224f7fe: fix server route match
|
38
|
+
- 30ac27c: feat: add generator package description
|
39
|
+
- 204c626: feat: initial
|
40
|
+
- Updated dependencies [224f7fe]
|
41
|
+
- Updated dependencies [30ac27c]
|
42
|
+
- Updated dependencies [204c626]
|
43
|
+
- @modern-js/core@1.0.0-rc.15
|
44
|
+
- @modern-js/webpack@1.0.0-rc.15
|
45
|
+
- @modern-js/utils@1.0.0-rc.15
|
46
|
+
|
47
|
+
## 1.0.0-rc.14
|
48
|
+
|
49
|
+
### Patch Changes
|
50
|
+
|
51
|
+
- 224f7fe: fix server route match
|
52
|
+
- 204c626: feat: initial
|
53
|
+
- Updated dependencies [224f7fe]
|
54
|
+
- Updated dependencies [204c626]
|
55
|
+
- @modern-js/core@1.0.0-rc.14
|
56
|
+
- @modern-js/webpack@1.0.0-rc.14
|
57
|
+
- @modern-js/utils@1.0.0-rc.14
|
58
|
+
|
3
59
|
## 1.0.0-rc.13
|
4
60
|
|
5
61
|
### Patch Changes
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import path from '
|
1
|
+
import { path, logger } from '@modern-js/utils';
|
2
2
|
import webpack from 'webpack';
|
3
3
|
import WebpackDevServer from 'webpack-dev-server';
|
4
|
-
import { logger } from '@modern-js/utils';
|
5
4
|
import { chokidarFile } from "./utils/chokidar";
|
6
5
|
import { generateFiles } from "./utils/generate-files"; // eslint-disable-next-line max-params
|
7
6
|
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import path from '
|
2
|
-
import { fs, Import, logger } from '@modern-js/utils';
|
1
|
+
import { path, fs, Import, logger } from '@modern-js/utils';
|
3
2
|
import { valid } from "./utils/valid";
|
4
3
|
const buildFeat = Import.lazy('./build', require);
|
5
4
|
const devFeat = Import.lazy('./dev', require);
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import path from '
|
1
|
+
import { path, logger } from '@modern-js/utils';
|
2
2
|
import chokidar from 'chokidar';
|
3
3
|
import glob from 'glob';
|
4
|
-
import { logger } from '@modern-js/utils';
|
5
4
|
import { generateFiles } from "./generate-files";
|
6
5
|
export function chokidarFile(appDirectory, tmpDir, isDev) {
|
7
6
|
let dirty = false;
|
@@ -10,7 +10,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
10
10
|
|
11
11
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
12
12
|
|
13
|
-
import path from '
|
13
|
+
import { path, logger, fs } from '@modern-js/utils';
|
14
14
|
import matter from 'gray-matter';
|
15
15
|
import GithubSlugger from 'github-slugger';
|
16
16
|
import sortPaths from 'sort-paths';
|
@@ -19,7 +19,6 @@ import toString from 'mdast-util-to-string';
|
|
19
19
|
import u from 'unist-builder';
|
20
20
|
import mdx from '@mdx-js/mdx';
|
21
21
|
import babelParser from '@babel/parser';
|
22
|
-
import { logger, fs } from '@modern-js/utils';
|
23
22
|
import { DOCS_RENDER_PATH, MDX_DEFAULT_RENDERER, UTILS_STATIC } from "../constant";
|
24
23
|
|
25
24
|
const loadTemplate = async (file, customPath = false) => {
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import path from '
|
2
|
-
import { fs } from '@modern-js/utils';
|
1
|
+
import { path, fs, upath } from '@modern-js/utils';
|
3
2
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
4
3
|
import webpack from 'webpack';
|
5
4
|
import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack';
|
@@ -44,7 +43,7 @@ export function generatorWebpackConfig(appDirectory, tmpDir, isDev) {
|
|
44
43
|
}
|
45
44
|
|
46
45
|
config.resolve.fallback = {
|
47
|
-
path: require.resolve('path-browserify')
|
46
|
+
path: upath.normalizeSafe(require.resolve('path-browserify'))
|
48
47
|
};
|
49
48
|
return config;
|
50
49
|
}
|
package/dist/js/modern/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Import } from '@modern-js/utils';
|
1
|
+
import { Import, upath } from '@modern-js/utils';
|
2
2
|
const core = Import.lazy('@modern-js/core', require);
|
3
3
|
const features = Import.lazy('./features', require);
|
4
4
|
export default core.createPlugin(() => ({
|
@@ -39,7 +39,7 @@ export default core.createPlugin(() => ({
|
|
39
39
|
return {
|
40
40
|
name: 'docsite',
|
41
41
|
title: 'Run Docsite log',
|
42
|
-
taskPath: require.resolve("./build-task"),
|
42
|
+
taskPath: upath.normalizeSafe(require.resolve("./build-task")),
|
43
43
|
params: []
|
44
44
|
};
|
45
45
|
}
|
@@ -5,11 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.UTILS_STATIC = exports.MDX_DEFAULT_RENDERER = exports.DOCS_RENDER_PATH = void 0;
|
7
7
|
|
8
|
-
var
|
8
|
+
var _utils = require("@modern-js/utils");
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
const UTILS_STATIC = _path.default.join(__dirname, '../../static');
|
10
|
+
const UTILS_STATIC = _utils.path.join(__dirname, '../../static');
|
13
11
|
|
14
12
|
exports.UTILS_STATIC = UTILS_STATIC;
|
15
13
|
const DOCS_RENDER_PATH = '/api/v1/docs/render';
|
@@ -5,14 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.dev = dev;
|
7
7
|
|
8
|
-
var
|
8
|
+
var _utils = require("@modern-js/utils");
|
9
9
|
|
10
10
|
var _webpack = _interopRequireDefault(require("webpack"));
|
11
11
|
|
12
12
|
var _webpackDevServer = _interopRequireDefault(require("webpack-dev-server"));
|
13
13
|
|
14
|
-
var _utils = require("@modern-js/utils");
|
15
|
-
|
16
14
|
var _chokidar = require("./utils/chokidar");
|
17
15
|
|
18
16
|
var _generateFiles = require("./utils/generate-files");
|
@@ -28,7 +26,7 @@ async function dev(appDirectory, tmpDir, files, webpackConfig, isDev, port) {
|
|
28
26
|
port,
|
29
27
|
historyApiFallback: true,
|
30
28
|
static: {
|
31
|
-
directory:
|
29
|
+
directory: _utils.path.resolve(appDirectory, 'assets'),
|
32
30
|
publicPath: '/assets'
|
33
31
|
}
|
34
32
|
}, compiler);
|
@@ -5,14 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.buildDocs = buildDocs;
|
7
7
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
9
|
-
|
10
8
|
var _utils = require("@modern-js/utils");
|
11
9
|
|
12
10
|
var _valid = require("./utils/valid");
|
13
11
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
-
|
16
12
|
const buildFeat = _utils.Import.lazy('./build', require);
|
17
13
|
|
18
14
|
const devFeat = _utils.Import.lazy('./dev', require);
|
@@ -35,7 +31,7 @@ async function buildDocs({
|
|
35
31
|
return;
|
36
32
|
}
|
37
33
|
|
38
|
-
const docsDir =
|
34
|
+
const docsDir = _utils.path.resolve(appDirectory, 'docs');
|
39
35
|
|
40
36
|
if (!_utils.fs.pathExistsSync(docsDir)) {
|
41
37
|
return;
|
@@ -52,7 +48,7 @@ async function buildDocs({
|
|
52
48
|
return;
|
53
49
|
}
|
54
50
|
|
55
|
-
const tmpDir =
|
51
|
+
const tmpDir = _utils.path.join(appDirectory, './node_modules/.modern-js/docs');
|
56
52
|
|
57
53
|
_utils.fs.ensureDirSync(tmpDir);
|
58
54
|
|
@@ -5,14 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.chokidarFile = chokidarFile;
|
7
7
|
|
8
|
-
var
|
8
|
+
var _utils = require("@modern-js/utils");
|
9
9
|
|
10
10
|
var _chokidar = _interopRequireDefault(require("chokidar"));
|
11
11
|
|
12
12
|
var _glob = _interopRequireDefault(require("glob"));
|
13
13
|
|
14
|
-
var _utils = require("@modern-js/utils");
|
15
|
-
|
16
14
|
var _generateFiles = require("./generate-files");
|
17
15
|
|
18
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -34,7 +32,7 @@ function chokidarFile(appDirectory, tmpDir, isDev) {
|
|
34
32
|
_utils.logger.info('changed, collect and rebuild docs');
|
35
33
|
|
36
34
|
const files = _glob.default.sync('**/*.{md,mdx}', {
|
37
|
-
cwd:
|
35
|
+
cwd: _utils.path.resolve(appDirectory, 'docs'),
|
38
36
|
ignore: '**/_*'
|
39
37
|
});
|
40
38
|
|
@@ -15,7 +15,7 @@ var _camelCase2 = _interopRequireDefault(require("lodash/camelCase"));
|
|
15
15
|
|
16
16
|
var _startCase2 = _interopRequireDefault(require("lodash/startCase"));
|
17
17
|
|
18
|
-
var
|
18
|
+
var _utils = require("@modern-js/utils");
|
19
19
|
|
20
20
|
var _grayMatter = _interopRequireDefault(require("gray-matter"));
|
21
21
|
|
@@ -33,8 +33,6 @@ var _mdx = _interopRequireDefault(require("@mdx-js/mdx"));
|
|
33
33
|
|
34
34
|
var _parser = _interopRequireDefault(require("@babel/parser"));
|
35
35
|
|
36
|
-
var _utils = require("@modern-js/utils");
|
37
|
-
|
38
36
|
var _constant = require("../constant");
|
39
37
|
|
40
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -51,7 +49,7 @@ const loadTemplate = async (file, customPath = false) => {
|
|
51
49
|
if (customPath) {
|
52
50
|
result = await _utils.fs.readFile(file, 'utf-8');
|
53
51
|
} else {
|
54
|
-
result = await _utils.fs.readFile(
|
52
|
+
result = await _utils.fs.readFile(_utils.path.join(_constant.UTILS_STATIC, file), 'utf-8');
|
55
53
|
}
|
56
54
|
|
57
55
|
return (0, _template2.default)(result, {
|
@@ -62,11 +60,11 @@ const loadTemplate = async (file, customPath = false) => {
|
|
62
60
|
// eslint-disable-next-line max-statements
|
63
61
|
async function handleFile(appDirectory, tmpDir, file, images) {
|
64
62
|
const moduleName = file.replace(/\.(md|mdx)$/, '');
|
65
|
-
const content = await _utils.fs.readFile(
|
63
|
+
const content = await _utils.fs.readFile(_utils.path.resolve(appDirectory, 'docs', file));
|
66
64
|
const parsed = (0, _grayMatter.default)(content);
|
67
65
|
|
68
66
|
if (!parsed.data.title) {
|
69
|
-
parsed.data.title = (0, _startCase2.default)((0, _camelCase2.default)(
|
67
|
+
parsed.data.title = (0, _startCase2.default)((0, _camelCase2.default)(_utils.path.basename(moduleName)));
|
70
68
|
}
|
71
69
|
|
72
70
|
const slugger = new _githubSlugger.default();
|
@@ -148,15 +146,15 @@ async function handleFile(appDirectory, tmpDir, file, images) {
|
|
148
146
|
} = node;
|
149
147
|
|
150
148
|
if (!url.startsWith('http')) {
|
151
|
-
const fullPath =
|
149
|
+
const fullPath = _utils.path.resolve(_utils.path.dirname(_utils.path.resolve(appDirectory, 'docs', file)), url);
|
152
150
|
|
153
|
-
const relativePath =
|
151
|
+
const relativePath = _utils.path.relative(_utils.path.resolve(appDirectory, 'assets'), fullPath);
|
154
152
|
|
155
153
|
if (relativePath.startsWith('..')) {
|
156
154
|
_utils.logger.warn(`${url} referenced in ${file} is not under the "assets" folder`);
|
157
155
|
} else {
|
158
156
|
images.push(relativePath);
|
159
|
-
node.url = `/${
|
157
|
+
node.url = `/${_utils.path.relative(_utils.path.dirname(_utils.path.resolve(appDirectory, 'docs', file)), _utils.path.resolve(appDirectory, 'docs/assets', relativePath))}`;
|
160
158
|
}
|
161
159
|
}
|
162
160
|
});
|
@@ -167,19 +165,19 @@ async function handleFile(appDirectory, tmpDir, file, images) {
|
|
167
165
|
});
|
168
166
|
const totalExported = (0, _union2.default)(imported.map(n => n.id), exported.map(n => n.id));
|
169
167
|
|
170
|
-
const outputFile =
|
168
|
+
const outputFile = _utils.path.resolve(tmpDir, `${moduleName}/mdx.jsx`);
|
171
169
|
|
172
170
|
await _utils.fs.outputFile(outputFile, _constant.MDX_DEFAULT_RENDERER + transpiled, {
|
173
171
|
encoding: 'utf8'
|
174
172
|
});
|
175
173
|
|
176
|
-
const pageFile =
|
174
|
+
const pageFile = _utils.path.resolve(tmpDir, `${moduleName}/index.jsx`);
|
177
175
|
|
178
176
|
const pageTemplate = await loadTemplate('docs-page.jsx.tpl');
|
179
177
|
const pageContent = pageTemplate({
|
180
178
|
moduleName,
|
181
179
|
toc: JSON.stringify(toc),
|
182
|
-
relRoot:
|
180
|
+
relRoot: _utils.path.relative(_utils.path.dirname(outputFile), tmpDir),
|
183
181
|
imports: totalExported.length ? `import { ${totalExported.join(', ')} } from './mdx';` : '',
|
184
182
|
imported: totalExported.join(',')
|
185
183
|
});
|
@@ -199,16 +197,16 @@ async function generateFiles(appDirectory, tmpDir, files, isDev) {
|
|
199
197
|
const meta = await Promise.all(files.map(file => handleFile(appDirectory, tmpDir, file, images)));
|
200
198
|
const sorted = (0, _sortPaths.default)(meta, e => e.moduleName.endsWith('index') ? e.moduleName.replace(/index$/, '') : `${e.moduleName}/`, '/');
|
201
199
|
const routesTemplate = await loadTemplate('DocsRoutes.jsx.tpl');
|
202
|
-
await _utils.fs.outputFile(
|
200
|
+
await _utils.fs.outputFile(_utils.path.resolve(tmpDir, 'DocsRoutes.jsx'), routesTemplate({
|
203
201
|
meta: sorted
|
204
202
|
}));
|
205
|
-
const pkgInfo = await _utils.fs.readJson(
|
203
|
+
const pkgInfo = await _utils.fs.readJson(_utils.path.resolve(appDirectory, 'package.json'));
|
206
204
|
const entryTemplate = await loadTemplate('docs-entry.jsx.tpl');
|
207
|
-
await _utils.fs.outputFile(
|
205
|
+
await _utils.fs.outputFile(_utils.path.resolve(tmpDir, 'docs-entry.jsx'), entryTemplate({
|
208
206
|
basename: isDev ? '/' : `${_constant.DOCS_RENDER_PATH}/${pkgInfo.name}/${pkgInfo.version}`
|
209
207
|
}));
|
210
|
-
await Promise.all(['DocsNav.jsx.tpl', 'DocsToc.jsx.tpl', 'docs.css'].map(async file => _utils.fs.copyFile(
|
211
|
-
await _utils.fs.outputJson(
|
208
|
+
await Promise.all(['DocsNav.jsx.tpl', 'DocsToc.jsx.tpl', 'docs.css'].map(async file => _utils.fs.copyFile(_utils.path.resolve(_constant.UTILS_STATIC, file), _utils.path.resolve(tmpDir, file.replace('.tpl', '')))));
|
209
|
+
await _utils.fs.outputJson(_utils.path.resolve(tmpDir, 'meta.json'), sorted.map(({
|
212
210
|
title,
|
213
211
|
moduleName
|
214
212
|
}) => ({
|
@@ -217,7 +215,7 @@ async function generateFiles(appDirectory, tmpDir, files, isDev) {
|
|
217
215
|
})), {
|
218
216
|
spaces: 2
|
219
217
|
});
|
220
|
-
await _utils.fs.ensureDir(
|
221
|
-
await Promise.all(Array.from(new Set(images)).map(file => _utils.fs.copyFile(
|
218
|
+
await _utils.fs.ensureDir(_utils.path.resolve(appDirectory, 'dist/docs/assets'));
|
219
|
+
await Promise.all(Array.from(new Set(images)).map(file => _utils.fs.copyFile(_utils.path.resolve(appDirectory, 'assets', file), _utils.path.resolve(appDirectory, 'dist/docs/assets', file))));
|
222
220
|
return sorted;
|
223
221
|
}
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.generatorWebpackConfig = generatorWebpackConfig;
|
7
7
|
exports.runWebpack = runWebpack;
|
8
8
|
|
9
|
-
var _path = _interopRequireDefault(require("path"));
|
10
|
-
|
11
9
|
var _utils = require("@modern-js/utils");
|
12
10
|
|
13
11
|
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
@@ -27,40 +25,40 @@ function generatorWebpackConfig(appDirectory, tmpDir, isDev) {
|
|
27
25
|
mode: isDev ? 'development' : 'production',
|
28
26
|
context: tmpDir,
|
29
27
|
entry: {
|
30
|
-
index:
|
28
|
+
index: _utils.path.resolve(tmpDir, 'docs-entry.jsx')
|
31
29
|
},
|
32
30
|
output: {
|
33
|
-
path:
|
31
|
+
path: _utils.path.resolve(appDirectory, 'dist/docs')
|
34
32
|
},
|
35
33
|
resolve: originConfig.resolve || {
|
36
34
|
alias: {}
|
37
35
|
},
|
38
36
|
module: originConfig.module,
|
39
37
|
plugins: [...plugins, new _htmlWebpackPlugin.default({
|
40
|
-
templateContent: _utils.fs.readFileSync(
|
38
|
+
templateContent: _utils.fs.readFileSync(_utils.path.resolve(_constant.UTILS_STATIC, 'index.html.ejs'), 'utf8')
|
41
39
|
})]
|
42
40
|
};
|
43
|
-
config.resolve.modules = [...(config.resolve.modules || []),
|
44
|
-
config.resolve.alias['@assets'] =
|
45
|
-
config.resolve.alias['@styles'] =
|
41
|
+
config.resolve.modules = [...(config.resolve.modules || []), _utils.path.join(__dirname, '../../../../../', 'node_modules')];
|
42
|
+
config.resolve.alias['@assets'] = _utils.path.resolve(appDirectory, 'assets');
|
43
|
+
config.resolve.alias['@styles'] = _utils.path.resolve(appDirectory, 'styles'); // fix this since react-live relies on core-js@2
|
46
44
|
|
47
|
-
config.resolve.alias[`${
|
48
|
-
const pkgJSON = JSON.parse(_utils.fs.readFileSync(
|
45
|
+
config.resolve.alias[`${_utils.path.dirname(require.resolve('core-js'))}/fn`] = 'core-js/es';
|
46
|
+
const pkgJSON = JSON.parse(_utils.fs.readFileSync(_utils.path.join(appDirectory, 'package.json'), 'utf-8'));
|
49
47
|
|
50
48
|
if (pkgJSON.dependencies.react || pkgJSON.devDependencies.react) {
|
51
|
-
config.resolve.alias.react =
|
49
|
+
config.resolve.alias.react = _utils.path.resolve('node_modules/react');
|
52
50
|
} else {
|
53
|
-
config.resolve.alias.react =
|
51
|
+
config.resolve.alias.react = _utils.path.resolve(__dirname, '../../../../../', 'node_modules', 'react');
|
54
52
|
}
|
55
53
|
|
56
54
|
if (pkgJSON.dependencies['react-dom'] || pkgJSON.devDependencies['react-dom']) {
|
57
|
-
config.resolve.alias['react-dom'] =
|
55
|
+
config.resolve.alias['react-dom'] = _utils.path.resolve('node_modules/react-dom');
|
58
56
|
} else {
|
59
|
-
config.resolve.alias['react-dom'] =
|
57
|
+
config.resolve.alias['react-dom'] = _utils.path.resolve(__dirname, '../../../../../', 'node_modules', 'react-dom');
|
60
58
|
}
|
61
59
|
|
62
60
|
config.resolve.fallback = {
|
63
|
-
path: require.resolve('path-browserify')
|
61
|
+
path: _utils.upath.normalizeSafe(require.resolve('path-browserify'))
|
64
62
|
};
|
65
63
|
return config;
|
66
64
|
}
|
package/dist/js/node/index.js
CHANGED
package/package.json
CHANGED
@@ -1,88 +1,88 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
}
|
2
|
+
"name": "@modern-js/plugin-docsite",
|
3
|
+
"version": "1.0.0-rc.17",
|
4
|
+
"jsnext:source": "./src/index.ts",
|
5
|
+
"types": "./dist/types/index.d.ts",
|
6
|
+
"main": "./dist/js/node/index.js",
|
7
|
+
"module": "./dist/js/treeshaking/index.js",
|
8
|
+
"jsnext:modern": "./dist/js/modern/index.js",
|
9
|
+
"exports": {
|
10
|
+
".": {
|
11
|
+
"node": {
|
12
|
+
"import": "./dist/js/modern/index.js",
|
13
|
+
"require": "./dist/js/node/index.js"
|
14
|
+
},
|
15
|
+
"default": "./dist/js/treeshaking/index.js"
|
16
|
+
},
|
17
|
+
"./cli": "./dist/js/node/index.js"
|
18
|
+
},
|
19
|
+
"dependencies": {
|
20
|
+
"@babel/parser": "^7.15.2",
|
21
|
+
"@babel/runtime": "^7",
|
22
|
+
"@mdx-js/mdx": "^1.6.22",
|
23
|
+
"@mdx-js/react": "^1.6.22",
|
24
|
+
"@modern-js/utils": "^1.0.0-rc.17",
|
25
|
+
"@modern-js/webpack": "^1.0.0-rc.17",
|
26
|
+
"antd": "^4.16.13",
|
27
|
+
"chokidar": "^3.5.2",
|
28
|
+
"core-js": "^3.17.2",
|
29
|
+
"github-slugger": "^1.4.0",
|
30
|
+
"glob": "^7.1.6",
|
31
|
+
"gray-matter": "^4.0.3",
|
32
|
+
"html-webpack-plugin": "^5.3.2",
|
33
|
+
"lodash": "^4.17.21",
|
34
|
+
"mdast-util-to-string": "^2.0.0",
|
35
|
+
"path-browserify": "^1.0.1",
|
36
|
+
"prism-react-renderer": "^1.2.1",
|
37
|
+
"react": "^17",
|
38
|
+
"react-dom": "^17",
|
39
|
+
"react-live": "^2.3.0",
|
40
|
+
"react-router-dom": "^5.3.0",
|
41
|
+
"sort-paths": "^1.1.1",
|
42
|
+
"styled-components": "^5.3.1",
|
43
|
+
"unist-builder": "^2.0.3",
|
44
|
+
"unist-util-visit": "^2.0.3",
|
45
|
+
"webpack": "^5.54.0",
|
46
|
+
"webpack-dev-server": "^4.1.1"
|
47
|
+
},
|
48
|
+
"devDependencies": {
|
49
|
+
"@modern-js/module-tools-hooks": "^1.0.0-rc.17",
|
50
|
+
"@types/core-js": "^2.5.5",
|
51
|
+
"@types/github-slugger": "^1.3.0",
|
52
|
+
"@types/glob": "^7.1.4",
|
53
|
+
"@types/jest": "^26",
|
54
|
+
"@types/lodash": "^4.14.168",
|
55
|
+
"@types/node": "^14",
|
56
|
+
"@types/react": "^17",
|
57
|
+
"@types/react-dom": "^17",
|
58
|
+
"@types/webpack-dev-server": "^4.1.0",
|
59
|
+
"typescript": "^4",
|
60
|
+
"@modern-js/core": "^1.0.0-rc.17",
|
61
|
+
"@modern-js/plugin-testing": "^1.0.0-rc.17",
|
62
|
+
"@modern-js/module-tools": "^1.0.0-rc.17"
|
63
|
+
},
|
64
|
+
"peerDependencies": {
|
65
|
+
"@modern-js/core": "^1.0.0-rc.17"
|
66
|
+
},
|
67
|
+
"sideEffects": false,
|
68
|
+
"modernConfig": {
|
69
|
+
"output": {
|
70
|
+
"packageMode": "node-js",
|
71
|
+
"copy": [
|
72
|
+
{
|
73
|
+
"from": "static",
|
74
|
+
"to": ""
|
75
|
+
}
|
76
|
+
]
|
77
|
+
}
|
78
|
+
},
|
79
|
+
"publishConfig": {
|
80
|
+
"registry": "https://registry.npmjs.org/",
|
81
|
+
"access": "public"
|
82
|
+
},
|
83
|
+
"scripts": {
|
84
|
+
"new": "modern new",
|
85
|
+
"build": "modern build",
|
86
|
+
"test": "modern test --passWithNoTests"
|
87
|
+
}
|
88
|
+
}
|
package/src/features/constant.ts
CHANGED
package/src/features/dev.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import path from '
|
1
|
+
import { path, logger } from '@modern-js/utils';
|
2
2
|
import webpack, { Configuration } from 'webpack';
|
3
3
|
import WebpackDevServer from 'webpack-dev-server';
|
4
|
-
import { logger } from '@modern-js/utils';
|
5
4
|
import { chokidarFile } from './utils/chokidar';
|
6
5
|
import { generateFiles } from './utils/generate-files';
|
7
6
|
|
package/src/features/index.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import path from '
|
1
|
+
import { path, logger } from '@modern-js/utils';
|
2
2
|
import chokidar from 'chokidar';
|
3
3
|
import glob from 'glob';
|
4
|
-
import { logger } from '@modern-js/utils';
|
5
4
|
import { generateFiles } from './generate-files';
|
6
5
|
|
7
6
|
export function chokidarFile(
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import path from '
|
1
|
+
import { path, logger, fs } from '@modern-js/utils';
|
2
2
|
import matter from 'gray-matter';
|
3
3
|
import { startCase, camelCase, union, template, difference } from 'lodash';
|
4
4
|
import GithubSlugger from 'github-slugger';
|
@@ -8,7 +8,6 @@ import toString from 'mdast-util-to-string';
|
|
8
8
|
import u from 'unist-builder';
|
9
9
|
import mdx from '@mdx-js/mdx';
|
10
10
|
import babelParser, { ParserOptions } from '@babel/parser';
|
11
|
-
import { logger, fs } from '@modern-js/utils';
|
12
11
|
import {
|
13
12
|
DOCS_RENDER_PATH,
|
14
13
|
MDX_DEFAULT_RENDERER,
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import path from '
|
2
|
-
import { fs } from '@modern-js/utils';
|
1
|
+
import { path, fs, upath } from '@modern-js/utils';
|
3
2
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
4
3
|
import webpack, { Configuration, WebpackPluginInstance } from 'webpack';
|
5
4
|
import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack';
|
@@ -83,7 +82,7 @@ export function generatorWebpackConfig(
|
|
83
82
|
);
|
84
83
|
}
|
85
84
|
|
86
|
-
config.resolve!.fallback = { path: require.resolve('path-browserify') };
|
85
|
+
config.resolve!.fallback = { path: upath.normalizeSafe(require.resolve('path-browserify')) };
|
87
86
|
return config;
|
88
87
|
}
|
89
88
|
|
package/src/index.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Import } from '@modern-js/utils';
|
1
|
+
import { Import, upath } from '@modern-js/utils';
|
2
2
|
|
3
3
|
const core: typeof import('@modern-js/core') = Import.lazy(
|
4
4
|
'@modern-js/core',
|
@@ -33,7 +33,7 @@ export default core.createPlugin(
|
|
33
33
|
return {
|
34
34
|
name: 'docsite',
|
35
35
|
title: 'Run Docsite log',
|
36
|
-
taskPath: require.resolve('./build-task'),
|
36
|
+
taskPath: upath.normalizeSafe(require.resolve('./build-task')),
|
37
37
|
params: [],
|
38
38
|
};
|
39
39
|
},
|