@modern-js/utils 1.0.0-rc.2 → 1.0.0-rc.6
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +28 -0
- package/README.md +1 -1
- package/dist/js/modern/alias.js +1 -1
- package/dist/js/modern/constants.js +14 -0
- package/dist/js/node/alias.js +2 -3
- package/dist/js/node/constants.js +15 -1
- package/dist/js/node/import.js +1 -1
- package/dist/js/node/is/index.js +1 -1
- package/dist/js/node/is/node-env.js +1 -1
- package/dist/js/node/is/platform.js +1 -1
- package/dist/js/node/is/type.js +2 -2
- package/dist/js/node/monorepo.js +1 -1
- package/dist/js/node/removeSlash.js +1 -1
- package/dist/js/treeshaking/alias.js +1 -1
- package/dist/js/treeshaking/constants.js +14 -0
- package/dist/js/treeshaking/getPort.js +4 -2
- package/dist/js/treeshaking/watch.js +8 -6
- package/dist/types/constants.d.ts +6 -0
- package/package.json +7 -3
- package/src/alias.ts +1 -1
- package/src/constants.ts +11 -0
package/CHANGELOG.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# @modern-js/utils
|
2
|
+
|
3
|
+
## 1.0.0-rc.6
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 224f7fe: fix server route match
|
8
|
+
- 204c626: feat: initial
|
9
|
+
|
10
|
+
## 1.0.0-rc.5
|
11
|
+
|
12
|
+
### Patch Changes
|
13
|
+
|
14
|
+
- 224f7fe: fix server route match
|
15
|
+
- 204c626: feat: initial
|
16
|
+
|
17
|
+
## 1.0.0-rc.4
|
18
|
+
|
19
|
+
### Patch Changes
|
20
|
+
|
21
|
+
- fix server route match
|
22
|
+
- 204c626: feat: initial
|
23
|
+
|
24
|
+
## 1.0.0-rc.3
|
25
|
+
|
26
|
+
### Patch Changes
|
27
|
+
|
28
|
+
- feat: initial
|
package/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
<p align="center">
|
3
|
-
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs.png" width="300" alt="Modern.js Logo" /></a>
|
3
|
+
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
|
4
4
|
</p>
|
5
5
|
|
6
6
|
<p align="center">现代 Web 工程体系</p>
|
package/dist/js/modern/alias.js
CHANGED
@@ -31,7 +31,6 @@ export const validAlias = (modernConfig, {
|
|
31
31
|
return null;
|
32
32
|
};
|
33
33
|
export const getAlias = (aliasOption, option) => {
|
34
|
-
const tsconfig = readTsConfigByFile(option.tsconfigPath);
|
35
34
|
const isTsProject = fs.existsSync(option.tsconfigPath);
|
36
35
|
let aliasConfig;
|
37
36
|
|
@@ -47,6 +46,7 @@ export const getAlias = (aliasOption, option) => {
|
|
47
46
|
} else {
|
48
47
|
var _tsconfig$compilerOpt, _tsconfig$compilerOpt2;
|
49
48
|
|
49
|
+
const tsconfig = readTsConfigByFile(option.tsconfigPath);
|
50
50
|
const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt === void 0 ? void 0 : _tsconfig$compilerOpt.baseUrl;
|
51
51
|
aliasConfig = {
|
52
52
|
absoluteBaseUrl: baseUrl ? path.join(option.appDirectory, baseUrl) : option.appDirectory,
|
@@ -114,6 +114,9 @@ export const INTERNAL_PLUGINS = {
|
|
114
114
|
},
|
115
115
|
'@modern-js/plugin-jarvis': {
|
116
116
|
cli: '@modern-js/plugin-jarvis/cli'
|
117
|
+
},
|
118
|
+
'@modern-js/plugin-tailwind': {
|
119
|
+
cli: '@modern-js/plugin-tailwind/cli'
|
117
120
|
}
|
118
121
|
};
|
119
122
|
/**
|
@@ -174,6 +177,17 @@ export const PLUGIN_SCHEMAS = {
|
|
174
177
|
typeof: ['object', 'function']
|
175
178
|
}
|
176
179
|
}],
|
180
|
+
'@modern-js/plugin-tailwind': [{
|
181
|
+
target: 'tools.tailwind',
|
182
|
+
schema: {
|
183
|
+
typeof: ['object', 'function']
|
184
|
+
}
|
185
|
+
}, {
|
186
|
+
target: 'source.designSystem',
|
187
|
+
schema: {
|
188
|
+
typeof: ['object']
|
189
|
+
}
|
190
|
+
}],
|
177
191
|
'@modern-js/plugin-proxy': [{
|
178
192
|
target: 'dev.proxy',
|
179
193
|
schema: {
|
package/dist/js/node/alias.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.validAlias = exports.getUserAlias = exports.getAlias = void 0;
|
7
7
|
|
8
8
|
var _fs = _interopRequireDefault(require("fs"));
|
9
9
|
|
@@ -48,8 +48,6 @@ const validAlias = (modernConfig, {
|
|
48
48
|
exports.validAlias = validAlias;
|
49
49
|
|
50
50
|
const getAlias = (aliasOption, option) => {
|
51
|
-
const tsconfig = (0, _readTsConfig.readTsConfigByFile)(option.tsconfigPath);
|
52
|
-
|
53
51
|
const isTsProject = _fs.default.existsSync(option.tsconfigPath);
|
54
52
|
|
55
53
|
let aliasConfig;
|
@@ -66,6 +64,7 @@ const getAlias = (aliasOption, option) => {
|
|
66
64
|
} else {
|
67
65
|
var _tsconfig$compilerOpt, _tsconfig$compilerOpt2;
|
68
66
|
|
67
|
+
const tsconfig = (0, _readTsConfig.readTsConfigByFile)(option.tsconfigPath);
|
69
68
|
const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt === void 0 ? void 0 : _tsconfig$compilerOpt.baseUrl;
|
70
69
|
aliasConfig = {
|
71
70
|
absoluteBaseUrl: baseUrl ? _path.default.join(option.appDirectory, baseUrl) : option.appDirectory,
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
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;
|
7
7
|
|
8
8
|
/**
|
9
9
|
* alias to src directory
|
@@ -130,6 +130,9 @@ const INTERNAL_PLUGINS = {
|
|
130
130
|
},
|
131
131
|
'@modern-js/plugin-jarvis': {
|
132
132
|
cli: '@modern-js/plugin-jarvis/cli'
|
133
|
+
},
|
134
|
+
'@modern-js/plugin-tailwind': {
|
135
|
+
cli: '@modern-js/plugin-tailwind/cli'
|
133
136
|
}
|
134
137
|
};
|
135
138
|
/**
|
@@ -191,6 +194,17 @@ const PLUGIN_SCHEMAS = {
|
|
191
194
|
typeof: ['object', 'function']
|
192
195
|
}
|
193
196
|
}],
|
197
|
+
'@modern-js/plugin-tailwind': [{
|
198
|
+
target: 'tools.tailwind',
|
199
|
+
schema: {
|
200
|
+
typeof: ['object', 'function']
|
201
|
+
}
|
202
|
+
}, {
|
203
|
+
target: 'source.designSystem',
|
204
|
+
schema: {
|
205
|
+
typeof: ['object']
|
206
|
+
}
|
207
|
+
}],
|
194
208
|
'@modern-js/plugin-proxy': [{
|
195
209
|
target: 'dev.proxy',
|
196
210
|
schema: {
|
package/dist/js/node/import.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.lazyImport = exports.Import = void 0;
|
7
7
|
|
8
8
|
// cover: https://rushstack.io/pages/api/node-core-library.import.lazy/
|
9
9
|
const lazy = (moduleName, requireFn) => {
|
package/dist/js/node/is/index.js
CHANGED
@@ -11,7 +11,7 @@ var _exportNames = {
|
|
11
11
|
isUseSSRBundle: true,
|
12
12
|
isFastRefresh: true
|
13
13
|
};
|
14
|
-
exports.
|
14
|
+
exports.isUseSSRBundle = exports.isTypescript = exports.isSSR = exports.isFastRefresh = exports.isEmpty = exports.isDepExists = void 0;
|
15
15
|
|
16
16
|
var _path = _interopRequireDefault(require("path"));
|
17
17
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.isTest = exports.isProdProfile = exports.isProd = exports.isDev = void 0;
|
7
7
|
|
8
8
|
const isDev = () => process.env.NODE_ENV === 'development';
|
9
9
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.isNodeJS = exports.isBrowser = void 0;
|
7
7
|
|
8
8
|
const isNodeJS = () => typeof process !== 'undefined' && process.versions != null && process.versions.node != null && process.versions.electron == null;
|
9
9
|
|
package/dist/js/node/is/type.js
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.isString = isString;
|
7
|
-
exports.isUndefined = isUndefined;
|
8
6
|
exports.isArray = isArray;
|
9
7
|
exports.isFunction = isFunction;
|
10
8
|
exports.isObject = isObject;
|
11
9
|
exports.isPlainObject = isPlainObject;
|
12
10
|
exports.isPromise = isPromise;
|
11
|
+
exports.isString = isString;
|
12
|
+
exports.isUndefined = isUndefined;
|
13
13
|
|
14
14
|
function isString(str) {
|
15
15
|
return typeof str === 'string';
|
package/dist/js/node/monorepo.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.isYarnWorkspaces = exports.isPnpmWorkspaces = exports.isMonorepo = exports.isModernjsMonorepo = exports.isLerna = exports.getMonorepoPackages = exports.findMonorepoRoot = void 0;
|
7
7
|
|
8
8
|
var _fs = _interopRequireDefault(require("fs"));
|
9
9
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.removeTailSlash = exports.removeSlash = exports.removeLeadingSlash = void 0;
|
7
7
|
|
8
8
|
const removeLeadingSlash = s => s.replace(/^\/+/, '');
|
9
9
|
|
@@ -26,7 +26,6 @@ export var validAlias = function validAlias(modernConfig, _ref) {
|
|
26
26
|
return null;
|
27
27
|
};
|
28
28
|
export var getAlias = function getAlias(aliasOption, option) {
|
29
|
-
var tsconfig = readTsConfigByFile(option.tsconfigPath);
|
30
29
|
var isTsProject = fs.existsSync(option.tsconfigPath);
|
31
30
|
var aliasConfig;
|
32
31
|
|
@@ -42,6 +41,7 @@ export var getAlias = function getAlias(aliasOption, option) {
|
|
42
41
|
} else {
|
43
42
|
var _tsconfig$compilerOpt, _tsconfig$compilerOpt2;
|
44
43
|
|
44
|
+
var tsconfig = readTsConfigByFile(option.tsconfigPath);
|
45
45
|
var baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt === void 0 ? void 0 : _tsconfig$compilerOpt.baseUrl;
|
46
46
|
aliasConfig = {
|
47
47
|
absoluteBaseUrl: baseUrl ? path.join(option.appDirectory, baseUrl) : option.appDirectory,
|
@@ -116,6 +116,9 @@ export var INTERNAL_PLUGINS = {
|
|
116
116
|
},
|
117
117
|
'@modern-js/plugin-jarvis': {
|
118
118
|
cli: '@modern-js/plugin-jarvis/cli'
|
119
|
+
},
|
120
|
+
'@modern-js/plugin-tailwind': {
|
121
|
+
cli: '@modern-js/plugin-tailwind/cli'
|
119
122
|
}
|
120
123
|
};
|
121
124
|
/**
|
@@ -174,6 +177,17 @@ export var PLUGIN_SCHEMAS = {
|
|
174
177
|
"typeof": ['object', 'function']
|
175
178
|
}
|
176
179
|
}],
|
180
|
+
'@modern-js/plugin-tailwind': [{
|
181
|
+
target: 'tools.tailwind',
|
182
|
+
schema: {
|
183
|
+
"typeof": ['object', 'function']
|
184
|
+
}
|
185
|
+
}, {
|
186
|
+
target: 'source.designSystem',
|
187
|
+
schema: {
|
188
|
+
"typeof": ['object']
|
189
|
+
}
|
190
|
+
}],
|
177
191
|
'@modern-js/plugin-proxy': [{
|
178
192
|
target: 'dev.proxy',
|
179
193
|
schema: {
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
2
|
+
|
1
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
2
4
|
|
3
5
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
@@ -15,13 +17,13 @@ import { logger } from "./logger";
|
|
15
17
|
/* eslint-disable no-param-reassign, @typescript-eslint/no-loop-func */
|
16
18
|
|
17
19
|
export var getPort = /*#__PURE__*/function () {
|
18
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/
|
20
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(port) {
|
19
21
|
var tryLimits,
|
20
22
|
original,
|
21
23
|
found,
|
22
24
|
attempts,
|
23
25
|
_args = arguments;
|
24
|
-
return
|
26
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
25
27
|
while (1) {
|
26
28
|
switch (_context.prev = _context.next) {
|
27
29
|
case 0:
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
2
|
+
|
1
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
2
4
|
|
3
5
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
@@ -20,9 +22,9 @@ export var watch = function watch(watchDir, runTask) {
|
|
20
22
|
return ready = true;
|
21
23
|
});
|
22
24
|
watcher.on('change', /*#__PURE__*/function () {
|
23
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/
|
25
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(filePath) {
|
24
26
|
var changedFilePath;
|
25
|
-
return
|
27
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
26
28
|
while (1) {
|
27
29
|
switch (_context.prev = _context.next) {
|
28
30
|
case 0:
|
@@ -46,9 +48,9 @@ export var watch = function watch(watchDir, runTask) {
|
|
46
48
|
};
|
47
49
|
}());
|
48
50
|
watcher.on('add', /*#__PURE__*/function () {
|
49
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/
|
51
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(filePath) {
|
50
52
|
var changedFilePath;
|
51
|
-
return
|
53
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
52
54
|
while (1) {
|
53
55
|
switch (_context2.prev = _context2.next) {
|
54
56
|
case 0:
|
@@ -78,9 +80,9 @@ export var watch = function watch(watchDir, runTask) {
|
|
78
80
|
};
|
79
81
|
}());
|
80
82
|
watcher.on('unlink', /*#__PURE__*/function () {
|
81
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/
|
83
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(filePath) {
|
82
84
|
var changedFilePath;
|
83
|
-
return
|
85
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
84
86
|
while (1) {
|
85
87
|
switch (_context3.prev = _context3.next) {
|
86
88
|
case 0:
|
@@ -111,6 +111,12 @@ export declare const PLUGIN_SCHEMAS: {
|
|
111
111
|
typeof: string[];
|
112
112
|
};
|
113
113
|
}[];
|
114
|
+
'@modern-js/plugin-tailwind': {
|
115
|
+
target: string;
|
116
|
+
schema: {
|
117
|
+
typeof: string[];
|
118
|
+
};
|
119
|
+
}[];
|
114
120
|
'@modern-js/plugin-proxy': {
|
115
121
|
target: string;
|
116
122
|
schema: {
|
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.6",
|
4
4
|
"jsnext:source": "./src/index.ts",
|
5
5
|
"types": "./dist/types/index.d.ts",
|
6
6
|
"main": "./dist/js/node/index.js",
|
@@ -53,13 +53,17 @@
|
|
53
53
|
"@types/recursive-readdir": "^2.2.0",
|
54
54
|
"typescript": "^4",
|
55
55
|
"webpack": "^5.54.0",
|
56
|
-
"@modern-js/plugin-testing": "^1.0.0-rc.
|
57
|
-
"@modern-js/module-tools": "^1.0.0-rc.
|
56
|
+
"@modern-js/plugin-testing": "^1.0.0-rc.6",
|
57
|
+
"@modern-js/module-tools": "^1.0.0-rc.6"
|
58
58
|
},
|
59
59
|
"peerDependencies": {
|
60
60
|
"typescript": "^4.4.3"
|
61
61
|
},
|
62
62
|
"sideEffects": false,
|
63
|
+
"publishConfig": {
|
64
|
+
"registry": "https://registry.npmjs.org/",
|
65
|
+
"access": "public"
|
66
|
+
},
|
63
67
|
"scripts": {
|
64
68
|
"new": "modern new",
|
65
69
|
"build": "modern build",
|
package/src/alias.ts
CHANGED
@@ -53,7 +53,6 @@ export const getAlias = (
|
|
53
53
|
aliasOption: AliasOption | Array<AliasOption>,
|
54
54
|
option: { appDirectory: string; tsconfigPath: string },
|
55
55
|
) => {
|
56
|
-
const tsconfig = readTsConfigByFile(option.tsconfigPath);
|
57
56
|
const isTsProject = fs.existsSync(option.tsconfigPath);
|
58
57
|
let aliasConfig: IAliasConfig;
|
59
58
|
if (!isTsProject) {
|
@@ -64,6 +63,7 @@ export const getAlias = (
|
|
64
63
|
isTsProject,
|
65
64
|
};
|
66
65
|
} else {
|
66
|
+
const tsconfig = readTsConfigByFile(option.tsconfigPath);
|
67
67
|
const baseUrl = tsconfig?.compilerOptions?.baseUrl;
|
68
68
|
aliasConfig = {
|
69
69
|
absoluteBaseUrl: baseUrl
|
package/src/constants.ts
CHANGED
@@ -87,6 +87,7 @@ export const INTERNAL_PLUGINS: {
|
|
87
87
|
cli: '@modern-js/plugin-micro-frontend/cli',
|
88
88
|
},
|
89
89
|
'@modern-js/plugin-jarvis': { cli: '@modern-js/plugin-jarvis/cli' },
|
90
|
+
'@modern-js/plugin-tailwind': { cli: '@modern-js/plugin-tailwind/cli' },
|
90
91
|
};
|
91
92
|
|
92
93
|
/**
|
@@ -141,6 +142,16 @@ export const PLUGIN_SCHEMAS = {
|
|
141
142
|
schema: { typeof: ['object', 'function'] },
|
142
143
|
},
|
143
144
|
],
|
145
|
+
'@modern-js/plugin-tailwind': [
|
146
|
+
{
|
147
|
+
target: 'tools.tailwind',
|
148
|
+
schema: { typeof: ['object', 'function'] },
|
149
|
+
},
|
150
|
+
{
|
151
|
+
target: 'source.designSystem',
|
152
|
+
schema: { typeof: ['object'] },
|
153
|
+
},
|
154
|
+
],
|
144
155
|
'@modern-js/plugin-proxy': [
|
145
156
|
{
|
146
157
|
target: 'dev.proxy',
|