@modern-js/utils 1.1.6-rc.0 → 1.2.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,23 @@
1
1
  # @modern-js/utils
2
2
 
3
- ## 1.1.6-rc.0
3
+ ## 1.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 823809c6: fix: remove plugin-polyfill from app-tools
8
+
9
+ ## 1.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - cfe11628: Make Modern.js self bootstraping
14
+
15
+ ### Patch Changes
16
+
17
+ - 2da09c69: Add "typescript" to the dependency list
18
+ - c3d46ee4: fix: test config invalid
19
+
20
+ ## 1.1.6
4
21
 
5
22
  ### Patch Changes
6
23
 
@@ -158,6 +158,7 @@ export const INTERNAL_PLUGINS = {
158
158
  cli: '@modern-js/plugin-static-hosting/cli'
159
159
  },
160
160
  '@modern-js/plugin-polyfill': {
161
+ cli: '@modern-js/plugin-polyfill/cli',
161
162
  server: '@modern-js/plugin-polyfill'
162
163
  },
163
164
  '@modern-js/plugin-multiprocess': {
@@ -297,7 +298,7 @@ export const PLUGIN_SCHEMAS = {
297
298
  }, {
298
299
  target: 'tools.jest',
299
300
  schema: {
300
- typeof: ['object']
301
+ typeof: ['object', 'function']
301
302
  }
302
303
  }],
