@modern-js/utils 1.3.6 → 1.3.7

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @modern-js/utils
2
2
 
3
+ ## 1.3.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 132f7b53: feat: move config declarations to @modern-js/core
8
+
3
9
  ## 1.3.6
4
10
 
5
11
  ### Patch Changes
@@ -18,9 +18,7 @@ export function isPlainObject(obj) {
18
18
  return isObject(obj) && Object.prototype.toString.call(obj) === '[object Object]';
19
19
  }
20
20
  export function isPromise(obj) {
21
- /* eslint-disable promise/prefer-await-to-then */
22
21
  return Boolean(obj) && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
23
- /* eslint-enable promise/prefer-await-to-then */
24
22
  }
25
23
  export function isRegExp(obj) {
26
24
  return Object.prototype.toString.call(obj) === '[object RegExp]';
@@ -38,9 +38,7 @@ function isPlainObject(obj) {
38
38
  }
39
39
 
40
40
  function isPromise(obj) {
41
- /* eslint-disable promise/prefer-await-to-then */
42
41
  return Boolean(obj) && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
43
- /* eslint-enable promise/prefer-await-to-then */
44
42
  }
45
43
 
46
44
  function isRegExp(obj) {
@@ -20,9 +20,7 @@ export function isPlainObject(obj) {
20
20
  return isObject(obj) && Object.prototype.toString.call(obj) === '[object Object]';
21
21
  }
22
22
  export function isPromise(obj) {
23
- /* eslint-disable promise/prefer-await-to-then */
24
23
  return Boolean(obj) && (_typeof(obj) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
25
- /* eslint-enable promise/prefer-await-to-then */
26
24
  }
27
25
  export function isRegExp(obj) {
28
26
  return Object.prototype.toString.call(obj) === '[object RegExp]';
@@ -6,11 +6,11 @@
6
6
  * https://github.com/facebook/create-react-app/blob/master/LICENSE
7
7
  */
8
8
  import { StatsCompilation } from 'webpack';
9
- import type { ProxyDetail, ProxyOptions } from '@modern-js/types';
9
+ import type { ProxyDetail, BffProxyOptions } from '@modern-js/types';
10
10
  declare function formatWebpackMessages(json: StatsCompilation): {
11
11
  errors: string[];
12
12
  warnings: string[];
13
13
  };
14
14
  export { formatWebpackMessages };
15
- declare function formatProxyOptions(proxyOptions: ProxyOptions): ProxyDetail[];
15
+ declare function formatProxyOptions(proxyOptions: BffProxyOptions): ProxyDetail[];
16
16
  export { formatProxyOptions };
package/jest.config.js CHANGED
@@ -2,7 +2,6 @@ const sharedConfig = require('@scripts/jest-config');
2
2
 
3
3
  /** @type {import('@jest/types').Config.InitialOptions} */
4
4
  module.exports = {
5
- // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
5
  ...sharedConfig,
7
6
  rootDir: __dirname,
8
7
  modulePathIgnorePatterns: [
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.3.6",
14
+ "version": "1.3.7",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -52,6 +52,7 @@
52
52
  "chalk": "^4.1.2",
53
53
  "chokidar": "^3.5.2",
54
54
  "debug": "^4.3.2",
55
+ "execa": "5",
55
56
  "filesize": "^7.0.0",
56
57
  "fs-extra": "^10.0.0",
57
58
  "glob": "^7.1.7",
@@ -60,23 +61,22 @@
60
61
  "pkg-up": "^3.1.0",
61
62
  "recursive-readdir": "^2.2.2",
62
63
  "strip-ansi": "6.0.0",
64
+ "typescript": "^4",
63
65
  "upath": "^2.0.1",
64
- "yaml": "^1.10.2",
65
- "execa": "5",
66
- "typescript": "^4"
66
+ "yaml": "^1.10.2"
67
67
  },
68
68
  "devDependencies": {
69
+ "@modern-js/types": "^1.3.6",
70
+ "@scripts/build": "0.0.0",
71
+ "@scripts/jest-config": "0.0.0",
69
72
  "@types/debug": "^4.1.7",
70
73
  "@types/fs-extra": "^9.0.12",
71
74
  "@types/glob": "^7.1.4",
72
75
  "@types/jest": "^26",
73
76
  "@types/node": "^14",
74
77
  "@types/recursive-readdir": "^2.2.0",
75
- "webpack": "^5.54.0",
76
- "@scripts/build": "0.0.0",
77
78
  "jest": "^27",
78
- "@scripts/jest-config": "0.0.0",
79
- "@modern-js/types": "^1.3.5"
79
+ "webpack": "^5.71.0"
80
80
  },
81
81
  "sideEffects": false,
82
82
  "publishConfig": {
@@ -0,0 +1,27 @@
1
+ import { isEmpty, isFastRefresh } from '../src/is';
2
+
3
+ describe('validate', () => {
4
+ it('should validate empty object correctly', () => {
5
+ expect(isEmpty({})).toBeTruthy();
6
+ expect(isEmpty({ foo: 'bar' })).toBeFalsy();
7
+ });
8
+
9
+ it('should validate fast refresh correctly', () => {
10
+ const { NODE_ENV, FAST_REFRESH } = process.env;
11
+
12
+ process.env.NODE_ENV = 'development';
13
+ process.env.FAST_REFRESH = 'true';
14
+ expect(isFastRefresh()).toBeTruthy();
15
+
16
+ process.env.NODE_ENV = 'production';
17
+ process.env.FAST_REFRESH = 'true';
18
+ expect(isFastRefresh()).toBeFalsy();
19
+
20
+ process.env.NODE_ENV = 'development';
21
+ process.env.FAST_REFRESH = 'false';
22
+ expect(isFastRefresh()).toBeFalsy();
23
+
24
+ process.env.NODE_ENV = NODE_ENV;
25
+ process.env.FAST_REFRESH = FAST_REFRESH;
26
+ });
27
+ });
@@ -0,0 +1,19 @@
1
+ import { isNodeJS, isBrowser } from '../src/is/platform';
2
+
3
+ describe('validate platform', () => {
4
+ it('should validate Node.js correctly', () => {
5
+ expect(isNodeJS()).toBeTruthy();
6
+ });
7
+
8
+ it('should validate browser correctly', () => {
9
+ const windowSpy = jest.spyOn(window, 'window', 'get');
10
+
11
+ windowSpy.mockImplementation((): any => undefined);
12
+ expect(isBrowser()).toBeFalsy();
13
+
14
+ windowSpy.mockImplementation((): any => global);
15
+ expect(isBrowser()).toBeTruthy();
16
+
17
+ windowSpy.mockRestore();
18
+ });
19
+ });