@modern-js/plugin-polyfill 1.0.0-alpha.3

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 ADDED
@@ -0,0 +1,9 @@
1
+ # @modern-js/plugin-polyfill
2
+
3
+ ## 1.0.0-alpha.3
4
+ ### Patch Changes
5
+
6
+ - feat: initial
7
+ - Updated dependencies [undefined]
8
+ - @modern-js/core@1.0.0-alpha.3
9
+ - @modern-js/server-plugin@1.0.0-alpha.3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Modern.js
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+
2
+ <p align="center">
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
+ </p>
5
+
6
+ <p align="center">现代 Web 工程体系</p>
7
+
8
+ ## 背景
9
+ - [迈入现代 Web 开发](https://zhuanlan.zhihu.com/p/386607009)
10
+ - [现代 Web 开发者问卷调查报告](https://zhuanlan.zhihu.com/p/403206195)
11
+
12
+ ## 计划
13
+
14
+ Modern.js 的 1.0.0.rc 版已经发到 npm,目前在做测试改进,README 文档之后统一提供(现阶段加入测试和开发,可以发 [issue](https://github.com/modern-js-dev/modern.js/issues) 留微信联系),完整的文档站计划在10月14日上线
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
@@ -0,0 +1,25 @@
1
+ import { createPlugin, useResolvedConfigContext } from '@modern-js/core';
2
+ import { defaultPolyfill } from "./const";
3
+ export default createPlugin(() => ({
4
+ htmlPartials({
5
+ entrypoint,
6
+ partials
7
+ }) {
8
+ // eslint-disable-next-line react-hooks/rules-of-hooks
9
+ const {
10
+ value: resolvedConfig
11
+ } = useResolvedConfigContext();
12
+
13
+ if (resolvedConfig.output.polyfill === 'ua') {
14
+ partials.top.push(`<script src="${defaultPolyfill}" crossorigin></script>`);
15
+ }
16
+
17
+ return {
18
+ partials,
19
+ entrypoint
20
+ };
21
+ }
22
+
23
+ }), {
24
+ name: '@modern-js/plugin-polyfill'
25
+ });
@@ -0,0 +1,6 @@
1
+ export const defaultPolyfill = '/__polyfill__';
2
+ export const defaultFeatures = {
3
+ es6: {
4
+ flags: ['gated']
5
+ }
6
+ };
@@ -0,0 +1,56 @@
1
+ import { createPlugin } from '@modern-js/server-plugin';
2
+ import { getPolyfillString } from '@modern-js/polyfill-lib';
3
+ import mime from 'mime-types';
4
+ import Parser from 'ua-parser-js';
5
+ import { defaultFeatures, defaultPolyfill } from "./const";
6
+ import PolyfillCache, { generateCacheKey } from "./libs/cache";
7
+ export default createPlugin(() => ({
8
+ preServerInit(_) {
9
+ const cache = new PolyfillCache();
10
+ const route = defaultPolyfill;
11
+ const features = defaultFeatures;
12
+ const minify = process.env.NODE_ENV === 'production';
13
+ const featureDig = Object.keys(features).map(name => {
14
+ const {
15
+ flags = ['gated']
16
+ } = features[name];
17
+ const flagStr = flags.join(',');
18
+ return `${name}-${flagStr}`;
19
+ }).join(',');
20
+ return async (context, next) => {
21
+ if (context.url !== route) {
22
+ return next();
23
+ }
24
+
25
+ const parsedUA = Parser(context.headers['user-agent']);
26
+ const {
27
+ name = '',
28
+ version = ''
29
+ } = parsedUA.browser;
30
+ const cacheKey = generateCacheKey({
31
+ name,
32
+ version,
33
+ features: featureDig,
34
+ minify
35
+ });
36
+ const matched = cache.get(cacheKey);
37
+
38
+ if (matched) {
39
+ context.res.setHeader('content-type', mime.contentType('js'));
40
+ return context.res.end(matched);
41
+ }
42
+
43
+ const polyfill = await getPolyfillString({
44
+ uaString: context.headers['user-agent'],
45
+ minify,
46
+ features
47
+ });
48
+ cache.set(cacheKey, polyfill);
49
+ context.res.setHeader('content-type', mime.contentType('js'));
50
+ return context.res.end(polyfill);
51
+ };
52
+ }
53
+
54
+ }), {
55
+ name: '@modern-js/plugin-polyfill'
56
+ });
@@ -0,0 +1,41 @@
1
+ import crypto from 'crypto';
2
+ import LRUCache from 'lru-cache';
3
+ const KB = 1024;
4
+ const MB = 1024 * KB;
5
+ const keyCache = new LRUCache(10000);
6
+ export const generateCacheKey = options => {
7
+ const {
8
+ name,
9
+ version,
10
+ features,
11
+ minify
12
+ } = options;
13
+ const str = `${name}-${version}-${Number(minify)}-${features}`;
14
+ const matched = keyCache.get(str);
15
+
16
+ if (matched) {
17
+ return matched;
18
+ }
19
+
20
+ const hash = crypto.createHmac('sha256', '^polyfill$').update(str).digest('hex');
21
+ keyCache.set(str, hash);
22
+ return hash;
23
+ };
24
+ export default class Cache {
25
+ constructor() {
26
+ this.caches = void 0;
27
+ this.caches = new LRUCache({
28
+ max: 200 * MB,
29
+ length: v => v.length
30
+ });
31
+ }
32
+
33
+ get(hash) {
34
+ return this.caches.get(hash);
35
+ }
36
+
37
+ set(hash, content) {
38
+ this.caches.set(hash, content);
39
+ }
40
+
41
+ }
File without changes
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _core = require("@modern-js/core");
9
+
10
+ var _const = require("./const");
11
+
12
+ var _default = (0, _core.createPlugin)(() => ({
13
+ htmlPartials({
14
+ entrypoint,
15
+ partials
16
+ }) {
17
+ // eslint-disable-next-line react-hooks/rules-of-hooks
18
+ const {
19
+ value: resolvedConfig
20
+ } = (0, _core.useResolvedConfigContext)();
21
+
22
+ if (resolvedConfig.output.polyfill === 'ua') {
23
+ partials.top.push(`<script src="${_const.defaultPolyfill}" crossorigin></script>`);
24
+ }
25
+
26
+ return {
27
+ partials,
28
+ entrypoint
29
+ };
30
+ }
31
+
32
+ }), {
33
+ name: '@modern-js/plugin-polyfill'
34
+ });
35
+
36
+ exports.default = _default;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.defaultPolyfill = exports.defaultFeatures = void 0;
7
+ const defaultPolyfill = '/__polyfill__';
8
+ exports.defaultPolyfill = defaultPolyfill;
9
+ const defaultFeatures = {
10
+ es6: {
11
+ flags: ['gated']
12
+ }
13
+ };
14
+ exports.defaultFeatures = defaultFeatures;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _serverPlugin = require("@modern-js/server-plugin");
9
+
10
+ var _polyfillLib = require("@modern-js/polyfill-lib");
11
+
12
+ var _mimeTypes = _interopRequireDefault(require("mime-types"));
13
+
14
+ var _uaParserJs = _interopRequireDefault(require("ua-parser-js"));
15
+
16
+ var _const = require("./const");
17
+
18
+ var _cache = _interopRequireWildcard(require("./libs/cache"));
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
26
+ var _default = (0, _serverPlugin.createPlugin)(() => ({
27
+ preServerInit(_) {
28
+ const cache = new _cache.default();
29
+ const route = _const.defaultPolyfill;
30
+ const features = _const.defaultFeatures;
31
+ const minify = process.env.NODE_ENV === 'production';
32
+ const featureDig = Object.keys(features).map(name => {
33
+ const {
34
+ flags = ['gated']
35
+ } = features[name];
36
+ const flagStr = flags.join(',');
37
+ return `${name}-${flagStr}`;
38
+ }).join(',');
39
+ return async (context, next) => {
40
+ if (context.url !== route) {
41
+ return next();
42
+ }
43
+
44
+ const parsedUA = (0, _uaParserJs.default)(context.headers['user-agent']);
45
+ const {
46
+ name = '',
47
+ version = ''
48
+ } = parsedUA.browser;
49
+ const cacheKey = (0, _cache.generateCacheKey)({
50
+ name,
51
+ version,
52
+ features: featureDig,
53
+ minify
54
+ });
55
+ const matched = cache.get(cacheKey);
56
+
57
+ if (matched) {
58
+ context.res.setHeader('content-type', _mimeTypes.default.contentType('js'));
59
+ return context.res.end(matched);
60
+ }
61
+
62
+ const polyfill = await (0, _polyfillLib.getPolyfillString)({
63
+ uaString: context.headers['user-agent'],
64
+ minify,
65
+ features
66
+ });
67
+ cache.set(cacheKey, polyfill);
68
+ context.res.setHeader('content-type', _mimeTypes.default.contentType('js'));
69
+ return context.res.end(polyfill);
70
+ };
71
+ }
72
+
73
+ }), {
74
+ name: '@modern-js/plugin-polyfill'
75
+ });
76
+
77
+ exports.default = _default;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.generateCacheKey = exports.default = void 0;
7
+
8
+ var _crypto = _interopRequireDefault(require("crypto"));
9
+
10
+ var _lruCache = _interopRequireDefault(require("lru-cache"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const KB = 1024;
15
+ const MB = 1024 * KB;
16
+ const keyCache = new _lruCache.default(10000);
17
+
18
+ const generateCacheKey = options => {
19
+ const {
20
+ name,
21
+ version,
22
+ features,
23
+ minify
24
+ } = options;
25
+ const str = `${name}-${version}-${Number(minify)}-${features}`;
26
+ const matched = keyCache.get(str);
27
+
28
+ if (matched) {
29
+ return matched;
30
+ }
31
+
32
+ const hash = _crypto.default.createHmac('sha256', '^polyfill$').update(str).digest('hex');
33
+
34
+ keyCache.set(str, hash);
35
+ return hash;
36
+ };
37
+
38
+ exports.generateCacheKey = generateCacheKey;
39
+
40
+ class Cache {
41
+ constructor() {
42
+ this.caches = void 0;
43
+ this.caches = new _lruCache.default({
44
+ max: 200 * MB,
45
+ length: v => v.length
46
+ });
47
+ }
48
+
49
+ get(hash) {
50
+ return this.caches.get(hash);
51
+ }
52
+
53
+ set(hash, content) {
54
+ this.caches.set(hash, content);
55
+ }
56
+
57
+ }
58
+
59
+ exports.default = Cache;
File without changes
@@ -0,0 +1,15 @@
1
+ declare const _default: import("@modern-js/plugin").AsyncPlugin<Partial<import("@modern-js/plugin").Progresses2Threads<{
2
+ config: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
3
+ validateSchema: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
4
+ prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
5
+ commands: import("@modern-js/plugin").AsyncWorkflow<{
6
+ program: import("commander").Command;
7
+ }, void>;
8
+ watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
9
+ fileChange: import("@modern-js/plugin").AsyncWorkflow<{
10
+ filename: string;
11
+ }, void>;
12
+ beforeExit: import("@modern-js/plugin").AsyncWorkflow<void, void>;
13
+ } & import("@modern-js/plugin").ClearDraftProgress<import("@modern-js/core").Hooks>>>>;
14
+
15
+ export default _default;
@@ -0,0 +1,4 @@
1
+ export declare const defaultPolyfill = "/__polyfill__";
2
+ export declare const defaultFeatures: Record<string, {
3
+ flags: string[];
4
+ }>;
@@ -0,0 +1,3 @@
1
+ declare const _default: any;
2
+
3
+ export default _default;
@@ -0,0 +1,14 @@
1
+ declare type CacheQueryOptions = {
2
+ features: string;
3
+ minify: boolean;
4
+ name: string;
5
+ version: string;
6
+ };
7
+ export declare const generateCacheKey: (options: CacheQueryOptions) => string;
8
+ export default class Cache {
9
+ private readonly caches;
10
+ constructor();
11
+ get(hash: string): string | undefined;
12
+ set(hash: string, content: string): void;
13
+ }
14
+ export {};
@@ -0,0 +1,9 @@
1
+ export declare type ServerPolyfill = {
2
+ polyfill: {
3
+ route: string;
4
+ features: Record<string, {
5
+ flags: string[];
6
+ }>;
7
+ minify: boolean;
8
+ };
9
+ };
@@ -0,0 +1,2 @@
1
+ /** @type {import('@modern-js/module-tools').UserConfig} */
2
+ module.exports = {};
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@modern-js/plugin-polyfill",
3
+ "version": "1.0.0-alpha.3",
4
+ "jsnext:source": "./src/index.ts",
5
+ "types": "./dist/types/index.d.ts",
6
+ "main": "./dist/js/node/index.js",
7
+ "module": "./dist/js/treeshaking/index.js",
8
+ "jsnext:modern": "./dist/js/modern/index.js",
9
+ "exports": {
10
+ ".": {
11
+ "node": {
12
+ "import": "./dist/js/modern/index.js",
13
+ "require": "./dist/js/node/index.js"
14
+ },
15
+ "default": "./dist/js/treeshaking/index.js"
16
+ },
17
+ "./cli": {
18
+ "node": {
19
+ "import": "./dist/js/node/cli.js",
20
+ "require": "./dist/js/node/cli.js"
21
+ },
22
+ "default": "./dist/js/node/cli.js"
23
+ }
24
+ },
25
+ "dependencies": {
26
+ "@babel/runtime": "^7",
27
+ "@modern-js/core": "^1.0.0-alpha.3",
28
+ "@modern-js/polyfill-lib": "^1.0.0-rc.0",
29
+ "@modern-js/server-plugin": "^1.0.0-alpha.3",
30
+ "lru-cache": "^6.0.0",
31
+ "mime-types": "^2.1.32",
32
+ "ua-parser-js": "^0.7.28"
33
+ },
34
+ "devDependencies": {
35
+ "@modern-js/types": "^1.0.0-alpha.3",
36
+ "@types/jest": "^26",
37
+ "@types/lru-cache": "^5.1.1",
38
+ "@types/mime-types": "^2.1.1",
39
+ "@types/node": "^14",
40
+ "@types/react": "^17",
41
+ "@types/react-dom": "^17",
42
+ "@types/ua-parser-js": "^0.7.36",
43
+ "typescript": "^4",
44
+ "@modern-js/plugin-testing": "^1.0.0-alpha.3",
45
+ "@modern-js/module-tools": "^1.0.0-alpha.3"
46
+ },
47
+ "sideEffects": false,
48
+ "modernConfig": {
49
+ "output": {
50
+ "packageMode": "node-js"
51
+ }
52
+ },
53
+ "scripts": {
54
+ "new": "modern new",
55
+ "build": "modern build",
56
+ "dev": "modern build --watch",
57
+ "test": "modern test --passWithNoTests"
58
+ }
59
+ }
package/src/cli.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { createPlugin, useResolvedConfigContext } from '@modern-js/core';
2
+ import { defaultPolyfill } from './const';
3
+
4
+ export default createPlugin(
5
+ () =>
6
+ ({
7
+ htmlPartials({ entrypoint, partials }: any) {
8
+ // eslint-disable-next-line react-hooks/rules-of-hooks
9
+ const { value: resolvedConfig } = useResolvedConfigContext();
10
+ if (resolvedConfig.output.polyfill === 'ua') {
11
+ partials.top.push(
12
+ `<script src="${defaultPolyfill}" crossorigin></script>`,
13
+ );
14
+ }
15
+
16
+ return { partials, entrypoint };
17
+ },
18
+ } as any),
19
+ { name: '@modern-js/plugin-polyfill' },
20
+ );
package/src/const.ts ADDED
@@ -0,0 +1,5 @@
1
+ export const defaultPolyfill = '/__polyfill__';
2
+
3
+ export const defaultFeatures: Record<string, { flags: string[] }> = {
4
+ es6: { flags: ['gated'] },
5
+ };
@@ -0,0 +1,7 @@
1
+ declare module '@modern-js/polyfill-lib' {
2
+ export const getPolyfillString: (options: {
3
+ uaString: string;
4
+ minify: boolean;
5
+ features: Record<string, { flags: string[] }>;
6
+ }) => Promise<string>;
7
+ }
package/src/index.ts ADDED
@@ -0,0 +1,66 @@
1
+ import { createPlugin } from '@modern-js/server-plugin';
2
+ import { NextFunction, ModernServerContext } from '@modern-js/types/server';
3
+ import type { NormalizedConfig } from '@modern-js/core';
4
+ import { getPolyfillString } from '@modern-js/polyfill-lib';
5
+ import mime from 'mime-types';
6
+ import Parser from 'ua-parser-js';
7
+ import { defaultFeatures, defaultPolyfill } from './const';
8
+ import PolyfillCache, { generateCacheKey } from './libs/cache';
9
+
10
+ export default createPlugin(
11
+ () => ({
12
+ preServerInit(_: NormalizedConfig) {
13
+ const cache = new PolyfillCache();
14
+ const route = defaultPolyfill;
15
+ const features = defaultFeatures;
16
+ const minify = process.env.NODE_ENV === 'production';
17
+
18
+ const featureDig = Object.keys(features)
19
+ .map(name => {
20
+ const { flags = ['gated'] } = features[name];
21
+ const flagStr = flags.join(',');
22
+
23
+ return `${name}-${flagStr}`;
24
+ })
25
+ .join(',');
26
+
27
+ return async (context: ModernServerContext, next: NextFunction) => {
28
+ if (context.url !== route) {
29
+ return next();
30
+ }
31
+
32
+ const parsedUA = Parser(context.headers['user-agent']);
33
+ const { name = '', version = '' } = parsedUA.browser;
34
+
35
+ const cacheKey = generateCacheKey({
36
+ name,
37
+ version,
38
+ features: featureDig,
39
+ minify,
40
+ });
41
+ const matched = cache.get(cacheKey);
42
+ if (matched) {
43
+ context.res.setHeader(
44
+ 'content-type',
45
+ mime.contentType('js') as string,
46
+ );
47
+ return context.res.end(matched);
48
+ }
49
+
50
+ const polyfill = await getPolyfillString({
51
+ uaString: context.headers['user-agent'] as string,
52
+ minify,
53
+ features,
54
+ });
55
+
56
+ cache.set(cacheKey, polyfill);
57
+
58
+ context.res.setHeader('content-type', mime.contentType('js') as string);
59
+ return context.res.end(polyfill);
60
+ };
61
+ },
62
+ }),
63
+ {
64
+ name: '@modern-js/plugin-polyfill',
65
+ },
66
+ ) as any;
@@ -0,0 +1,49 @@
1
+ import crypto from 'crypto';
2
+ import LRUCache from 'lru-cache';
3
+
4
+ type CacheQueryOptions = {
5
+ features: string;
6
+ minify: boolean;
7
+ name: string;
8
+ version: string;
9
+ };
10
+
11
+ const KB = 1024;
12
+ const MB = 1024 * KB;
13
+
14
+ const keyCache = new LRUCache<string, string>(10000);
15
+ export const generateCacheKey = (options: CacheQueryOptions) => {
16
+ const { name, version, features, minify } = options;
17
+
18
+ const str = `${name}-${version}-${Number(minify)}-${features}`;
19
+ const matched = keyCache.get(str);
20
+ if (matched) {
21
+ return matched;
22
+ }
23
+
24
+ const hash = crypto
25
+ .createHmac('sha256', '^polyfill$')
26
+ .update(str)
27
+ .digest('hex');
28
+ keyCache.set(str, hash);
29
+ return hash;
30
+ };
31
+
32
+ export default class Cache {
33
+ private readonly caches: LRUCache<string, string>;
34
+
35
+ constructor() {
36
+ this.caches = new LRUCache({
37
+ max: 200 * MB,
38
+ length: v => v.length,
39
+ });
40
+ }
41
+
42
+ public get(hash: string) {
43
+ return this.caches.get(hash);
44
+ }
45
+
46
+ public set(hash: string, content: string) {
47
+ this.caches.set(hash, content);
48
+ }
49
+ }
package/src/type.ts ADDED
@@ -0,0 +1,7 @@
1
+ export type ServerPolyfill = {
2
+ polyfill: {
3
+ route: string;
4
+ features: Record<string, { flags: string[] }>;
5
+ minify: boolean;
6
+ };
7
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "@modern-js/tsconfig/base",
3
+ "compilerOptions": {
4
+ "declaration": false,
5
+ "jsx": "preserve",
6
+ "baseUrl": "./",
7
+ "paths": {
8
+ "@/*": ["./src/*"]
9
+ }
10
+ },
11
+ "include": ["src"]
12
+ }