303
304
  '@modern-js/plugin-micro-frontend': [{
@@ -1,4 +1,4 @@
1
- import { loadConfig } from 'browserslist/node';
1
+ import { loadConfig } from 'browserslist';
2
2
  export const defaults = ['> 0.01%', 'not dead', 'not op_mini all'];
3
3
  export const getBrowserslist = appDirectory => loadConfig({
4
4
  path: appDirectory
@@ -21,7 +21,7 @@ const getAddressUrls = (protocol = 'http', port) => {
21
21
  let type = 'Network: ';
22
22
  let url = `${protocol}://${detail.address}:${port}`;
23
23
 
24
- if (detail.address.includes(`127.0.0.1`)) {
24
+ if (detail.address.includes(`localhost`)) {
25
25
  type = 'Local: ';
26
26
  url = `${protocol}://localhost:${port}`;
27
27
  }
@@ -179,6 +179,7 @@ const INTERNAL_PLUGINS = {
179
179
  cli: '@modern-js/plugin-static-hosting/cli'
180
180
  },
181
181
  '@modern-js/plugin-polyfill': {
182
+ cli: '@modern-js/plugin-polyfill/cli',
182
183
  server: '@modern-js/plugin-polyfill'
183
184
  },
184
185
  '@modern-js/plugin-multiprocess': {
@@ -319,7 +320,7 @@ const PLUGIN_SCHEMAS = {
319
320
  }, {
320
321
  target: 'tools.jest',
321
322
  schema: {
322
- typeof: ['object']
323
+ typeof: ['object', 'function']
323
324
  }
324
325
  }],
325
326
  '@modern-js/plugin-micro-frontend': [{
@@ -5,12 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getBrowserslist = exports.defaults = void 0;
7
7
 
8
- var _node = require("browserslist/node");
8
+ var _browserslist = require("browserslist");
9
9
 
10
10
  const defaults = ['> 0.01%', 'not dead', 'not op_mini all'];
11
11
  exports.defaults = defaults;
12
12
 
13
- const getBrowserslist = appDirectory => (0, _node.loadConfig)({
13
+ const getBrowserslist = appDirectory => (0, _browserslist.loadConfig)({
14
14
  path: appDirectory
15
15
  }) || defaults;
16
16
 
@@ -35,7 +35,7 @@ const getAddressUrls = (protocol = 'http', port) => {
35
35
  let type = 'Network: ';
36
36
  let url = `${protocol}://${detail.address}:${port}`;
37
37
 
38
- if (detail.address.includes(`127.0.0.1`)) {
38
+ if (detail.address.includes(`localhost`)) {
39
39
  type = 'Local: ';
40
40
  url = `${protocol}://localhost:${port}`;
41
41
  }
@@ -160,6 +160,7 @@ export var INTERNAL_PLUGINS = {
160
160
  cli: '@modern-js/plugin-static-hosting/cli'
161
161
  },
162
162
  '@modern-js/plugin-polyfill': {
163
+ cli: '@modern-js/plugin-polyfill/cli',
163
164
  server: '@modern-js/plugin-polyfill'
164
165
  },
165
166
  '@modern-js/plugin-multiprocess': {
@@ -297,7 +298,7 @@ export var PLUGIN_SCHEMAS = {
297
298
  }, {
298
299
  target: 'tools.jest',
299
300
  schema: {
300
- "typeof": ['object']
301
+ "typeof": ['object', 'function']
301
302
  }
302
303
  }],
303
304
  '@modern-js/plugin-micro-frontend': [{
@@ -1,4 +1,4 @@
1
- import { loadConfig } from 'browserslist/node';
1
+ import { loadConfig } from 'browserslist';
2
2
  export var defaults = ['> 0.01%', 'not dead', 'not op_mini all'];
3
3
  export var getBrowserslist = function getBrowserslist(appDirectory) {
4
4
  return loadConfig({
@@ -39,7 +39,7 @@ var getAddressUrls = function getAddressUrls() {
39
39
  var type = 'Network: ';
40
40
  var url = "".concat(protocol, "://").concat(detail.address, ":").concat(port);
41
41
 
42
- if (detail.address.includes("127.0.0.1")) {
42
+ if (detail.address.includes("localhost")) {
43
43
  type = 'Local: ';
44
44
  url = "".concat(protocol, "://localhost:").concat(port);
45
45
  }
@@ -1,2 +1,2 @@
1
1
  export declare const defaults: string[];
2
- export declare const getBrowserslist: (appDirectory: string) => any;
2
+ export declare const getBrowserslist: (appDirectory: string) => string[];
package/jest.config.js ADDED
@@ -0,0 +1,8 @@
1
+ const sharedConfig = require('@scripts/jest-config');
2
+
3
+ /** @type {import('@jest/types').Config.InitialOptions} */
4
+ module.exports = {
5
+ // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
+ ...sharedConfig,
7
+ rootDir: __dirname,
8
+ };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.1.6-rc.0",
14
+ "version": "1.2.1",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -20,13 +20,20 @@
20
20
  "exports": {
21
21
  ".": {
22
22
  "node": {
23
+ "jsnext:source": "./src/index.ts",
23
24
  "import": "./dist/js/modern/index.js",
24
25
  "require": "./dist/js/node/index.js"
25
26
  },
26
27
  "default": "./dist/js/treeshaking/index.js"
27
28
  },
28
- "./formatWebpackMessages": "./dist/js/treeshaking/formatWebpackMessages.js",
29
- "./constants": "./dist/js/treeshaking/constants.js"
29
+ "./formatWebpackMessages": {
30
+ "jsnext:source": "./src/formatWebpackMessages.ts",
31
+ "default": "./dist/js/treeshaking/formatWebpackMessages.js"
32
+ },
33
+ "./constants": {
34
+ "jsnext:source": "./src/constants.ts",
35
+ "default": "./dist/js/treeshaking/constants.js"
36
+ }
30
37
  },
31
38
  "typesVersions": {
32
39
  "*": {
@@ -55,7 +62,8 @@
55
62
  "strip-ansi": "6.0.0",
56
63
  "upath": "^2.0.1",
57
64
  "yaml": "^1.10.2",
58
- "execa": "5"
65
+ "execa": "5",
66
+ "typescript": "^4"
59
67
  },
60
68
  "devDependencies": {
61
69
  "@types/debug": "^4.1.7",
@@ -64,23 +72,21 @@
64
72
  "@types/jest": "^26",
65
73
  "@types/node": "^14",
66
74
  "@types/recursive-readdir": "^2.2.0",
67
- "typescript": "^4",
68
75
  "webpack": "^5.54.0",
69
- "@modern-js/plugin-testing": "^1.2.2",
70
- "@modern-js/module-tools": "^1.1.4"
71
- },
72
- "peerDependencies": {
73
- "typescript": "^4.4.3"
76
+ "@scripts/build": "0.0.0",
77
+ "jest": "^27",
78
+ "@scripts/jest-config": "0.0.0"
74
79
  },
75
80
  "sideEffects": false,
76
81
  "publishConfig": {
77
82
  "registry": "https://registry.npmjs.org/",
78
- "access": "public"
83
+ "access": "public",
84
+ "types": "./dist/types/index.d.ts"
79
85
  },
80
86
  "scripts": {
81
87
  "new": "modern new",
82
88
  "build": "modern build",
83
- "test": "modern test --passWithNoTests"
89
+ "test": "jest --passWithNoTests"
84
90
  },
85
91
  "readme": "\n<p align=\"center\">\n <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>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
86
92
  }
package/src/constants.ts CHANGED
@@ -119,7 +119,10 @@ export const INTERNAL_PLUGINS: {
119
119
  '@modern-js/plugin-static-hosting': {
120
120
  cli: '@modern-js/plugin-static-hosting/cli',
121
121
  },
122
- '@modern-js/plugin-polyfill': { server: '@modern-js/plugin-polyfill' },
122
+ '@modern-js/plugin-polyfill': {
123
+ cli: '@modern-js/plugin-polyfill/cli',
124
+ server: '@modern-js/plugin-polyfill',
125
+ },
123
126
  '@modern-js/plugin-multiprocess': {
124
127
  cli: '@modern-js/plugin-multiprocess/cli',
125
128
  },
@@ -245,7 +248,7 @@ export const PLUGIN_SCHEMAS = {
245
248
  },
246
249
  {
247
250
  target: 'tools.jest',
248
- schema: { typeof: ['object'] },
251
+ schema: { typeof: ['object', 'function'] },
249
252
  },
250
253
  ],
251
254
  '@modern-js/plugin-micro-frontend': [
@@ -1,4 +1,4 @@
1
- import { loadConfig } from 'browserslist/node';
1
+ import { loadConfig } from 'browserslist';
2
2
 
3
3
  export const defaults = ['> 0.01%', 'not dead', 'not op_mini all'];
4
4
 
@@ -34,7 +34,7 @@ const getAddressUrls = (protocol = 'http', port: number) => {
34
34
  (memo: { type: string; url: string }[], detail) => {
35
35
  let type = 'Network: ';
36
36
  let url = `${protocol}://${detail.address}:${port}`;
37
- if (detail.address.includes(`127.0.0.1`)) {
37
+ if (detail.address.includes(`localhost`)) {
38
38
  type = 'Local: ';
39
39
  url = `${protocol}://localhost:${port}`;
40
40
  }
@@ -1,4 +1,4 @@
1
- import { applyOptionsChain } from '@/applyOptionsChain';
1
+ import { applyOptionsChain } from '../src/applyOptionsChain';
2
2
 
3
3
  describe('apply options chain', () => {
4
4
  test(`should return default options`, () => {
@@ -1,5 +1,5 @@
1
1
  import path from 'path';
2
- import { compatRequire } from '@/compatRequire';
2
+ import { compatRequire } from '../src/compatRequire';
3
3
 
4
4
  describe('compat require', () => {
5
5
  const fixturePath = path.resolve(__dirname, './fixtures/compat-require');
@@ -1,5 +1,6 @@
1
1
  import debug from 'debug';
2
- import { createDebugger } from '@/debug';
2
+ import stripAnsi from 'strip-ansi';
3
+ import { createDebugger } from '../src/debug';
3
4
 
4
5
  describe('debug utility', () => {
5
6
  test('should return file path', () => {
@@ -10,7 +11,8 @@ describe('debug utility', () => {
10
11
  debug.enable('modern-js:test2');
11
12
 
12
13
  debug.log = (...args) => {
13
- expect(args[0]).toContain('modern-js:test2 22222');
14
+ // XXX: args[0] 的内容有时候是 ' \x1B[38;5;167;1mmodern-js:test2 \x1B[0m22222' 这种格式
15
+ expect(stripAnsi(args[0])).toContain('modern-js:test2 22222');
14
16
  };
15
17
 
16
18
  debug1('11111');
@@ -1,5 +1,5 @@
1
1
  import path from 'path';
2
- import { ensureAbsolutePath } from '@/ensureAbsolutePath';
2
+ import { ensureAbsolutePath } from '../src/ensureAbsolutePath';
3
3
 
4
4
  describe('ensure absolute file path', () => {
5
5
  test('should return filePath directly', () => {
@@ -1,5 +1,5 @@
1
1
  import path from 'path';
2
- import { findExists } from '@/findExists';
2
+ import { findExists } from '../src/findExists';
3
3
 
4
4
  describe('find first exists file', () => {
5
5
  const fixturePath = path.resolve(__dirname, './fixtures/file-exists');
@@ -1,5 +1,5 @@
1
1
  import path from 'path';
2
- import { getBrowserslist, defaults } from '@/getBrowserslist';
2
+ import { getBrowserslist, defaults } from '../src/getBrowserslist';
3
3
 
4
4
  describe('get browserslist', () => {
5
5
  const fixture = path.resolve(__dirname, './fixtures/browserlist');
@@ -1,4 +1,4 @@
1
- import { getCacheIdentifier } from '@/getCacheIdentifier';
1
+ import { getCacheIdentifier } from '../src/getCacheIdentifier';
2
2
 
3
3
  describe('get cache identifier', () => {
4
4
  test('should use package name and version', () => {
@@ -1,4 +1,4 @@
1
- import { getEntryOptions } from '@/getEntryOptions';
1
+ import { getEntryOptions } from '../src/getEntryOptions';
2
2
 
3
3
  describe('get entry options', () => {
4
4
  test('should return default options', () => {
@@ -1,4 +1,4 @@
1
- import { canUseNpm, canUsePnpm, canUseYarn } from '@/index';
1
+ import { canUseNpm, canUsePnpm, canUseYarn } from '../src';
2
2
 
3
3
  describe('test generator utils', () => {
4
4
  test('test canUseNpm', async () => {
@@ -1,4 +1,4 @@
1
- import { logger } from '@/logger';
1
+ import { logger } from '../src/logger';
2
2
 
3
3
  describe('logger', () => {
4
4
  test('should log', () => {
@@ -2,7 +2,7 @@ import {
2
2
  removeLeadingSlash,
3
3
  removeSlash,
4
4
  removeTailSlash,
5
- } from '@/removeSlash';
5
+ } from '../src/removeSlash';
6
6
 
7
7
  describe('remove slash', () => {
8
8
  test(`should remove leading slash`, () => {
@@ -5,9 +5,7 @@
5
5
  "jsx": "preserve",
6
6
  "baseUrl": "./",
7
7
  "isolatedModules": true,
8
- "paths": {
9
- "@/*": ["../src/*"]
10
- },
8
+ "paths": {},
11
9
  "types": ["node", "jest"]
12
10
  }
13
11
  }
package/tsconfig.json CHANGED
@@ -6,9 +6,7 @@
6
6
  "jsx": "preserve",
7
7
  "baseUrl": "./",
8
8
  "isolatedModules": true,
9
- "paths": {
10
- "@/*": ["./src/*"]
11
- }
9
+ "paths": {}
12
10
  },
13
11
  "include": ["src"]
14
12
  }