@modern-js/utils 1.7.7 → 1.7.9

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @modern-js/utils
2
2
 
3
+ ## 1.7.9
4
+
5
+ ### Patch Changes
6
+
7
+ - a90bc96: perf(babel): skip babel-plugin-import if package not installed
8
+
9
+ ## 1.7.8
10
+
11
+ ### Patch Changes
12
+
13
+ - 63c354ad5: fix normalizeToPosixPath utils function args would be null
14
+ - 073e9ad78: feat(webpack): improve utils of tools.webpack
15
+ - f4a7d49e1: fix: applyOptionsChain argument type
16
+
3
17
  ## 1.7.7
4
18
 
5
19
  ### Patch Changes
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -0,0 +1 @@
1
+ export declare const ensureArray: <T>(params: T | T[]) => T[];
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureArray = void 0;
4
+ const ensureArray = (params) => {
5
+ if (Array.isArray(params)) {
6
+ return params;
7
+ }
8
+ return [params];
9
+ };
10
+ exports.ensureArray = ensureArray;
@@ -13,4 +13,4 @@ export declare type MetaAttributes = {
13
13
  export interface MetaOptions {
14
14
  [name: string]: string | false | MetaAttributes;
15
15
  }
16
- export declare const generateMetaTags: (metaOptions?: MetaOptions | undefined) => string;
16
+ export declare const generateMetaTags: (metaOptions?: MetaOptions) => string;
@@ -1 +1 @@
1
- export declare const getEntryOptions: <T>(name: string, baseOptions?: T | undefined, optionsByEntries?: Record<string, T> | undefined, packageName?: string | undefined) => T | undefined;
1
+ export declare const getEntryOptions: <T>(name: string, baseOptions?: T | undefined, optionsByEntries?: Record<string, T> | undefined, packageName?: string) => T | undefined;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from './is';
8
8
  export * from './compatRequire';
9
9
  export * from './logger';
10
10
  export * from './constants';
11
+ export * from './ensureArray';
11
12
  export * from './ensureAbsolutePath';
12
13
  export * from './clearConsole';
13
14
  export * from './applyOptionsChain';
@@ -30,5 +31,6 @@ export * from './wait';
30
31
  export * from './emptyDir';
31
32
  export * from './getServerConfig';
32
33
  export * from './ssr';
34
+ export * from './tryResolve';
33
35
  export * from './analyzeProject';
34
36
  export * from './chainId';
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -20,6 +24,7 @@ __exportStar(require("./is"), exports);
20
24
  __exportStar(require("./compatRequire"), exports);
21
25
  __exportStar(require("./logger"), exports);
22
26
  __exportStar(require("./constants"), exports);
27
+ __exportStar(require("./ensureArray"), exports);
23
28
  __exportStar(require("./ensureAbsolutePath"), exports);
24
29
  __exportStar(require("./clearConsole"), exports);
25
30
  __exportStar(require("./applyOptionsChain"), exports);
@@ -42,5 +47,6 @@ __exportStar(require("./wait"), exports);
42
47
  __exportStar(require("./emptyDir"), exports);
43
48
  __exportStar(require("./getServerConfig"), exports);
44
49
  __exportStar(require("./ssr"), exports);
50
+ __exportStar(require("./tryResolve"), exports);
45
51
  __exportStar(require("./analyzeProject"), exports);
46
52
  __exportStar(require("./chainId"), exports);
package/dist/is/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/dist/path.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export declare const isRelativePath: (test: string) => boolean;
2
2
  export declare const normalizeOutputPath: (s: string) => string;
3
- export declare const normalizeToPosixPath: (p: string) => string;
3
+ export declare const normalizeToPosixPath: (p: string | undefined) => string;
package/dist/path.js CHANGED
@@ -10,5 +10,5 @@ const isRelativePath = (test) => /^\.\.?($|[\\/])/.test(test);
10
10
  exports.isRelativePath = isRelativePath;
11
11
  const normalizeOutputPath = (s) => s.replace(/\\/g, '\\\\');
12
12
  exports.normalizeOutputPath = normalizeOutputPath;
13
- const normalizeToPosixPath = (p) => compiled_1.upath.normalizeSafe(path_1.default.normalize(p));
13
+ const normalizeToPosixPath = (p) => compiled_1.upath.normalizeSafe(path_1.default.normalize(p || ''));
14
14
  exports.normalizeToPosixPath = normalizeToPosixPath;
package/dist/storage.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Try to resolve npm package entry file path.
3
+ * @param name - Package name.
4
+ * @param resolvePath - Path to resolve dependencies.
5
+ * @returns Resolved file path.
6
+ */
7
+ export declare const tryResolve: (name: string, resolvePath: string) => string;
8
+ /**
9
+ * Try to resolve npm package, return true if package is installed.
10
+ */
11
+ export declare const isPackageInstalled: (name: string, resolvePaths: string | string[]) => boolean;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPackageInstalled = exports.tryResolve = void 0;
4
+ const ensureArray_1 = require("./ensureArray");
5
+ /**
6
+ * Try to resolve npm package entry file path.
7
+ * @param name - Package name.
8
+ * @param resolvePath - Path to resolve dependencies.
9
+ * @returns Resolved file path.
10
+ */
11
+ const tryResolve = (name, resolvePath) => {
12
+ let filePath = '';
13
+ try {
14
+ filePath = require.resolve(name, { paths: [resolvePath] });
15
+ delete require.cache[filePath];
16
+ }
17
+ catch (err) {
18
+ if (err.code === 'MODULE_NOT_FOUND') {
19
+ throw new Error(`Can not find module ${name}.`);
20
+ }
21
+ throw err;
22
+ }
23
+ return filePath;
24
+ };
25
+ exports.tryResolve = tryResolve;
26
+ /**
27
+ * Try to resolve npm package, return true if package is installed.
28
+ */
29
+ const isPackageInstalled = (name, resolvePaths) => {
30
+ try {
31
+ require.resolve(name, { paths: (0, ensureArray_1.ensureArray)(resolvePaths) });
32
+ return true;
33
+ }
34
+ catch (err) {
35
+ return false;
36
+ }
37
+ };
38
+ exports.isPackageInstalled = isPackageInstalled;
package/dist/watch.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.7.7",
14
+ "version": "1.7.9",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/index.d.ts",
17
17
  "main": "./dist/index.js",
@@ -98,7 +98,7 @@
98
98
  "lodash": "^4.17.21"
99
99
  },
100
100
  "devDependencies": {
101
- "@modern-js/types": "1.5.4",
101
+ "@modern-js/types": "1.5.5",
102
102
  "@scripts/build": "0.0.0",
103
103
  "@scripts/jest-config": "0.0.0",
104
104
  "@types/jest": "^27",