@modern-js/plugin-polyfill 1.2.4 → 1.2.7

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,5 +1,38 @@
1
1
  # @modern-js/plugin-polyfill
2
2
 
3
+ ## 1.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 6fa74d5f: add internal metrics and logger
8
+ - Updated dependencies [0ee4bb4e]
9
+ - Updated dependencies [6fa74d5f]
10
+ - @modern-js/utils@1.7.0
11
+
12
+ ## 1.2.6
13
+
14
+ ### Patch Changes
15
+
16
+ - 592edabc: feat: prebundle url-join,mime-types,json5,fast-glob,globby,ora,inquirer
17
+ - 895fa0ff: chore: using "workspace:\*" in devDependencies
18
+ - Updated dependencies [2d155c4c]
19
+ - Updated dependencies [123e432d]
20
+ - Updated dependencies [e5a9b26d]
21
+ - Updated dependencies [0b26b93b]
22
+ - Updated dependencies [123e432d]
23
+ - Updated dependencies [f9f66ef9]
24
+ - Updated dependencies [592edabc]
25
+ - Updated dependencies [895fa0ff]
26
+ - Updated dependencies [3578913e]
27
+ - Updated dependencies [1c3beab3]
28
+ - @modern-js/utils@1.6.0
29
+
30
+ ## 1.2.5
31
+
32
+ ### Patch Changes
33
+
34
+ - 60f7d8bf: feat: add tests dir to npmignore
35
+
3
36
  ## 1.2.4
4
37
 
5
38
  ### Patch Changes
@@ -1,12 +1,12 @@
1
1
  import { getPolyfillString } from '@modern-js/polyfill-lib';
2
- import mime from 'mime-types';
2
+ import { mime } from '@modern-js/utils';
3
3
  import Parser from 'ua-parser-js';
4
4
  import { defaultFeatures, defaultPolyfill } from "./const";
5
5
  import PolyfillCache, { generateCacheKey } from "./libs/cache";
6
6
  export default (() => ({
7
7
  name: '@modern-js/plugin-polyfill',
8
8
  setup: () => ({
9
- preServerInit(_) {
9
+ beforeProdServer(_) {
10
10
  const cache = new PolyfillCache();
11
11
  const route = defaultPolyfill;
12
12
  const features = defaultFeatures;
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var _polyfillLib = require("@modern-js/polyfill-lib");
9
9
 
10
- var _mimeTypes = _interopRequireDefault(require("mime-types"));
10
+ var _utils = require("@modern-js/utils");
11
11
 
12
12
  var _uaParserJs = _interopRequireDefault(require("ua-parser-js"));
13
13
 
@@ -24,7 +24,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
24
24
  var _default = () => ({
25
25
  name: '@modern-js/plugin-polyfill',
26
26
  setup: () => ({
27
- preServerInit(_) {
27
+ beforeProdServer(_) {
28
28
  const cache = new _cache.default();
29
29
  const route = _const.defaultPolyfill;
30
30
  const features = _const.defaultFeatures;
@@ -55,7 +55,7 @@ var _default = () => ({
55
55
  const matched = cache.get(cacheKey);
56
56
 
57
57
  if (matched) {
58
- context.res.setHeader('content-type', _mimeTypes.default.contentType('js'));
58
+ context.res.setHeader('content-type', _utils.mime.contentType('js'));
59
59
  return context.res.end(matched);
60
60
  }
61
61
 
@@ -65,7 +65,7 @@ var _default = () => ({
65
65
  features
66
66
  });
67
67
  cache.set(cacheKey, polyfill);
68
- context.res.setHeader('content-type', _mimeTypes.default.contentType('js'));
68
+ context.res.setHeader('content-type', _utils.mime.contentType('js'));
69
69
  return context.res.end(polyfill);
70
70
  };
71
71
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.4",
14
+ "version": "1.2.7",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -37,23 +37,22 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@babel/runtime": "^7",
40
+ "@modern-js/utils": "^1.7.0",
40
41
  "@modern-js/polyfill-lib": "^1.0.0",
41
42
  "lru-cache": "^6.0.0",
42
- "mime-types": "^2.1.32",
43
43
  "ua-parser-js": "^0.7.28"
44
44
  },
45
45
  "devDependencies": {
46
- "@modern-js/server-core": "1.2.5",
47
- "@modern-js/types": "^1.3.6",
46
+ "@modern-js/server-core": "1.3.3",
47
+ "@modern-js/types": "1.5.2",
48
48
  "@types/jest": "^26",
49
49
  "@types/lru-cache": "^5.1.1",
50
- "@types/mime-types": "^2.1.1",
51
50
  "@types/node": "^14",
52
51
  "@types/react": "^17",
53
52
  "@types/react-dom": "^17",
54
53
  "@types/ua-parser-js": "^0.7.36",
55
54
  "typescript": "^4",
56
- "@modern-js/core": "1.6.1",
55
+ "@modern-js/core": "1.10.0",
57
56
  "@scripts/build": "0.0.0",
58
57
  "jest": "^27",
59
58
  "@scripts/jest-config": "0.0.0"
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- extends: ['@modern-js'],
3
- parserOptions: {
4
- project: require.resolve('./tsconfig.json'),
5
- },
6
- };
@@ -1,53 +0,0 @@
1
- import type { NormalizedConfig } from '@modern-js/core';
2
- import cliPugin from '../src/cli';
3
- import serverPlugin from '../src';
4
- import { defaultPolyfill } from '../src/const';
5
-
6
- describe('plugin-static-hosting', () => {
7
- it('cli', () => {
8
- expect(cliPugin).toBeDefined();
9
- const instance = cliPugin();
10
- expect(instance.name).toBe('@modern-js/plugin-polyfill');
11
-
12
- const hooks: any = instance.setup?.({
13
- useResolvedConfigContext: () => {
14
- return {
15
- output: {},
16
- } as NormalizedConfig;
17
- },
18
- } as any);
19
-
20
- const params = { entrypoint: [], partials: [] };
21
- expect(hooks.htmlPartials(params)).toEqual(params);
22
- });
23
-
24
- it('server', async () => {
25
- expect(serverPlugin).toBeDefined();
26
- const instance = serverPlugin();
27
- expect(instance.name).toBe('@modern-js/plugin-polyfill');
28
-
29
- const hooks: any = instance.setup?.({} as any);
30
- const fn = hooks.preServerInit();
31
- expect(typeof fn).toBe('function');
32
-
33
- const errorContext = { url: '' };
34
- expect(await fn(errorContext, () => false)).toBeFalsy();
35
-
36
- const context = {
37
- url: defaultPolyfill,
38
- res: {
39
- setHeader: () => false,
40
- end: (result: string) => result,
41
- },
42
- headers: {
43
- 'user-agent':
44
- 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36',
45
- },
46
- };
47
-
48
- const res = await fn(context);
49
- expect(res).toMatch('modern polyfill');
50
- const res1 = await fn(context);
51
- expect(res1).toMatch('modern polyfill');
52
- });
53
- });
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true
8
- }
9
- }