@modern-js/utils 1.0.0-rc.14 → 1.0.0-rc.18
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +34 -0
- package/dist/js/modern/FileSizeReporter.js +1 -1
- package/dist/js/modern/alias.js +1 -1
- package/dist/js/modern/constants.js +1 -0
- package/dist/js/modern/ensureAbsolutePath.js +1 -1
- package/dist/js/modern/getPackageManager.js +1 -1
- package/dist/js/modern/index.js +5 -1
- package/dist/js/modern/is/index.js +1 -1
- package/dist/js/modern/monorepo.js +1 -1
- package/dist/js/modern/path.js +16 -1
- package/dist/js/modern/readTsConfig.js +1 -1
- package/dist/js/modern/runtimeExports.js +1 -1
- package/dist/js/node/FileSizeReporter.js +12 -8
- package/dist/js/node/alias.js +7 -3
- package/dist/js/node/constants.js +4 -2
- package/dist/js/node/ensureAbsolutePath.js +5 -3
- package/dist/js/node/getPackageManager.js +10 -6
- package/dist/js/node/index.js +17 -13
- package/dist/js/node/is/index.js +8 -4
- package/dist/js/node/monorepo.js +17 -13
- package/dist/js/node/path.js +48 -2
- package/dist/js/node/readTsConfig.js +6 -4
- package/dist/js/node/runtimeExports.js +7 -4
- package/dist/js/treeshaking/FileSizeReporter.js +1 -1
- package/dist/js/treeshaking/alias.js +1 -1
- package/dist/js/treeshaking/constants.js +1 -0
- package/dist/js/treeshaking/ensureAbsolutePath.js +1 -1
- package/dist/js/treeshaking/getPackageManager.js +1 -1
- package/dist/js/treeshaking/index.js +5 -1
- package/dist/js/treeshaking/is/index.js +1 -1
- package/dist/js/treeshaking/monorepo.js +1 -1
- package/dist/js/treeshaking/path.js +31 -1
- package/dist/js/treeshaking/readTsConfig.js +1 -1
- package/dist/js/treeshaking/runtimeExports.js +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/monorepo.d.ts +1 -1
- package/dist/types/path.d.ts +12 -1
- package/package.json +4 -3
- package/src/FileSizeReporter.ts +1 -1
- package/src/alias.ts +1 -1
- package/src/constants.ts +2 -0
- package/src/ensureAbsolutePath.ts +1 -1
- package/src/getPackageManager.ts +1 -1
- package/src/index.ts +3 -1
- package/src/is/index.ts +1 -1
- package/src/monorepo.ts +1 -1
- package/src/path.ts +25 -0
- package/src/readTsConfig.ts +1 -1
- package/src/runtimeExports.ts +1 -1
- package/tests/compatRequire.test.ts +1 -1
- package/tests/findExists.test.ts +1 -1
- package/tests/getBrowserslist.test.ts +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,39 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
+
## 1.0.0-rc.18
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 224f7fe: fix server route match
|
8
|
+
- 30ac27c: feat: add generator package description
|
9
|
+
- 204c626: feat: initial
|
10
|
+
- 63be0a5: fix: #118 #104
|
11
|
+
|
12
|
+
## 1.0.0-rc.17
|
13
|
+
|
14
|
+
### Patch Changes
|
15
|
+
|
16
|
+
- 224f7fe: fix server route match
|
17
|
+
- 30ac27c: feat: add generator package description
|
18
|
+
- 204c626: feat: initial
|
19
|
+
- fix: #118 #104
|
20
|
+
|
21
|
+
## 1.0.0-rc.16
|
22
|
+
|
23
|
+
### Patch Changes
|
24
|
+
|
25
|
+
- 224f7fe: fix server route match
|
26
|
+
- 30ac27c: feat: add generator package description
|
27
|
+
- 204c626: feat: initial
|
28
|
+
|
29
|
+
## 1.0.0-rc.15
|
30
|
+
|
31
|
+
### Patch Changes
|
32
|
+
|
33
|
+
- 224f7fe: fix server route match
|
34
|
+
- 30ac27c: feat: add generator package description
|
35
|
+
- 204c626: feat: initial
|
36
|
+
|
3
37
|
## 1.0.0-rc.14
|
4
38
|
|
5
39
|
### Patch Changes
|
package/dist/js/modern/alias.js
CHANGED
@@ -5,8 +5,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
5
5
|
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; }
|
6
6
|
|
7
7
|
import fs from 'fs';
|
8
|
-
import path from 'path';
|
9
8
|
import chalk from 'chalk';
|
9
|
+
import * as path from "./path";
|
10
10
|
import { readTsConfigByFile } from "./readTsConfig";
|
11
11
|
import { applyOptionsChain } from "./applyOptionsChain";
|
12
12
|
export const validAlias = (modernConfig, {
|
@@ -42,6 +42,7 @@ export const SERVER_RENDER_FUNCTION_NAME = 'serverRender';
|
|
42
42
|
*/
|
43
43
|
|
44
44
|
export const LOADABLE_STATS_FILE = 'loadable-stats.json';
|
45
|
+
export const HIDE_MODERN_JS_DIR = './node_modules/.modern-js';
|
45
46
|
/**
|
46
47
|
* Internal plugins that work as soon as they are installed.
|
47
48
|
*/
|
package/dist/js/modern/index.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import * as _fs from 'fs-extra';
|
2
2
|
export { _fs as fs };
|
3
|
+
import * as _upath from 'upath';
|
4
|
+
export { _upath as upath };
|
3
5
|
export * from "./chalk";
|
4
6
|
export * from "./formatWebpackMessages";
|
5
7
|
export * from "./FileSizeReporter";
|
@@ -23,7 +25,9 @@ export * from "./monorepo";
|
|
23
25
|
export * from "./getPackageManager";
|
24
26
|
export * from "./runtimeExports";
|
25
27
|
export * from "./readTsConfig";
|
26
|
-
export
|
28
|
+
export { isRelativePath } from "./path";
|
29
|
+
import * as _path from "./path";
|
30
|
+
export { _path as path };
|
27
31
|
export * from "./generateMetaTags";
|
28
32
|
export * from "./prettyInstructions";
|
29
33
|
export * from "./alias";
|
@@ -5,9 +5,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
5
5
|
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; }
|
6
6
|
|
7
7
|
import fs from 'fs';
|
8
|
-
import path from 'path';
|
9
8
|
import glob from 'glob';
|
10
9
|
import yaml from 'yaml';
|
10
|
+
import * as path from "./path";
|
11
11
|
const PACKAGE_MAX_DEPTH = 5;
|
12
12
|
const WOKRSPACES_FILES = {
|
13
13
|
YARN: 'package.json',
|
package/dist/js/modern/path.js
CHANGED
@@ -1 +1,16 @@
|
|
1
|
-
|
1
|
+
import path from 'path';
|
2
|
+
import upath from 'upath';
|
3
|
+
export const isRelativePath = test => /^\.\.?($|[\\/])/.test(test);
|
4
|
+
export const join = (...paths) => upath.normalizeSafe(path.join(...paths));
|
5
|
+
export const resolve = (...paths) => upath.normalizeSafe(path.resolve(...paths));
|
6
|
+
export const relative = (from, to) => upath.normalizeSafe(path.relative(from, to));
|
7
|
+
export const basename = (p, ext) => upath.normalizeSafe(path.basename(p, ext));
|
8
|
+
export const dirname = p => upath.normalizeSafe(path.dirname(p));
|
9
|
+
export const extname = p => path.extname(p);
|
10
|
+
export const isAbsolute = p => path.isAbsolute(p);
|
11
|
+
export const normalize = p => upath.normalizeSafe(path.normalize(p));
|
12
|
+
export const {
|
13
|
+
sep,
|
14
|
+
win32,
|
15
|
+
posix
|
16
|
+
} = path;
|
@@ -20,7 +20,7 @@ exports.printFileSizesAfterBuild = printFileSizesAfterBuild;
|
|
20
20
|
|
21
21
|
var _fs = _interopRequireDefault(require("fs"));
|
22
22
|
|
23
|
-
var
|
23
|
+
var path = _interopRequireWildcard(require("./path"));
|
24
24
|
|
25
25
|
var _chalk = _interopRequireDefault(require("chalk"));
|
26
26
|
|
@@ -34,6 +34,10 @@ var _gzipSize = _interopRequireDefault(require("gzip-size"));
|
|
34
34
|
|
35
35
|
var _ = require(".");
|
36
36
|
|
37
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
38
|
+
|
39
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
40
|
+
|
37
41
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
38
42
|
|
39
43
|
function canReadAsset(asset) {
|
@@ -48,7 +52,7 @@ function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, ma
|
|
48
52
|
all: false,
|
49
53
|
assets: true
|
50
54
|
}).assets.filter(asset => canReadAsset(asset.name)).map(asset => {
|
51
|
-
var fileContents = _fs.default.readFileSync(
|
55
|
+
var fileContents = _fs.default.readFileSync(path.join(root, asset.name));
|
52
56
|
|
53
57
|
var size = fileContents.length;
|
54
58
|
|
@@ -58,8 +62,8 @@ function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, ma
|
|
58
62
|
var sizeDifference = getDifferenceLabel(size, previousSize);
|
59
63
|
var gzipSizeDifference = getDifferenceLabel(gzippedSize, previousGzipSize);
|
60
64
|
return {
|
61
|
-
folder:
|
62
|
-
name:
|
65
|
+
folder: path.join(path.basename(buildFolder), path.dirname(asset.name)),
|
66
|
+
name: path.basename(asset.name),
|
63
67
|
gzippedSize: gzippedSize,
|
64
68
|
sizeLabel: (0, _filesize.default)(size) + (sizeDifference ? ' (' + sizeDifference + ')' : ''),
|
65
69
|
gzipSizeLabel: (0, _filesize.default)(gzippedSize) + (gzipSizeDifference ? ' (' + gzipSizeDifference + ')' : '')
|
@@ -67,7 +71,7 @@ function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, ma
|
|
67
71
|
})).reduce((single, all) => all.concat(single), []);
|
68
72
|
assets.sort((a, b) => b.size - a.size);
|
69
73
|
var longestSizeLabelLength = Math.max.apply(null, assets.map(a => (0, _stripAnsi.default)(a.sizeLabel).length));
|
70
|
-
var longestFileNameLength = Math.max.apply(null, assets.map(a => (0, _stripAnsi.default)(a.folder +
|
74
|
+
var longestFileNameLength = Math.max.apply(null, assets.map(a => (0, _stripAnsi.default)(a.folder + path.sep + a.name).length));
|
71
75
|
printFileSizesHeader(longestFileNameLength, longestSizeLabelLength);
|
72
76
|
var suggestBundleSplitting = false;
|
73
77
|
assets.forEach(asset => {
|
@@ -78,7 +82,7 @@ function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, ma
|
|
78
82
|
gzipSizeLabel,
|
79
83
|
gzippedSize
|
80
84
|
} = asset;
|
81
|
-
var fileNameLength = (0, _stripAnsi.default)(folder +
|
85
|
+
var fileNameLength = (0, _stripAnsi.default)(folder + path.sep + name).length;
|
82
86
|
var sizeLength = (0, _stripAnsi.default)(sizeLabel).length;
|
83
87
|
|
84
88
|
if (sizeLength < longestSizeLabelLength) {
|
@@ -86,7 +90,7 @@ function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, ma
|
|
86
90
|
sizeLabel += rightPadding;
|
87
91
|
}
|
88
92
|
|
89
|
-
var fileNameLabel = _chalk.default.dim(asset.folder +
|
93
|
+
var fileNameLabel = _chalk.default.dim(asset.folder + path.sep) + _chalk.default.cyan(asset.name);
|
90
94
|
|
91
95
|
if (fileNameLength < longestFileNameLength) {
|
92
96
|
var rightPadding = ' '.repeat(longestFileNameLength - fileNameLength);
|
@@ -97,7 +101,7 @@ function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, ma
|
|
97
101
|
var maxRecommendedSize = isMainBundle ? maxBundleGzipSize : maxChunkGzipSize;
|
98
102
|
var isLarge = maxRecommendedSize && gzippedSize > maxRecommendedSize;
|
99
103
|
|
100
|
-
if (isLarge &&
|
104
|
+
if (isLarge && path.extname(asset.name) === '.js') {
|
101
105
|
suggestBundleSplitting = true;
|
102
106
|
}
|
103
107
|
|
package/dist/js/node/alias.js
CHANGED
@@ -7,14 +7,18 @@ exports.validAlias = exports.getUserAlias = exports.getAlias = void 0;
|
|
7
7
|
|
8
8
|
var _fs = _interopRequireDefault(require("fs"));
|
9
9
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
11
|
-
|
12
10
|
var _chalk = _interopRequireDefault(require("chalk"));
|
13
11
|
|
12
|
+
var path = _interopRequireWildcard(require("./path"));
|
13
|
+
|
14
14
|
var _readTsConfig = require("./readTsConfig");
|
15
15
|
|
16
16
|
var _applyOptionsChain = require("./applyOptionsChain");
|
17
17
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
19
|
+
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
21
|
+
|
18
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
23
|
|
20
24
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
@@ -73,7 +77,7 @@ const getAlias = (aliasOption, option) => {
|
|
73
77
|
const tsconfig = (0, _readTsConfig.readTsConfigByFile)(option.tsconfigPath);
|
74
78
|
const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt === void 0 ? void 0 : _tsconfig$compilerOpt.baseUrl;
|
75
79
|
aliasConfig = {
|
76
|
-
absoluteBaseUrl: baseUrl ?
|
80
|
+
absoluteBaseUrl: baseUrl ? path.join(option.appDirectory, baseUrl) : option.appDirectory,
|
77
81
|
paths: _objectSpread(_objectSpread({}, aliasOption || {}), tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt2 = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt2 === void 0 ? void 0 : _tsconfig$compilerOpt2.paths),
|
78
82
|
isTsPath: true,
|
79
83
|
isTsProject
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.SERVER_RENDER_FUNCTION_NAME = exports.SERVER_BUNDLE_DIRECTORY = exports.ROUTE_SPEC_FILE = exports.PLUGIN_SCHEMAS = exports.LOADABLE_STATS_FILE = exports.LAUNCH_EDITOR_ENDPOINT = exports.INTERNAL_SRC_ALIAS = exports.INTERNAL_PLUGINS = exports.INTERNAL_DIR_ALAIS = exports.HMR_SOCK_PATH = exports.ENTRY_NAME_PATTERN = void 0;
|
6
|
+
exports.SERVER_RENDER_FUNCTION_NAME = exports.SERVER_BUNDLE_DIRECTORY = exports.ROUTE_SPEC_FILE = exports.PLUGIN_SCHEMAS = exports.LOADABLE_STATS_FILE = exports.LAUNCH_EDITOR_ENDPOINT = exports.INTERNAL_SRC_ALIAS = exports.INTERNAL_PLUGINS = exports.INTERNAL_DIR_ALAIS = exports.HMR_SOCK_PATH = exports.HIDE_MODERN_JS_DIR = exports.ENTRY_NAME_PATTERN = void 0;
|
7
7
|
|
8
8
|
/**
|
9
9
|
* alias to src directory
|
@@ -57,11 +57,13 @@ const SERVER_RENDER_FUNCTION_NAME = 'serverRender';
|
|
57
57
|
|
58
58
|
exports.SERVER_RENDER_FUNCTION_NAME = SERVER_RENDER_FUNCTION_NAME;
|
59
59
|
const LOADABLE_STATS_FILE = 'loadable-stats.json';
|
60
|
+
exports.LOADABLE_STATS_FILE = LOADABLE_STATS_FILE;
|
61
|
+
const HIDE_MODERN_JS_DIR = './node_modules/.modern-js';
|
60
62
|
/**
|
61
63
|
* Internal plugins that work as soon as they are installed.
|
62
64
|
*/
|
63
65
|
|
64
|
-
exports.
|
66
|
+
exports.HIDE_MODERN_JS_DIR = HIDE_MODERN_JS_DIR;
|
65
67
|
const INTERNAL_PLUGINS = {
|
66
68
|
'@modern-js/app-tools': {
|
67
69
|
cli: '@modern-js/app-tools/cli'
|
@@ -5,9 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.ensureAbsolutePath = void 0;
|
7
7
|
|
8
|
-
var
|
8
|
+
var path = _interopRequireWildcard(require("./path"));
|
9
9
|
|
10
|
-
function
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
11
|
+
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
11
13
|
|
12
14
|
/**
|
13
15
|
* ensure absolute file path.
|
@@ -15,6 +17,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
15
17
|
* @param filePath - Aboluste or relative file path.
|
16
18
|
* @returns Resolved absolute file path.
|
17
19
|
*/
|
18
|
-
const ensureAbsolutePath = (base, filePath) =>
|
20
|
+
const ensureAbsolutePath = (base, filePath) => path.isAbsolute(filePath) ? filePath : path.resolve(base, filePath);
|
19
21
|
|
20
22
|
exports.ensureAbsolutePath = ensureAbsolutePath;
|
@@ -7,29 +7,33 @@ exports.getPackageManager = getPackageManager;
|
|
7
7
|
|
8
8
|
var _os = _interopRequireDefault(require("os"));
|
9
9
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
11
|
-
|
12
10
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
13
11
|
|
12
|
+
var path = _interopRequireWildcard(require("./path"));
|
13
|
+
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
15
|
+
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
17
|
+
|
14
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
19
|
|
16
20
|
function getPackageManager(cwd = process.cwd()) {
|
17
21
|
let appDirectory = cwd;
|
18
22
|
|
19
23
|
while (_os.default.homedir() !== appDirectory) {
|
20
|
-
if (_fsExtra.default.existsSync(
|
24
|
+
if (_fsExtra.default.existsSync(path.resolve(appDirectory, 'pnpm-lock.yaml'))) {
|
21
25
|
return 'pnpm';
|
22
26
|
}
|
23
27
|
|
24
|
-
if (_fsExtra.default.existsSync(
|
28
|
+
if (_fsExtra.default.existsSync(path.resolve(appDirectory, 'yarn.lock'))) {
|
25
29
|
return 'yarn';
|
26
30
|
}
|
27
31
|
|
28
|
-
if (_fsExtra.default.existsSync(
|
32
|
+
if (_fsExtra.default.existsSync(path.resolve(appDirectory, 'package-lock.json'))) {
|
29
33
|
return 'npm';
|
30
34
|
}
|
31
35
|
|
32
|
-
appDirectory =
|
36
|
+
appDirectory = path.join(appDirectory, '..');
|
33
37
|
}
|
34
38
|
|
35
39
|
return 'npm';
|
package/dist/js/node/index.js
CHANGED
@@ -4,14 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
var _exportNames = {
|
7
|
-
fs: true
|
7
|
+
fs: true,
|
8
|
+
upath: true,
|
9
|
+
isRelativePath: true,
|
10
|
+
path: true
|
8
11
|
};
|
9
12
|
exports.fs = void 0;
|
13
|
+
Object.defineProperty(exports, "isRelativePath", {
|
14
|
+
enumerable: true,
|
15
|
+
get: function () {
|
16
|
+
return _path.isRelativePath;
|
17
|
+
}
|
18
|
+
});
|
19
|
+
exports.upath = exports.path = void 0;
|
10
20
|
|
11
21
|
var _fs = _interopRequireWildcard(require("fs-extra"));
|
12
22
|
|
13
23
|
exports.fs = _fs;
|
14
24
|
|
25
|
+
var _upath = _interopRequireWildcard(require("upath"));
|
26
|
+
|
27
|
+
exports.upath = _upath;
|
28
|
+
|
15
29
|
var _chalk = require("./chalk");
|
16
30
|
|
17
31
|
Object.keys(_chalk).forEach(function (key) {
|
@@ -334,19 +348,9 @@ Object.keys(_readTsConfig).forEach(function (key) {
|
|
334
348
|
});
|
335
349
|
});
|
336
350
|
|
337
|
-
var _path = require("./path");
|
351
|
+
var _path = _interopRequireWildcard(require("./path"));
|
338
352
|
|
339
|
-
|
340
|
-
if (key === "default" || key === "__esModule") return;
|
341
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
342
|
-
if (key in exports && exports[key] === _path[key]) return;
|
343
|
-
Object.defineProperty(exports, key, {
|
344
|
-
enumerable: true,
|
345
|
-
get: function () {
|
346
|
-
return _path[key];
|
347
|
-
}
|
348
|
-
});
|
349
|
-
});
|
353
|
+
exports.path = _path;
|
350
354
|
|
351
355
|
var _generateMetaTags = require("./generateMetaTags");
|
352
356
|
|
package/dist/js/node/is/index.js
CHANGED
@@ -13,10 +13,10 @@ var _exportNames = {
|
|
13
13
|
};
|
14
14
|
exports.isUseSSRBundle = exports.isTypescript = exports.isSSR = exports.isFastRefresh = exports.isEmpty = exports.isDepExists = void 0;
|
15
15
|
|
16
|
-
var _path = _interopRequireDefault(require("path"));
|
17
|
-
|
18
16
|
var _fs = _interopRequireDefault(require("fs"));
|
19
17
|
|
18
|
+
var path = _interopRequireWildcard(require("../path"));
|
19
|
+
|
20
20
|
var _nodeEnv = require("./node-env");
|
21
21
|
|
22
22
|
Object.keys(_nodeEnv).forEach(function (key) {
|
@@ -59,6 +59,10 @@ Object.keys(_type).forEach(function (key) {
|
|
59
59
|
});
|
60
60
|
});
|
61
61
|
|
62
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
63
|
+
|
64
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
65
|
+
|
62
66
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
63
67
|
|
64
68
|
/**
|
@@ -69,7 +73,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
69
73
|
* @returns True if the name is in dependencies or devDependencies, false otherwise.
|
70
74
|
*/
|
71
75
|
const isDepExists = (appDirectory, name) => {
|
72
|
-
const json = require(
|
76
|
+
const json = require(path.resolve(appDirectory, './package.json'));
|
73
77
|
|
74
78
|
const {
|
75
79
|
dependencies = {},
|
@@ -87,7 +91,7 @@ const isDepExists = (appDirectory, name) => {
|
|
87
91
|
|
88
92
|
exports.isDepExists = isDepExists;
|
89
93
|
|
90
|
-
const isTypescript = root => _fs.default.existsSync(
|
94
|
+
const isTypescript = root => _fs.default.existsSync(path.resolve(root, './tsconfig.json'));
|
91
95
|
/**
|
92
96
|
* Is Empty object
|
93
97
|
*
|
package/dist/js/node/monorepo.js
CHANGED
@@ -7,12 +7,16 @@ exports.isYarnWorkspaces = exports.isPnpmWorkspaces = exports.isMonorepo = expor
|
|
7
7
|
|
8
8
|
var _fs = _interopRequireDefault(require("fs"));
|
9
9
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
11
|
-
|
12
10
|
var _glob = _interopRequireDefault(require("glob"));
|
13
11
|
|
14
12
|
var _yaml = _interopRequireDefault(require("yaml"));
|
15
13
|
|
14
|
+
var path = _interopRequireWildcard(require("./path"));
|
15
|
+
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
17
|
+
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
19
|
+
|
16
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
21
|
|
18
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
@@ -28,14 +32,14 @@ const WOKRSPACES_FILES = {
|
|
28
32
|
LERNA: 'lerna.json'
|
29
33
|
};
|
30
34
|
|
31
|
-
const isLerna = root => _fs.default.existsSync(
|
35
|
+
const isLerna = root => _fs.default.existsSync(path.join(root, WOKRSPACES_FILES.LERNA));
|
32
36
|
|
33
37
|
exports.isLerna = isLerna;
|
34
38
|
|
35
39
|
const isYarnWorkspaces = root => {
|
36
40
|
var _json$workspaces;
|
37
41
|
|
38
|
-
const pkg =
|
42
|
+
const pkg = path.join(root, WOKRSPACES_FILES.YARN);
|
39
43
|
|
40
44
|
if (!_fs.default.existsSync(pkg)) {
|
41
45
|
return false;
|
@@ -47,7 +51,7 @@ const isYarnWorkspaces = root => {
|
|
47
51
|
|
48
52
|
exports.isYarnWorkspaces = isYarnWorkspaces;
|
49
53
|
|
50
|
-
const isPnpmWorkspaces = root => _fs.default.existsSync(
|
54
|
+
const isPnpmWorkspaces = root => _fs.default.existsSync(path.join(root, WOKRSPACES_FILES.PNPM));
|
51
55
|
|
52
56
|
exports.isPnpmWorkspaces = isPnpmWorkspaces;
|
53
57
|
|
@@ -56,7 +60,7 @@ const isMonorepo = root => isLerna(root) || isYarnWorkspaces(root) || isPnpmWork
|
|
56
60
|
exports.isMonorepo = isMonorepo;
|
57
61
|
|
58
62
|
const isModernjsMonorepo = root => {
|
59
|
-
const json = JSON.parse(_fs.default.readFileSync(
|
63
|
+
const json = JSON.parse(_fs.default.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
60
64
|
|
61
65
|
const deps = _objectSpread(_objectSpread({}, json.dependencies || {}), json.devDependencies || {});
|
62
66
|
|
@@ -75,7 +79,7 @@ const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
|
|
75
79
|
} // eslint-disable-next-line no-param-reassign
|
76
80
|
|
77
81
|
|
78
|
-
appDirectory =
|
82
|
+
appDirectory = path.dirname(appDirectory);
|
79
83
|
}
|
80
84
|
|
81
85
|
return inMonorepo ? appDirectory : undefined;
|
@@ -87,28 +91,28 @@ const getMonorepoPackages = root => {
|
|
87
91
|
let packages = [];
|
88
92
|
|
89
93
|
if (isYarnWorkspaces(root)) {
|
90
|
-
const json = JSON.parse(_fs.default.readFileSync(
|
94
|
+
const json = JSON.parse(_fs.default.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
91
95
|
({
|
92
96
|
packages
|
93
97
|
} = json.workspaces);
|
94
98
|
} else if (isLerna(root)) {
|
95
|
-
const json = JSON.parse(_fs.default.readFileSync(
|
99
|
+
const json = JSON.parse(_fs.default.readFileSync(path.resolve(root, 'lerna.json'), 'utf8'));
|
96
100
|
({
|
97
101
|
packages
|
98
102
|
} = json);
|
99
103
|
} else {
|
100
104
|
({
|
101
105
|
packages
|
102
|
-
} = _yaml.default.parse(_fs.default.readFileSync(
|
106
|
+
} = _yaml.default.parse(_fs.default.readFileSync(path.join(root, WOKRSPACES_FILES.PNPM), 'utf8')));
|
103
107
|
}
|
104
108
|
|
105
109
|
if (packages) {
|
106
110
|
return packages.map(name => // The trailing / ensures only dirs are picked up
|
107
|
-
_glob.default.sync(
|
111
|
+
_glob.default.sync(path.join(root, `${name}/`), {
|
108
112
|
ignore: ['**/node_modules/**']
|
109
|
-
})).flat().filter(filepath => _fs.default.existsSync(
|
113
|
+
})).flat().filter(filepath => _fs.default.existsSync(path.resolve(filepath, 'package.json'))).map(filepath => ({
|
110
114
|
path: filepath,
|
111
|
-
name: JSON.parse(_fs.default.readFileSync(
|
115
|
+
name: JSON.parse(_fs.default.readFileSync(path.resolve(filepath, 'package.json'), 'utf8')).name
|
112
116
|
}));
|
113
117
|
}
|
114
118
|
|
package/dist/js/node/path.js
CHANGED
@@ -3,8 +3,54 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.isRelativePath = void 0;
|
6
|
+
exports.win32 = exports.sep = exports.resolve = exports.relative = exports.posix = exports.normalize = exports.join = exports.isRelativePath = exports.isAbsolute = exports.extname = exports.dirname = exports.basename = void 0;
|
7
|
+
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
9
|
+
|
10
|
+
var _upath = _interopRequireDefault(require("upath"));
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
7
13
|
|
8
14
|
const isRelativePath = test => /^\.\.?($|[\\/])/.test(test);
|
9
15
|
|
10
|
-
exports.isRelativePath = isRelativePath;
|
16
|
+
exports.isRelativePath = isRelativePath;
|
17
|
+
|
18
|
+
const join = (...paths) => _upath.default.normalizeSafe(_path.default.join(...paths));
|
19
|
+
|
20
|
+
exports.join = join;
|
21
|
+
|
22
|
+
const resolve = (...paths) => _upath.default.normalizeSafe(_path.default.resolve(...paths));
|
23
|
+
|
24
|
+
exports.resolve = resolve;
|
25
|
+
|
26
|
+
const relative = (from, to) => _upath.default.normalizeSafe(_path.default.relative(from, to));
|
27
|
+
|
28
|
+
exports.relative = relative;
|
29
|
+
|
30
|
+
const basename = (p, ext) => _upath.default.normalizeSafe(_path.default.basename(p, ext));
|
31
|
+
|
32
|
+
exports.basename = basename;
|
33
|
+
|
34
|
+
const dirname = p => _upath.default.normalizeSafe(_path.default.dirname(p));
|
35
|
+
|
36
|
+
exports.dirname = dirname;
|
37
|
+
|
38
|
+
const extname = p => _path.default.extname(p);
|
39
|
+
|
40
|
+
exports.extname = extname;
|
41
|
+
|
42
|
+
const isAbsolute = p => _path.default.isAbsolute(p);
|
43
|
+
|
44
|
+
exports.isAbsolute = isAbsolute;
|
45
|
+
|
46
|
+
const normalize = p => _upath.default.normalizeSafe(_path.default.normalize(p));
|
47
|
+
|
48
|
+
exports.normalize = normalize;
|
49
|
+
const {
|
50
|
+
sep,
|
51
|
+
win32,
|
52
|
+
posix
|
53
|
+
} = _path.default;
|
54
|
+
exports.posix = posix;
|
55
|
+
exports.win32 = win32;
|
56
|
+
exports.sep = sep;
|
@@ -5,15 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.readTsConfigByFile = exports.readTsConfig = void 0;
|
7
7
|
|
8
|
-
var
|
8
|
+
var path = _interopRequireWildcard(require("./path"));
|
9
9
|
|
10
|
-
function
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
11
|
+
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
11
13
|
|
12
14
|
const readTsConfig = root => {
|
13
15
|
// import typescript from 'typescript' cause eslint fromat error.
|
14
16
|
const typescript = require('typescript');
|
15
17
|
|
16
|
-
return typescript.readConfigFile(
|
18
|
+
return typescript.readConfigFile(path.resolve(root, './tsconfig.json'), typescript.sys.readFile).config;
|
17
19
|
};
|
18
20
|
|
19
21
|
exports.readTsConfig = readTsConfig;
|
@@ -22,7 +24,7 @@ const readTsConfigByFile = filename => {
|
|
22
24
|
// import typescript from 'typescript' cause eslint fromat error.
|
23
25
|
const typescript = require('typescript');
|
24
26
|
|
25
|
-
return typescript.readConfigFile(
|
27
|
+
return typescript.readConfigFile(path.resolve(filename), typescript.sys.readFile).config;
|
26
28
|
};
|
27
29
|
|
28
30
|
exports.readTsConfigByFile = readTsConfigByFile;
|
@@ -5,10 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.createRuntimeExportsUtils = void 0;
|
7
7
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
9
|
-
|
10
8
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
11
9
|
|
10
|
+
var path = _interopRequireWildcard(require("./path"));
|
11
|
+
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
13
|
+
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
15
|
+
|
12
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
17
|
|
14
18
|
const memo = fn => {
|
@@ -28,14 +32,13 @@ const memo = fn => {
|
|
28
32
|
};
|
29
33
|
|
30
34
|
const createRuntimeExportsUtils = memo((pwd, namespace) => {
|
31
|
-
const entryExportFile =
|
35
|
+
const entryExportFile = path.join(pwd, `.runtime-exports/${namespace ? `${namespace}.js` : 'index.js'}`); // const ensure = () => {
|
32
36
|
// if (!fs.existsSync(entryExportFile)) {
|
33
37
|
// fs.outputFileSync(entryExportFile, '');
|
34
38
|
// }
|
35
39
|
// fs.ensureFileSync(entryExportFile);
|
36
40
|
// };
|
37
41
|
|
38
|
-
|
39
42
|
const addExport = statement => {
|
40
43
|
try {
|
41
44
|
_fsExtra.default.ensureFileSync(entryExportFile);
|
@@ -25,7 +25,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
25
25
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
26
26
|
|
27
27
|
import fs from 'fs';
|
28
|
-
import path from
|
28
|
+
import * as path from "./path";
|
29
29
|
import chalk from 'chalk';
|
30
30
|
import filesize from 'filesize';
|
31
31
|
import recursive from 'recursive-readdir';
|
@@ -5,8 +5,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
5
5
|
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; }
|
6
6
|
|
7
7
|
import fs from 'fs';
|
8
|
-
import path from 'path';
|
9
8
|
import chalk from 'chalk';
|
9
|
+
import * as path from "./path";
|
10
10
|
import { readTsConfigByFile } from "./readTsConfig";
|
11
11
|
import { applyOptionsChain } from "./applyOptionsChain";
|
12
12
|
export var validAlias = function validAlias(modernConfig, _ref) {
|
@@ -44,6 +44,7 @@ export var SERVER_RENDER_FUNCTION_NAME = 'serverRender';
|
|
44
44
|
*/
|
45
45
|
|
46
46
|
export var LOADABLE_STATS_FILE = 'loadable-stats.json';
|
47
|
+
export var HIDE_MODERN_JS_DIR = './node_modules/.modern-js';
|
47
48
|
/**
|
48
49
|
* Internal plugins that work as soon as they are installed.
|
49
50
|
*/
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import os from 'os';
|
2
|
-
import path from 'path';
|
3
2
|
import fs from 'fs-extra';
|
3
|
+
import * as path from "./path";
|
4
4
|
export function getPackageManager() {
|
5
5
|
var cwd = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : process.cwd();
|
6
6
|
var appDirectory = cwd;
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import * as _fs from 'fs-extra';
|
2
2
|
export { _fs as fs };
|
3
|
+
import * as _upath from 'upath';
|
4
|
+
export { _upath as upath };
|
3
5
|
export * from "./chalk";
|
4
6
|
export * from "./formatWebpackMessages";
|
5
7
|
export * from "./FileSizeReporter";
|
@@ -23,7 +25,9 @@ export * from "./monorepo";
|
|
23
25
|
export * from "./getPackageManager";
|
24
26
|
export * from "./runtimeExports";
|
25
27
|
export * from "./readTsConfig";
|
26
|
-
export
|
28
|
+
export { isRelativePath } from "./path";
|
29
|
+
import * as _path from "./path";
|
30
|
+
export { _path as path };
|
27
31
|
export * from "./generateMetaTags";
|
28
32
|
export * from "./prettyInstructions";
|
29
33
|
export * from "./alias";
|
@@ -5,9 +5,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
5
5
|
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; }
|
6
6
|
|
7
7
|
import fs from 'fs';
|
8
|
-
import path from 'path';
|
9
8
|
import glob from 'glob';
|
10
9
|
import yaml from 'yaml';
|
10
|
+
import * as path from "./path";
|
11
11
|
var PACKAGE_MAX_DEPTH = 5;
|
12
12
|
var WOKRSPACES_FILES = {
|
13
13
|
YARN: 'package.json',
|
@@ -1,3 +1,33 @@
|
|
1
|
+
import path from 'path';
|
2
|
+
import upath from 'upath';
|
1
3
|
export var isRelativePath = function isRelativePath(test) {
|
2
4
|
return /^\.\.?($|[\\/])/.test(test);
|
3
|
-
};
|
5
|
+
};
|
6
|
+
export var join = function join() {
|
7
|
+
return upath.normalizeSafe(path.join.apply(path, arguments));
|
8
|
+
};
|
9
|
+
export var resolve = function resolve() {
|
10
|
+
return upath.normalizeSafe(path.resolve.apply(path, arguments));
|
11
|
+
};
|
12
|
+
export var relative = function relative(from, to) {
|
13
|
+
return upath.normalizeSafe(path.relative(from, to));
|
14
|
+
};
|
15
|
+
export var basename = function basename(p, ext) {
|
16
|
+
return upath.normalizeSafe(path.basename(p, ext));
|
17
|
+
};
|
18
|
+
export var dirname = function dirname(p) {
|
19
|
+
return upath.normalizeSafe(path.dirname(p));
|
20
|
+
};
|
21
|
+
export var extname = function extname(p) {
|
22
|
+
return path.extname(p);
|
23
|
+
};
|
24
|
+
export var isAbsolute = function isAbsolute(p) {
|
25
|
+
return path.isAbsolute(p);
|
26
|
+
};
|
27
|
+
export var normalize = function normalize(p) {
|
28
|
+
return upath.normalizeSafe(path.normalize(p));
|
29
|
+
};
|
30
|
+
var sep = path.sep,
|
31
|
+
win32 = path.win32,
|
32
|
+
posix = path.posix;
|
33
|
+
export { sep, win32, posix };
|
@@ -42,6 +42,7 @@ export declare const SERVER_RENDER_FUNCTION_NAME = "serverRender";
|
|
42
42
|
*/
|
43
43
|
|
44
44
|
export declare const LOADABLE_STATS_FILE = "loadable-stats.json";
|
45
|
+
export declare const HIDE_MODERN_JS_DIR = "./node_modules/.modern-js";
|
45
46
|
/**
|
46
47
|
* Internal plugins that work as soon as they are installed.
|
47
48
|
*/
|
package/dist/types/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
export * as fs from 'fs-extra';
|
2
|
+
export * as upath from 'upath';
|
2
3
|
export * from './chalk';
|
3
4
|
export * from './formatWebpackMessages';
|
4
5
|
export * from './FileSizeReporter';
|
@@ -22,7 +23,8 @@ export * from './monorepo';
|
|
22
23
|
export * from './getPackageManager';
|
23
24
|
export * from './runtimeExports';
|
24
25
|
export * from './readTsConfig';
|
25
|
-
export
|
26
|
+
export { isRelativePath } from './path';
|
27
|
+
export * as path from './path';
|
26
28
|
export * from './generateMetaTags';
|
27
29
|
export * from './prettyInstructions';
|
28
30
|
export * from './alias';
|
package/dist/types/monorepo.d.ts
CHANGED
package/dist/types/path.d.ts
CHANGED
@@ -1 +1,12 @@
|
|
1
|
-
|
1
|
+
/// <reference types="node" />
|
2
|
+
import path from 'path';
|
3
|
+
export declare const isRelativePath: (test: string) => boolean;
|
4
|
+
export declare const join: (...paths: string[]) => string;
|
5
|
+
export declare const resolve: (...paths: string[]) => string;
|
6
|
+
export declare const relative: (from: string, to: string) => string;
|
7
|
+
export declare const basename: (p: string, ext?: string | undefined) => string;
|
8
|
+
export declare const dirname: (p: string) => string;
|
9
|
+
export declare const extname: (p: string) => string;
|
10
|
+
export declare const isAbsolute: (p: string) => boolean;
|
11
|
+
export declare const normalize: (p: string) => string;
|
12
|
+
export declare const sep: string, win32: path.PlatformPath, posix: path.PlatformPath;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@modern-js/utils",
|
3
|
-
"version": "1.0.0-rc.
|
3
|
+
"version": "1.0.0-rc.18",
|
4
4
|
"jsnext:source": "./src/index.ts",
|
5
5
|
"types": "./dist/types/index.d.ts",
|
6
6
|
"main": "./dist/js/node/index.js",
|
@@ -42,6 +42,7 @@
|
|
42
42
|
"pkg-up": "^3.1.0",
|
43
43
|
"recursive-readdir": "^2.2.2",
|
44
44
|
"strip-ansi": "6.0.0",
|
45
|
+
"upath": "^2.0.1",
|
45
46
|
"yaml": "^1.10.2"
|
46
47
|
},
|
47
48
|
"devDependencies": {
|
@@ -53,8 +54,8 @@
|
|
53
54
|
"@types/recursive-readdir": "^2.2.0",
|
54
55
|
"typescript": "^4",
|
55
56
|
"webpack": "^5.54.0",
|
56
|
-
"@modern-js/plugin-testing": "^1.0.0-rc.
|
57
|
-
"@modern-js/module-tools": "^1.0.0-rc.
|
57
|
+
"@modern-js/plugin-testing": "^1.0.0-rc.18",
|
58
|
+
"@modern-js/module-tools": "^1.0.0-rc.18"
|
58
59
|
},
|
59
60
|
"peerDependencies": {
|
60
61
|
"typescript": "^4.4.3"
|
package/src/FileSizeReporter.ts
CHANGED
package/src/alias.ts
CHANGED
package/src/constants.ts
CHANGED
@@ -43,6 +43,8 @@ export const SERVER_RENDER_FUNCTION_NAME = 'serverRender';
|
|
43
43
|
*/
|
44
44
|
export const LOADABLE_STATS_FILE = 'loadable-stats.json';
|
45
45
|
|
46
|
+
export const HIDE_MODERN_JS_DIR = './node_modules/.modern-js';
|
47
|
+
|
46
48
|
/**
|
47
49
|
* Internal plugins that work as soon as they are installed.
|
48
50
|
*/
|
package/src/getPackageManager.ts
CHANGED
package/src/index.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
export * as fs from 'fs-extra';
|
2
|
+
export * as upath from 'upath';
|
2
3
|
export * from './chalk';
|
3
4
|
export * from './formatWebpackMessages';
|
4
5
|
export * from './FileSizeReporter';
|
@@ -22,7 +23,8 @@ export * from './monorepo';
|
|
22
23
|
export * from './getPackageManager';
|
23
24
|
export * from './runtimeExports';
|
24
25
|
export * from './readTsConfig';
|
25
|
-
export
|
26
|
+
export { isRelativePath } from './path';
|
27
|
+
export * as path from './path';
|
26
28
|
export * from './generateMetaTags';
|
27
29
|
export * from './prettyInstructions';
|
28
30
|
export * from './alias';
|
package/src/is/index.ts
CHANGED
package/src/monorepo.ts
CHANGED
package/src/path.ts
CHANGED
@@ -1,2 +1,27 @@
|
|
1
|
+
import path from 'path';
|
2
|
+
import upath from 'upath';
|
3
|
+
|
1
4
|
export const isRelativePath = (test: string): boolean =>
|
2
5
|
/^\.\.?($|[\\/])/.test(test);
|
6
|
+
|
7
|
+
export const join = (...paths: string[]) =>
|
8
|
+
upath.normalizeSafe(path.join(...paths));
|
9
|
+
|
10
|
+
export const resolve = (...paths: string[]) =>
|
11
|
+
upath.normalizeSafe(path.resolve(...paths));
|
12
|
+
|
13
|
+
export const relative = (from: string, to: string) =>
|
14
|
+
upath.normalizeSafe(path.relative(from, to));
|
15
|
+
|
16
|
+
export const basename = (p: string, ext?: string) =>
|
17
|
+
upath.normalizeSafe(path.basename(p, ext));
|
18
|
+
|
19
|
+
export const dirname = (p: string) => upath.normalizeSafe(path.dirname(p));
|
20
|
+
|
21
|
+
export const extname = (p: string) => path.extname(p);
|
22
|
+
|
23
|
+
export const isAbsolute = (p: string) => path.isAbsolute(p);
|
24
|
+
|
25
|
+
export const normalize = (p: string) => upath.normalizeSafe(path.normalize(p));
|
26
|
+
|
27
|
+
export const { sep, win32, posix } = path;
|
package/src/readTsConfig.ts
CHANGED
package/src/runtimeExports.ts
CHANGED
package/tests/findExists.test.ts
CHANGED