@modern-js/utils 1.3.7 → 1.5.0
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/.eslintrc.js +9 -0
- package/CHANGELOG.md +31 -0
- package/compiled/browserslist/index.d.ts +178 -0
- package/compiled/browserslist/index.js +1 -0
- package/compiled/browserslist/license +20 -0
- package/compiled/browserslist/package.json +1 -0
- package/compiled/chalk/index.d.ts +415 -0
- package/compiled/chalk/index.js +1 -0
- package/compiled/chalk/license +9 -0
- package/compiled/chalk/package.json +1 -0
- package/compiled/chokidar/anymatch/index.d.ts +19 -0
- package/compiled/chokidar/fsevents.node +0 -0
- package/compiled/chokidar/index.js +40 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/compiled/chokidar/types/index.d.ts +188 -0
- package/compiled/commander/index.js +1 -0
- package/compiled/commander/license +22 -0
- package/compiled/commander/package.json +1 -0
- package/compiled/commander/typings/index.d.ts +774 -0
- package/compiled/debug/index.d.ts +54 -0
- package/compiled/debug/index.js +1 -0
- package/compiled/debug/license +20 -0
- package/compiled/debug/ms/index.d.ts +25 -0
- package/compiled/debug/package.json +1 -0
- package/compiled/execa/index.d.ts +564 -0
- package/compiled/execa/index.js +1 -0
- package/compiled/execa/license +9 -0
- package/compiled/execa/package.json +1 -0
- package/compiled/filesize/filesize.d.ts +131 -0
- package/compiled/filesize/index.js +9 -0
- package/compiled/filesize/license +28 -0
- package/compiled/filesize/package.json +1 -0
- package/compiled/fs-extra/index.d.ts +563 -0
- package/compiled/fs-extra/index.js +1 -0
- package/compiled/fs-extra/license +15 -0
- package/compiled/fs-extra/package.json +1 -0
- package/compiled/glob/index.d.ts +91 -0
- package/compiled/glob/index.js +1 -0
- package/compiled/glob/license +21 -0
- package/compiled/glob/minimatch/index.d.ts +204 -0
- package/compiled/glob/package.json +1 -0
- package/compiled/gzip-size/index.d.ts +96 -0
- package/compiled/gzip-size/index.js +1 -0
- package/compiled/gzip-size/license +9 -0
- package/compiled/gzip-size/package.json +1 -0
- package/compiled/import-lazy/index.d.ts +26 -0
- package/compiled/import-lazy/index.js +1 -0
- package/compiled/import-lazy/license +9 -0
- package/compiled/import-lazy/package.json +1 -0
- package/compiled/js-yaml/index.d.ts +154 -0
- package/compiled/js-yaml/index.js +1 -0
- package/compiled/js-yaml/license +21 -0
- package/compiled/js-yaml/package.json +1 -0
- package/compiled/lodash/common/array.d.ts +2126 -0
- package/compiled/lodash/common/collection.d.ts +1930 -0
- package/compiled/lodash/common/common.d.ts +280 -0
- package/compiled/lodash/common/date.d.ts +23 -0
- package/compiled/lodash/common/function.d.ts +1446 -0
- package/compiled/lodash/common/lang.d.ts +1693 -0
- package/compiled/lodash/common/math.d.ts +405 -0
- package/compiled/lodash/common/number.d.ts +131 -0
- package/compiled/lodash/common/object.d.ts +2519 -0
- package/compiled/lodash/common/seq.d.ts +210 -0
- package/compiled/lodash/common/string.d.ts +788 -0
- package/compiled/lodash/common/util.d.ts +1220 -0
- package/compiled/lodash/index.d.ts +46 -0
- package/compiled/lodash/index.js +9 -0
- package/compiled/lodash/license +47 -0
- package/compiled/lodash/package.json +1 -0
- package/compiled/pkg-up/index.d.ts +48 -0
- package/compiled/pkg-up/index.js +1 -0
- package/compiled/pkg-up/license +9 -0
- package/compiled/pkg-up/package.json +1 -0
- package/compiled/recursive-readdir/index.d.ts +21 -0
- package/compiled/recursive-readdir/index.js +1 -0
- package/compiled/recursive-readdir/license +21 -0
- package/compiled/recursive-readdir/package.json +1 -0
- package/compiled/signale/index.d.ts +162 -0
- package/compiled/signale/index.js +1 -0
- package/compiled/signale/package.json +1 -0
- package/compiled/strip-ansi/index.d.ts +17 -0
- package/compiled/strip-ansi/index.js +1 -0
- package/compiled/strip-ansi/license +9 -0
- package/compiled/strip-ansi/package.json +1 -0
- package/compiled/upath/index.js +1 -0
- package/compiled/upath/license +22 -0
- package/compiled/upath/package.json +1 -0
- package/compiled/upath/upath.d.ts +241 -0
- package/dist/{types/FileSizeReporter.d.ts → FileSizeReporter.d.ts} +5 -5
- package/dist/FileSizeReporter.js +151 -0
- package/dist/{types/alias.d.ts → alias.d.ts} +12 -14
- package/dist/alias.js +62 -0
- package/dist/analyzeProject.d.ts +1 -0
- package/dist/analyzeProject.js +44 -0
- package/dist/applyOptionsChain.d.ts +6 -0
- package/dist/applyOptionsChain.js +30 -0
- package/dist/clearConsole.d.ts +1 -0
- package/dist/clearConsole.js +9 -0
- package/dist/{types/compatRequire.d.ts → compatRequire.d.ts} +1 -1
- package/dist/compatRequire.js +28 -0
- package/dist/compiled.d.ts +21 -0
- package/dist/compiled.js +33 -0
- package/dist/constants.d.ts +222 -0
- package/dist/constants.js +277 -0
- package/dist/{js/modern/debug.js → debug.d.ts} +1 -3
- package/dist/debug.js +11 -0
- package/dist/emptyDir.d.ts +1 -0
- package/dist/emptyDir.js +19 -0
- package/dist/{types/ensureAbsolutePath.d.ts → ensureAbsolutePath.d.ts} +1 -1
- package/dist/ensureAbsolutePath.js +15 -0
- package/dist/{types/findExists.d.ts → findExists.d.ts} +1 -1
- package/dist/findExists.js +21 -0
- package/dist/{types/format.d.ts → format.d.ts} +3 -3
- package/dist/format.js +113 -0
- package/dist/{types/generateMetaTags.d.ts → generateMetaTags.d.ts} +3 -3
- package/dist/generateMetaTags.js +48 -0
- package/dist/{types/getBrowserslist.d.ts → getBrowserslist.d.ts} +1 -1
- package/dist/getBrowserslist.js +7 -0
- package/dist/{types/getCacheIdentifier.d.ts → getCacheIdentifier.d.ts} +3 -3
- package/dist/getCacheIdentifier.js +24 -0
- package/dist/{types/getEntryOptions.d.ts → getEntryOptions.d.ts} +1 -1
- package/dist/getEntryOptions.js +26 -0
- package/dist/{types/getPackageManager.d.ts → getPackageManager.d.ts} +1 -1
- package/dist/getPackageManager.js +47 -0
- package/dist/{types/getPort.d.ts → getPort.d.ts} +1 -1
- package/dist/getPort.js +62 -0
- package/dist/getServerConfig.d.ts +1 -0
- package/dist/getServerConfig.js +39 -0
- package/dist/{types/import.d.ts → import.d.ts} +2 -2
- package/dist/import.js +10 -0
- package/dist/{types/index.d.ts → index.d.ts} +5 -4
- package/dist/index.js +46 -0
- package/dist/{types/is → is}/index.d.ts +1 -4
- package/dist/is/index.js +82 -0
- package/dist/{types/is → is}/node-env.d.ts +1 -1
- package/dist/is/node-env.js +12 -0
- package/dist/is/platform.d.ts +2 -0
- package/dist/is/platform.js +10 -0
- package/dist/{types/is → is}/type.d.ts +1 -1
- package/dist/is/type.js +38 -0
- package/dist/logger.d.ts +63 -0
- package/dist/logger.js +128 -0
- package/dist/{types/monorepo.d.ts → monorepo.d.ts} +3 -3
- package/dist/monorepo.js +80 -0
- package/dist/{types/nodeEnv.d.ts → nodeEnv.d.ts} +1 -1
- package/dist/nodeEnv.js +49 -0
- package/dist/{types/path.d.ts → path.d.ts} +1 -1
- package/dist/path.js +14 -0
- package/dist/{types/prettyInstructions.d.ts → prettyInstructions.d.ts} +2 -2
- package/dist/prettyInstructions.js +64 -0
- package/dist/{types/printBuildError.d.ts → printBuildError.d.ts} +1 -1
- package/dist/printBuildError.js +43 -0
- package/dist/{types/readTsConfig.d.ts → readTsConfig.d.ts} +1 -1
- package/dist/readTsConfig.js +19 -0
- package/dist/{types/removeSlash.d.ts → removeSlash.d.ts} +1 -1
- package/dist/removeSlash.js +9 -0
- package/dist/{types/runtimeExports.d.ts → runtimeExports.d.ts} +3 -3
- package/dist/runtimeExports.js +53 -0
- package/dist/ssrHelpers.d.ts +4 -0
- package/dist/ssrHelpers.js +7 -0
- package/dist/storage.d.ts +5 -0
- package/dist/storage.js +61 -0
- package/dist/{types/wait.d.ts → wait.d.ts} +1 -1
- package/dist/wait.js +7 -0
- package/dist/{types/watch.d.ts → watch.d.ts} +4 -4
- package/dist/watch.js +64 -0
- package/package.json +55 -37
- package/tsconfig.json +3 -5
- package/dist/js/modern/FileSizeReporter.js +0 -156
- package/dist/js/modern/alias.js +0 -74
- package/dist/js/modern/applyOptionsChain.js +0 -27
- package/dist/js/modern/chalk.js +0 -2
- package/dist/js/modern/clearConsole.js +0 -5
- package/dist/js/modern/compatRequire.js +0 -26
- package/dist/js/modern/constants.js +0 -333
- package/dist/js/modern/emptyDir.js +0 -6
- package/dist/js/modern/ensureAbsolutePath.js +0 -9
- package/dist/js/modern/findExists.js +0 -16
- package/dist/js/modern/format.js +0 -137
- package/dist/js/modern/generateMetaTags.js +0 -49
- package/dist/js/modern/getBrowserslist.js +0 -5
- package/dist/js/modern/getCacheIdentifier.js +0 -20
- package/dist/js/modern/getEntryOptions.js +0 -24
- package/dist/js/modern/getPackageManager.js +0 -37
- package/dist/js/modern/getPort.js +0 -52
- package/dist/js/modern/import.js +0 -11
- package/dist/js/modern/index.js +0 -34
- package/dist/js/modern/is/index.js +0 -77
- package/dist/js/modern/is/node-env.js +0 -5
- package/dist/js/modern/is/platform.js +0 -2
- package/dist/js/modern/is/type.js +0 -25
- package/dist/js/modern/logger.js +0 -152
- package/dist/js/modern/monorepo.js +0 -84
- package/dist/js/modern/nodeEnv.js +0 -31
- package/dist/js/modern/path.js +0 -5
- package/dist/js/modern/pkgUp.js +0 -2
- package/dist/js/modern/prettyInstructions.js +0 -79
- package/dist/js/modern/printBuildError.js +0 -40
- package/dist/js/modern/readTsConfig.js +0 -13
- package/dist/js/modern/removeSlash.js +0 -3
- package/dist/js/modern/runtimeExports.js +0 -52
- package/dist/js/modern/wait.js +0 -5
- package/dist/js/modern/watch.js +0 -43
- package/dist/js/node/FileSizeReporter.js +0 -175
- package/dist/js/node/alias.js +0 -97
- package/dist/js/node/applyOptionsChain.js +0 -37
- package/dist/js/node/chalk.js +0 -15
- package/dist/js/node/clearConsole.js +0 -14
- package/dist/js/node/compatRequire.js +0 -41
- package/dist/js/node/constants.js +0 -353
- package/dist/js/node/debug.js +0 -19
- package/dist/js/node/emptyDir.js +0 -18
- package/dist/js/node/ensureAbsolutePath.js +0 -20
- package/dist/js/node/findExists.js +0 -27
- package/dist/js/node/format.js +0 -141
- package/dist/js/node/generateMetaTags.js +0 -58
- package/dist/js/node/getBrowserslist.js +0 -17
- package/dist/js/node/getCacheIdentifier.js +0 -27
- package/dist/js/node/getEntryOptions.js +0 -35
- package/dist/js/node/getPackageManager.js +0 -51
- package/dist/js/node/getPort.js +0 -67
- package/dist/js/node/import.js +0 -19
- package/dist/js/node/index.js +0 -465
- package/dist/js/node/is/index.js +0 -150
- package/dist/js/node/is/node-env.js +0 -23
- package/dist/js/node/is/platform.js +0 -14
- package/dist/js/node/is/type.js +0 -46
- package/dist/js/node/logger.js +0 -162
- package/dist/js/node/monorepo.js +0 -118
- package/dist/js/node/nodeEnv.js +0 -45
- package/dist/js/node/path.js +0 -24
- package/dist/js/node/pkgUp.js +0 -15
- package/dist/js/node/prettyInstructions.js +0 -95
- package/dist/js/node/printBuildError.js +0 -52
- package/dist/js/node/readTsConfig.js +0 -28
- package/dist/js/node/removeSlash.js +0 -18
- package/dist/js/node/runtimeExports.js +0 -68
- package/dist/js/node/wait.js +0 -12
- package/dist/js/node/watch.js +0 -61
- package/dist/js/treeshaking/FileSizeReporter.js +0 -185
- package/dist/js/treeshaking/alias.js +0 -72
- package/dist/js/treeshaking/applyOptionsChain.js +0 -31
- package/dist/js/treeshaking/chalk.js +0 -2
- package/dist/js/treeshaking/clearConsole.js +0 -5
- package/dist/js/treeshaking/compatRequire.js +0 -29
- package/dist/js/treeshaking/constants.js +0 -333
- package/dist/js/treeshaking/debug.js +0 -10
- package/dist/js/treeshaking/emptyDir.js +0 -37
- package/dist/js/treeshaking/ensureAbsolutePath.js +0 -11
- package/dist/js/treeshaking/findExists.js +0 -33
- package/dist/js/treeshaking/format.js +0 -167
- package/dist/js/treeshaking/generateMetaTags.js +0 -55
- package/dist/js/treeshaking/getBrowserslist.js +0 -7
- package/dist/js/treeshaking/getCacheIdentifier.js +0 -35
- package/dist/js/treeshaking/getEntryOptions.js +0 -26
- package/dist/js/treeshaking/getPackageManager.js +0 -101
- package/dist/js/treeshaking/getPort.js +0 -103
- package/dist/js/treeshaking/import.js +0 -11
- package/dist/js/treeshaking/index.js +0 -34
- package/dist/js/treeshaking/is/index.js +0 -81
- package/dist/js/treeshaking/is/node-env.js +0 -13
- package/dist/js/treeshaking/is/platform.js +0 -6
- package/dist/js/treeshaking/is/type.js +0 -27
- package/dist/js/treeshaking/logger.js +0 -188
- package/dist/js/treeshaking/monorepo.js +0 -95
- package/dist/js/treeshaking/nodeEnv.js +0 -108
- package/dist/js/treeshaking/path.js +0 -11
- package/dist/js/treeshaking/pkgUp.js +0 -2
- package/dist/js/treeshaking/prettyInstructions.js +0 -100
- package/dist/js/treeshaking/printBuildError.js +0 -40
- package/dist/js/treeshaking/readTsConfig.js +0 -13
- package/dist/js/treeshaking/removeSlash.js +0 -9
- package/dist/js/treeshaking/runtimeExports.js +0 -61
- package/dist/js/treeshaking/wait.js +0 -8
- package/dist/js/treeshaking/watch.js +0 -112
- package/dist/types/applyOptionsChain.d.ts +0 -6
- package/dist/types/chalk.d.ts +0 -2
- package/dist/types/clearConsole.d.ts +0 -1
- package/dist/types/constants.d.ts +0 -219
- package/dist/types/debug.d.ts +0 -8
- package/dist/types/emptyDir.d.ts +0 -1
- package/dist/types/is/platform.d.ts +0 -2
- package/dist/types/logger.d.ts +0 -63
- package/dist/types/pkgUp.d.ts +0 -2
- package/tests/.eslintrc.js +0 -6
- package/tests/__snapshots__/prettyInstructions.test.ts.snap +0 -19
- package/tests/applyOptionsChain.test.ts +0 -100
- package/tests/compatRequire.test.ts +0 -32
- package/tests/debug.test.ts +0 -25
- package/tests/ensureAbsolutePath.test.ts +0 -16
- package/tests/findExists.test.ts +0 -22
- package/tests/fixtures/browserlist/develop/package.json +0 -11
- package/tests/fixtures/browserlist/dotfile/.browserslistrc +0 -3
- package/tests/fixtures/browserlist/pkg/package.json +0 -7
- package/tests/fixtures/compat-require/cjs.js +0 -1
- package/tests/fixtures/compat-require/empty.js +0 -1
- package/tests/fixtures/compat-require/esm.js +0 -5
- package/tests/fixtures/compat-require/foo.js +0 -3
- package/tests/fixtures/file-exists/a.ejs +0 -0
- package/tests/fixtures/file-exists/a.js/.gitkeep +0 -0
- package/tests/fixtures/file-exists/a.mjs +0 -0
- package/tests/fixtures/file-exists/a.ts +0 -0
- package/tests/format.test.ts +0 -60
- package/tests/generateMetaTags.test.ts +0 -19
- package/tests/getBrowserslist.test.ts +0 -32
- package/tests/getCacheIdentifier.test.ts +0 -37
- package/tests/getEntryOptions.test.ts +0 -53
- package/tests/index.test.ts +0 -18
- package/tests/is.test.ts +0 -27
- package/tests/isPlatform.test.ts +0 -19
- package/tests/isType.test.ts +0 -85
- package/tests/logger.test.ts +0 -53
- package/tests/prettyInstructions.test.ts +0 -139
- package/tests/removeSlash.test.ts +0 -19
- package/tests/tsconfig.json +0 -11
- package/tests/wait.ts +0 -38
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/* eslint-disable eslint-comments/no-unlimited-disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file at
|
|
8
|
+
* https://github.com/facebook/create-react-app/blob/master/LICENSE
|
|
9
|
+
*/
|
|
10
|
+
// Modified by Chao Xu (xuchaobei)
|
|
11
|
+
'use strict';
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.printFileSizesAfterBuild = exports.measureFileSizesBeforeBuild = void 0;
|
|
17
|
+
const fs_1 = __importDefault(require("fs"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const compiled_1 = require("./compiled");
|
|
20
|
+
const logger_1 = require("./logger");
|
|
21
|
+
function canReadAsset(asset) {
|
|
22
|
+
return (/\.(js|css)$/.test(asset) &&
|
|
23
|
+
!/service-worker\.js/.test(asset) &&
|
|
24
|
+
!/precache-manifest\.[0-9a-f]+\.js/.test(asset));
|
|
25
|
+
}
|
|
26
|
+
// Prints a detailed summary of build files.
|
|
27
|
+
function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, maxBundleGzipSize, maxChunkGzipSize) {
|
|
28
|
+
var root = previousSizeMap.root;
|
|
29
|
+
var sizes = previousSizeMap.sizes;
|
|
30
|
+
var assets = (webpackStats.stats || [webpackStats])
|
|
31
|
+
.map((stats) => stats
|
|
32
|
+
.toJson({ all: false, assets: true })
|
|
33
|
+
.assets.filter((asset) => canReadAsset(asset.name))
|
|
34
|
+
.map((asset) => {
|
|
35
|
+
var fileContents = fs_1.default.readFileSync(path_1.default.join(root, asset.name));
|
|
36
|
+
var size = fileContents.length;
|
|
37
|
+
var gzippedSize = compiled_1.gzipSize.sync(fileContents);
|
|
38
|
+
var [previousSize, previousGzipSize] = sizes[removeFileNameHash(root, asset.name)] || [];
|
|
39
|
+
var sizeDifference = getDifferenceLabel(size, previousSize);
|
|
40
|
+
var gzipSizeDifference = getDifferenceLabel(gzippedSize, previousGzipSize);
|
|
41
|
+
return {
|
|
42
|
+
folder: path_1.default.join(path_1.default.basename(buildFolder), path_1.default.dirname(asset.name)),
|
|
43
|
+
name: path_1.default.basename(asset.name),
|
|
44
|
+
gzippedSize: gzippedSize,
|
|
45
|
+
sizeLabel: (0, compiled_1.filesize)(size) +
|
|
46
|
+
(sizeDifference ? ' (' + sizeDifference + ')' : ''),
|
|
47
|
+
gzipSizeLabel: (0, compiled_1.filesize)(gzippedSize) +
|
|
48
|
+
(gzipSizeDifference ? ' (' + gzipSizeDifference + ')' : ''),
|
|
49
|
+
};
|
|
50
|
+
}))
|
|
51
|
+
.reduce((single, all) => all.concat(single), []);
|
|
52
|
+
assets.sort((a, b) => b.size - a.size);
|
|
53
|
+
var longestSizeLabelLength = Math.max.apply(null, assets.map((a) => (0, compiled_1.stripAnsi)(a.sizeLabel).length));
|
|
54
|
+
var longestFileNameLength = Math.max.apply(null, assets.map((a) => (0, compiled_1.stripAnsi)(a.folder + path_1.default.sep + a.name).length));
|
|
55
|
+
printFileSizesHeader(longestFileNameLength, longestSizeLabelLength);
|
|
56
|
+
var suggestBundleSplitting = false;
|
|
57
|
+
assets.forEach((asset) => {
|
|
58
|
+
var { folder, name, sizeLabel, gzipSizeLabel, gzippedSize } = asset;
|
|
59
|
+
var fileNameLength = (0, compiled_1.stripAnsi)(folder + path_1.default.sep + name).length;
|
|
60
|
+
var sizeLength = (0, compiled_1.stripAnsi)(sizeLabel).length;
|
|
61
|
+
if (sizeLength < longestSizeLabelLength) {
|
|
62
|
+
var rightPadding = ' '.repeat(longestSizeLabelLength - sizeLength);
|
|
63
|
+
sizeLabel += rightPadding;
|
|
64
|
+
}
|
|
65
|
+
var fileNameLabel = compiled_1.chalk.dim(asset.folder + path_1.default.sep) + compiled_1.chalk.cyan(asset.name);
|
|
66
|
+
if (fileNameLength < longestFileNameLength) {
|
|
67
|
+
var rightPadding = ' '.repeat(longestFileNameLength - fileNameLength);
|
|
68
|
+
fileNameLabel += rightPadding;
|
|
69
|
+
}
|
|
70
|
+
var isMainBundle = asset.name.indexOf('main.') === 0;
|
|
71
|
+
var maxRecommendedSize = isMainBundle
|
|
72
|
+
? maxBundleGzipSize
|
|
73
|
+
: maxChunkGzipSize;
|
|
74
|
+
var isLarge = maxRecommendedSize && gzippedSize > maxRecommendedSize;
|
|
75
|
+
if (isLarge && path_1.default.extname(asset.name) === '.js') {
|
|
76
|
+
suggestBundleSplitting = true;
|
|
77
|
+
}
|
|
78
|
+
logger_1.logger.log(' ' +
|
|
79
|
+
fileNameLabel +
|
|
80
|
+
' ' +
|
|
81
|
+
sizeLabel +
|
|
82
|
+
' ' +
|
|
83
|
+
(isLarge ? compiled_1.chalk.yellow(gzipSizeLabel) : gzipSizeLabel));
|
|
84
|
+
});
|
|
85
|
+
if (suggestBundleSplitting) {
|
|
86
|
+
logger_1.logger.log();
|
|
87
|
+
logger_1.logger.warn('The bundle size is significantly larger than recommended.');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.printFileSizesAfterBuild = printFileSizesAfterBuild;
|
|
91
|
+
function printFileSizesHeader(longestFileNameLength, longestSizeLabelLength) {
|
|
92
|
+
const longestLengths = [longestFileNameLength, longestSizeLabelLength];
|
|
93
|
+
const headerRow = ['File', 'Size', 'Gzipped'].reduce((prev, cur, index) => {
|
|
94
|
+
const length = longestLengths[index];
|
|
95
|
+
let curLabel = cur;
|
|
96
|
+
if (length) {
|
|
97
|
+
curLabel =
|
|
98
|
+
cur.length < length ? cur + ' '.repeat(length - cur.length) : cur;
|
|
99
|
+
}
|
|
100
|
+
return prev + curLabel + ' ';
|
|
101
|
+
}, ' ');
|
|
102
|
+
logger_1.logger.log(compiled_1.chalk.bold(compiled_1.chalk.blue(headerRow)));
|
|
103
|
+
}
|
|
104
|
+
function removeFileNameHash(buildFolder, fileName) {
|
|
105
|
+
return fileName
|
|
106
|
+
.replace(buildFolder, '')
|
|
107
|
+
.replace(/\\/g, '/')
|
|
108
|
+
.replace(/\/?(.*)(\.[0-9a-f]+)(\.chunk)?(\.js|\.css)/, (match, p1, p2, p3, p4) => p1 + p4);
|
|
109
|
+
}
|
|
110
|
+
// Input: 1024, 2048
|
|
111
|
+
// Output: "(+1 KB)"
|
|
112
|
+
function getDifferenceLabel(currentSize, previousSize) {
|
|
113
|
+
var FIFTY_KILOBYTES = 1024 * 50;
|
|
114
|
+
var difference = currentSize - previousSize;
|
|
115
|
+
var fileSize = !Number.isNaN(difference) ? (0, compiled_1.filesize)(difference) : 0;
|
|
116
|
+
if (difference >= FIFTY_KILOBYTES) {
|
|
117
|
+
return compiled_1.chalk.red('+' + fileSize);
|
|
118
|
+
}
|
|
119
|
+
else if (difference < FIFTY_KILOBYTES && difference > 0) {
|
|
120
|
+
return compiled_1.chalk.yellow('+' + fileSize);
|
|
121
|
+
}
|
|
122
|
+
else if (difference < 0) {
|
|
123
|
+
return compiled_1.chalk.green(fileSize);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
return '';
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function measureFileSizesBeforeBuild(buildFolder) {
|
|
130
|
+
return new Promise(resolve => {
|
|
131
|
+
(0, compiled_1.recursiveReaddir)(buildFolder, (err, fileNames) => {
|
|
132
|
+
var sizes;
|
|
133
|
+
if (!err && fileNames) {
|
|
134
|
+
sizes = fileNames
|
|
135
|
+
.filter(canReadAsset)
|
|
136
|
+
.reduce((memo, fileName) => {
|
|
137
|
+
var contents = fs_1.default.readFileSync(fileName);
|
|
138
|
+
var key = removeFileNameHash(buildFolder, fileName);
|
|
139
|
+
// save both the original size and gzip size
|
|
140
|
+
memo[key] = [contents.length, compiled_1.gzipSize.sync(contents)];
|
|
141
|
+
return memo;
|
|
142
|
+
}, {});
|
|
143
|
+
}
|
|
144
|
+
resolve({
|
|
145
|
+
root: buildFolder,
|
|
146
|
+
sizes: sizes || {},
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
exports.measureFileSizesBeforeBuild = measureFileSizesBeforeBuild;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
declare type AliasOption = Record<string, string> | ((aliases: Record<string, string>) => Record<string, unknown>) | Record<string, string> | undefined;
|
|
2
2
|
interface NormalizedConfig {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
source: {
|
|
4
|
+
alias?: AliasOption | Array<AliasOption>;
|
|
5
|
+
};
|
|
6
6
|
}
|
|
7
7
|
interface IAliasConfig {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
absoluteBaseUrl: string;
|
|
9
|
+
paths?: Record<string, string | string[]>;
|
|
10
|
+
isTsPath?: boolean;
|
|
11
|
+
isTsProject?: boolean;
|
|
12
12
|
}
|
|
13
|
-
export declare const validAlias: <T extends NormalizedConfig>(modernConfig: T, {
|
|
14
|
-
|
|
15
|
-
}: {
|
|
16
|
-
tsconfigPath: string;
|
|
13
|
+
export declare const validAlias: <T extends NormalizedConfig>(modernConfig: T, { tsconfigPath }: {
|
|
14
|
+
tsconfigPath: string;
|
|
17
15
|
}) => string | null;
|
|
18
16
|
export declare const getAlias: (aliasOption: AliasOption | Array<AliasOption>, option: {
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
appDirectory: string;
|
|
18
|
+
tsconfigPath: string;
|
|
21
19
|
}) => IAliasConfig;
|
|
22
20
|
export declare const getUserAlias: (alias?: Record<string, string | string[]>) => Record<string, string | string[]>;
|
|
23
|
-
export {};
|
|
21
|
+
export {};
|
package/dist/alias.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getUserAlias = exports.getAlias = exports.validAlias = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const compiled_1 = require("./compiled");
|
|
10
|
+
const readTsConfig_1 = require("./readTsConfig");
|
|
11
|
+
const applyOptionsChain_1 = require("./applyOptionsChain");
|
|
12
|
+
const validAlias = (modernConfig, { tsconfigPath }) => {
|
|
13
|
+
const { source: { alias }, } = modernConfig;
|
|
14
|
+
if (!alias) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const isTsProject = fs_1.default.existsSync(tsconfigPath);
|
|
18
|
+
if (!isTsProject) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const userAlias = (0, exports.getUserAlias)(alias);
|
|
22
|
+
if (Object.keys(userAlias).length > 0) {
|
|
23
|
+
return compiled_1.chalk.red('Note: Please use `compilerOptions.paths` in "tsconfig.json" file replace `source.alias` config in "modern.config.js/ts" when project is typescript');
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
exports.validAlias = validAlias;
|
|
28
|
+
const getAlias = (aliasOption, option) => {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
const isTsProject = fs_1.default.existsSync(option.tsconfigPath);
|
|
31
|
+
let aliasConfig;
|
|
32
|
+
if (!isTsProject) {
|
|
33
|
+
aliasConfig = {
|
|
34
|
+
absoluteBaseUrl: option.appDirectory,
|
|
35
|
+
paths: (0, applyOptionsChain_1.applyOptionsChain)({ '@': ['./src'] }, aliasOption),
|
|
36
|
+
isTsPath: false,
|
|
37
|
+
isTsProject,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const tsconfig = (0, readTsConfig_1.readTsConfigByFile)(option.tsconfigPath);
|
|
42
|
+
const baseUrl = (_a = tsconfig === null || tsconfig === void 0 ? void 0 : tsconfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.baseUrl;
|
|
43
|
+
aliasConfig = {
|
|
44
|
+
absoluteBaseUrl: baseUrl
|
|
45
|
+
? path_1.default.join(option.appDirectory, baseUrl)
|
|
46
|
+
: option.appDirectory,
|
|
47
|
+
paths: Object.assign(Object.assign({}, (aliasOption || {})), (_b = tsconfig === null || tsconfig === void 0 ? void 0 : tsconfig.compilerOptions) === null || _b === void 0 ? void 0 : _b.paths),
|
|
48
|
+
isTsPath: true,
|
|
49
|
+
isTsProject,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return aliasConfig;
|
|
53
|
+
};
|
|
54
|
+
exports.getAlias = getAlias;
|
|
55
|
+
// filter invalid ts paths that are not array
|
|
56
|
+
const getUserAlias = (alias = {}) => Object.keys(alias).reduce((o, k) => {
|
|
57
|
+
if (Array.isArray(alias[k])) {
|
|
58
|
+
o[k] = alias[k];
|
|
59
|
+
}
|
|
60
|
+
return o;
|
|
61
|
+
}, {});
|
|
62
|
+
exports.getUserAlias = getUserAlias;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isApiOnly: (appDirectory: string) => Promise<boolean>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.isApiOnly = void 0;
|
|
35
|
+
const path = __importStar(require("path"));
|
|
36
|
+
const minimist_1 = __importDefault(require("minimist"));
|
|
37
|
+
const compiled_1 = require("./compiled");
|
|
38
|
+
const isApiOnly = (appDirectory) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
const srcDir = path.join(appDirectory, 'src');
|
|
40
|
+
const existSrc = yield compiled_1.fs.pathExists(srcDir);
|
|
41
|
+
const options = (0, minimist_1.default)(process.argv.slice(2));
|
|
42
|
+
return !existSrc || Boolean(options['api-only']);
|
|
43
|
+
});
|
|
44
|
+
exports.isApiOnly = isApiOnly;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const applyOptionsChain: <T, U>(defaults: T, options?: T | (T | ((config: T, utils?: U | undefined) => void | T))[] | ((config: T, utils?: U | undefined) => void | T) | undefined, utils?: U | undefined, mergeFn?: {
|
|
2
|
+
<T_1, U_1>(target: T_1, source: U_1): T_1 & U_1;
|
|
3
|
+
<T_2, U_2, V>(target: T_2, source1: U_2, source2: V): T_2 & U_2 & V;
|
|
4
|
+
<T_3, U_3, V_1, W>(target: T_3, source1: U_3, source2: V_1, source3: W): T_3 & U_3 & V_1 & W;
|
|
5
|
+
(target: object, ...sources: any[]): any;
|
|
6
|
+
}) => T;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyOptionsChain = void 0;
|
|
4
|
+
// eslint-disable-next-line import/no-useless-path-segments
|
|
5
|
+
const index_1 = require("./index");
|
|
6
|
+
const applyOptionsChain = (defaults, options, utils, mergeFn = Object.assign) => {
|
|
7
|
+
if (!options) {
|
|
8
|
+
return defaults;
|
|
9
|
+
}
|
|
10
|
+
if ((0, index_1.isPlainObject)(options)) {
|
|
11
|
+
return mergeFn(defaults, options);
|
|
12
|
+
}
|
|
13
|
+
else if ((0, index_1.isFunction)(options)) {
|
|
14
|
+
const ret = options(defaults, utils);
|
|
15
|
+
if (ret) {
|
|
16
|
+
if (!(0, index_1.isPlainObject)(ret)) {
|
|
17
|
+
index_1.logger.warn(`${options.name}: Function should mutate the config and return nothing, Or return a cloned or merged version of config object.`);
|
|
18
|
+
}
|
|
19
|
+
return ret;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else if (Array.isArray(options)) {
|
|
23
|
+
return options.reduce((memo, cur) => (0, exports.applyOptionsChain)(memo, cur, utils, mergeFn), defaults);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw new Error(`applyOptionsChain error:\ndefault options is: ${JSON.stringify(defaults)}`);
|
|
27
|
+
}
|
|
28
|
+
return defaults;
|
|
29
|
+
};
|
|
30
|
+
exports.applyOptionsChain = applyOptionsChain;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const clearConsole: () => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clearConsole = void 0;
|
|
4
|
+
const clearConsole = () => {
|
|
5
|
+
if (process.stdout.isTTY && !process.env.DEBUG) {
|
|
6
|
+
process.stdout.write('\x1B[H\x1B[2J');
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
exports.clearConsole = clearConsole;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const compatRequire: (filePath: string) => any;
|
|
7
7
|
export declare const requireExistModule: (filename: string, extensions?: string[]) => any;
|
|
8
|
-
export declare const cleanRequireCache: (filelist: string[]) => void;
|
|
8
|
+
export declare const cleanRequireCache: (filelist: string[]) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanRequireCache = exports.requireExistModule = exports.compatRequire = void 0;
|
|
4
|
+
const findExists_1 = require("./findExists");
|
|
5
|
+
/**
|
|
6
|
+
* Require function compatible with esm and cjs module.
|
|
7
|
+
* @param filePath - File to required.
|
|
8
|
+
* @returns module export object.
|
|
9
|
+
*/
|
|
10
|
+
const compatRequire = (filePath) => {
|
|
11
|
+
const mod = require(filePath);
|
|
12
|
+
return (mod === null || mod === void 0 ? void 0 : mod.__esModule) ? mod.default : mod;
|
|
13
|
+
};
|
|
14
|
+
exports.compatRequire = compatRequire;
|
|
15
|
+
const requireExistModule = (filename, extensions = ['.ts', '.js']) => {
|
|
16
|
+
const exist = (0, findExists_1.findExists)(extensions.map(ext => `${filename}${ext}`));
|
|
17
|
+
if (!exist) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return (0, exports.compatRequire)(exist);
|
|
21
|
+
};
|
|
22
|
+
exports.requireExistModule = requireExistModule;
|
|
23
|
+
const cleanRequireCache = (filelist) => {
|
|
24
|
+
filelist.forEach(filepath => {
|
|
25
|
+
delete require.cache[filepath];
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
exports.cleanRequireCache = cleanRequireCache;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import fs from '../compiled/fs-extra';
|
|
2
|
+
import chalk from '../compiled/chalk';
|
|
3
|
+
import lodash from '../compiled/lodash';
|
|
4
|
+
import signale from '../compiled/signale';
|
|
5
|
+
export { fs, chalk, lodash, signale };
|
|
6
|
+
export { program, Command } from '../compiled/commander';
|
|
7
|
+
export { Signale, SignaleOptions } from '../compiled/signale';
|
|
8
|
+
export type { IOptions as GlobOptions } from '../compiled/glob';
|
|
9
|
+
export type { FSWatcher, WatchOptions } from '../compiled/chokidar';
|
|
10
|
+
export declare const glob: typeof import('../compiled/glob');
|
|
11
|
+
export declare const yaml: typeof import('../compiled/js-yaml');
|
|
12
|
+
export declare const execa: typeof import('../compiled/execa');
|
|
13
|
+
export declare const pkgUp: typeof import('../compiled/pkg-up');
|
|
14
|
+
export declare const upath: typeof import('../compiled/upath');
|
|
15
|
+
export declare const debug: typeof import('../compiled/debug');
|
|
16
|
+
export declare const chokidar: typeof import('../compiled/chokidar');
|
|
17
|
+
export declare const gzipSize: typeof import('../compiled/gzip-size');
|
|
18
|
+
export declare const filesize: typeof import('../compiled/filesize');
|
|
19
|
+
export declare const stripAnsi: typeof import('../compiled/strip-ansi');
|
|
20
|
+
export declare const browserslist: typeof import('../compiled/browserslist');
|
|
21
|
+
export declare const recursiveReaddir: typeof import('../compiled/recursive-readdir');
|
package/dist/compiled.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.recursiveReaddir = exports.browserslist = exports.stripAnsi = exports.filesize = exports.gzipSize = exports.chokidar = exports.debug = exports.upath = exports.pkgUp = exports.execa = exports.yaml = exports.glob = exports.SignaleOptions = exports.Signale = exports.Command = exports.program = exports.signale = exports.lodash = exports.chalk = exports.fs = void 0;
|
|
7
|
+
const fs_extra_1 = __importDefault(require("../compiled/fs-extra"));
|
|
8
|
+
exports.fs = fs_extra_1.default;
|
|
9
|
+
const chalk_1 = __importDefault(require("../compiled/chalk"));
|
|
10
|
+
exports.chalk = chalk_1.default;
|
|
11
|
+
const lodash_1 = __importDefault(require("../compiled/lodash"));
|
|
12
|
+
exports.lodash = lodash_1.default;
|
|
13
|
+
const signale_1 = __importDefault(require("../compiled/signale"));
|
|
14
|
+
exports.signale = signale_1.default;
|
|
15
|
+
const import_1 = require("./import");
|
|
16
|
+
var commander_1 = require("../compiled/commander");
|
|
17
|
+
Object.defineProperty(exports, "program", { enumerable: true, get: function () { return commander_1.program; } });
|
|
18
|
+
Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return commander_1.Command; } });
|
|
19
|
+
var signale_2 = require("../compiled/signale");
|
|
20
|
+
Object.defineProperty(exports, "Signale", { enumerable: true, get: function () { return signale_2.Signale; } });
|
|
21
|
+
Object.defineProperty(exports, "SignaleOptions", { enumerable: true, get: function () { return signale_2.SignaleOptions; } });
|
|
22
|
+
exports.glob = import_1.Import.lazy('../compiled/glob', require);
|
|
23
|
+
exports.yaml = import_1.Import.lazy('../compiled/js-yaml', require);
|
|
24
|
+
exports.execa = import_1.Import.lazy('../compiled/execa', require);
|
|
25
|
+
exports.pkgUp = import_1.Import.lazy('../compiled/pkg-up', require);
|
|
26
|
+
exports.upath = import_1.Import.lazy('../compiled/upath', require);
|
|
27
|
+
exports.debug = import_1.Import.lazy('../compiled/debug', require);
|
|
28
|
+
exports.chokidar = import_1.Import.lazy('../compiled/chokidar', require);
|
|
29
|
+
exports.gzipSize = import_1.Import.lazy('../compiled/gzip-size', require);
|
|
30
|
+
exports.filesize = import_1.Import.lazy('../compiled/filesize', require);
|
|
31
|
+
exports.stripAnsi = import_1.Import.lazy('../compiled/strip-ansi', require);
|
|
32
|
+
exports.browserslist = import_1.Import.lazy('../compiled/browserslist', require);
|
|
33
|
+
exports.recursiveReaddir = import_1.Import.lazy('../compiled/recursive-readdir', require);
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hmr socket connect path
|
|
3
|
+
*/
|
|
4
|
+
export declare const HMR_SOCK_PATH = "/_modern_js_hmr_ws";
|
|
5
|
+
/**
|
|
6
|
+
* route specification file
|
|
7
|
+
*/
|
|
8
|
+
export declare const ROUTE_SPEC_FILE = "route.json";
|
|
9
|
+
/**
|
|
10
|
+
* main entry name
|
|
11
|
+
*/
|
|
12
|
+
export declare const MAIN_ENTRY_NAME = "main";
|
|
13
|
+
/**
|
|
14
|
+
* open editor request path
|
|
15
|
+
*/
|
|
16
|
+
export declare const LAUNCH_EDITOR_ENDPOINT = "/__open-stack-frame-in-editor";
|
|
17
|
+
/**
|
|
18
|
+
* server side bundles directory, which relative to dist.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SERVER_BUNDLE_DIRECTORY = "bundles";
|
|
21
|
+
/**
|
|
22
|
+
* entry name pattern used for ajv pattern properties.
|
|
23
|
+
*/
|
|
24
|
+
export declare const ENTRY_NAME_PATTERN = "^[a-zA-Z0-9_-]+$";
|
|
25
|
+
/**
|
|
26
|
+
* SSR server render function name
|
|
27
|
+
*/
|
|
28
|
+
export declare const SERVER_RENDER_FUNCTION_NAME = "serverRender";
|
|
29
|
+
/**
|
|
30
|
+
* loadbale manifest json file
|
|
31
|
+
*/
|
|
32
|
+
export declare const LOADABLE_STATS_FILE = "loadable-stats.json";
|
|
33
|
+
/**
|
|
34
|
+
* internal specified folder
|
|
35
|
+
*/
|
|
36
|
+
export declare const API_DIR = "api";
|
|
37
|
+
export declare const SERVER_DIR = "server";
|
|
38
|
+
export declare const SHARED_DIR = "shared";
|
|
39
|
+
/**
|
|
40
|
+
* Modern.config.ts cached dir
|
|
41
|
+
*/
|
|
42
|
+
export declare const CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
|
|
43
|
+
export declare const CONFIG_FILE_EXTENSIONS: string[];
|
|
44
|
+
/**
|
|
45
|
+
* Serialized config path
|
|
46
|
+
*/
|
|
47
|
+
export declare const OUTPUT_CONFIG_FILE = "modern.config.json";
|
|
48
|
+
/**
|
|
49
|
+
* Default server config basename
|
|
50
|
+
*/
|
|
51
|
+
export declare const DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
|
|
52
|
+
/**
|
|
53
|
+
* Internal plugins that work as soon as they are installed.
|
|
54
|
+
*/
|
|
55
|
+
export declare const INTERNAL_PLUGINS: {
|
|
56
|
+
[name: string]: {
|
|
57
|
+
cli?: string;
|
|
58
|
+
server?: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The schema registered in the plugin.
|
|
63
|
+
*/
|
|
64
|
+
export declare const PLUGIN_SCHEMAS: {
|
|
65
|
+
'@modern-js/runtime': ({
|
|
66
|
+
target: string;
|
|
67
|
+
schema: {
|
|
68
|
+
type: string;
|
|
69
|
+
additionalProperties: boolean;
|
|
70
|
+
patternProperties?: undefined;
|
|
71
|
+
};
|
|
72
|
+
} | {
|
|
73
|
+
target: string;
|
|
74
|
+
schema: {
|
|
75
|
+
type: string;
|
|
76
|
+
patternProperties: {
|
|
77
|
+
"^[a-zA-Z0-9_-]+$": {
|
|
78
|
+
type: string;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
additionalProperties: boolean;
|
|
82
|
+
};
|
|
83
|
+
})[];
|
|
84
|
+
'@modern-js/plugin-bff': {
|
|
85
|
+
target: string;
|
|
86
|
+
schema: {
|
|
87
|
+
type: string;
|
|
88
|
+
properties: {
|
|
89
|
+
prefix: {
|
|
90
|
+
type: string[];
|
|
91
|
+
items: {
|
|
92
|
+
type: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
fetcher: {
|
|
96
|
+
type: string;
|
|
97
|
+
};
|
|
98
|
+
proxy: {
|
|
99
|
+
type: string;
|
|
100
|
+
};
|
|
101
|
+
requestCreator: {
|
|
102
|
+
type: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
}[];
|
|
107
|
+
'@modern-js/plugin-esbuild': {
|
|
108
|
+
target: string;
|
|
109
|
+
schema: {
|
|
110
|
+
typeof: string[];
|
|
111
|
+
};
|
|
112
|
+
}[];
|
|
113
|
+
'@modern-js/plugin-less': {
|
|
114
|
+
target: string;
|
|
115
|
+
schema: {
|
|
116
|
+
typeof: string[];
|
|
117
|
+
};
|
|
118
|
+
}[];
|
|
119
|
+
'@modern-js/plugin-sass': {
|
|
120
|
+
target: string;
|
|
121
|
+
schema: {
|
|
122
|
+
typeof: string[];
|
|
123
|
+
};
|
|
124
|
+
}[];
|
|
125
|
+
'@modern-js/plugin-tailwindcss': {
|
|
126
|
+
target: string;
|
|
127
|
+
schema: {
|
|
128
|
+
typeof: string[];
|
|
129
|
+
};
|
|
130
|
+
}[];
|
|
131
|
+
'@modern-js/plugin-proxy': {
|
|
132
|
+
target: string;
|
|
133
|
+
schema: {
|
|
134
|
+
typeof: string[];
|
|
135
|
+
};
|
|
136
|
+
}[];
|
|
137
|
+
'@modern-js/plugin-unbundle': ({
|
|
138
|
+
target: string;
|
|
139
|
+
schema: {
|
|
140
|
+
type: string;
|
|
141
|
+
properties?: undefined;
|
|
142
|
+
};
|
|
143
|
+
} | {
|
|
144
|
+
target: string;
|
|
145
|
+
schema: {
|
|
146
|
+
type: string;
|
|
147
|
+
properties: {
|
|
148
|
+
ignore: {
|
|
149
|
+
type: string[];
|
|
150
|
+
items: {
|
|
151
|
+
type: string;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
ignoreModuleCache: {
|
|
155
|
+
type: string;
|
|
156
|
+
};
|
|
157
|
+
clearPdnCache: {
|
|
158
|
+
type: string;
|
|
159
|
+
};
|
|
160
|
+
pdnHost: {
|
|
161
|
+
type: string;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
})[];
|
|
166
|
+
'@modern-js/plugin-ssg': {
|
|
167
|
+
target: string;
|
|
168
|
+
schema: {
|
|
169
|
+
oneOf: ({
|
|
170
|
+
type: string;
|
|
171
|
+
instanceof?: undefined;
|
|
172
|
+
} | {
|
|
173
|
+
instanceof: string;
|
|
174
|
+
type?: undefined;
|
|
175
|
+
})[];
|
|
176
|
+
};
|
|
177
|
+
}[];
|
|
178
|
+
'@modern-js/plugin-ssr': {
|
|
179
|
+
target: string;
|
|
180
|
+
schema: {
|
|
181
|
+
type: string[];
|
|
182
|
+
};
|
|
183
|
+
}[];
|
|
184
|
+
'@modern-js/plugin-state': {
|
|
185
|
+
target: string;
|
|
186
|
+
schema: {
|
|
187
|
+
type: string[];
|
|
188
|
+
};
|
|
189
|
+
}[];
|
|
190
|
+
'@modern-js/plugin-design-token': ({
|
|
191
|
+
target: string;
|
|
192
|
+
schema: {
|
|
193
|
+
typeof: string[];
|
|
194
|
+
type?: undefined;
|
|
195
|
+
};
|
|
196
|
+
} | {
|
|
197
|
+
target: string;
|
|
198
|
+
schema: {
|
|
199
|
+
type: string[];
|
|
200
|
+
typeof?: undefined;
|
|
201
|
+
};
|
|
202
|
+
})[];
|
|
203
|
+
'@modern-js/plugin-router': {
|
|
204
|
+
target: string;
|
|
205
|
+
schema: {
|
|
206
|
+
type: string[];
|
|
207
|
+
};
|
|
208
|
+
}[];
|
|
209
|
+
'@modern-js/plugin-testing': {
|
|
210
|
+
target: string;
|
|
211
|
+
schema: {
|
|
212
|
+
typeof: string[];
|
|
213
|
+
};
|
|
214
|
+
}[];
|
|
215
|
+
'@modern-js/plugin-garfish': {
|
|
216
|
+
target: string;
|
|
217
|
+
schema: {
|
|
218
|
+
type: string[];
|
|
219
|
+
};
|
|
220
|
+
}[];
|
|
221
|
+
'@modern-js/plugin-nocode': never[];
|
|
222
|
+
};
|