Skip to content

Commit 56ecf60

Browse files
author
HienTM
committed
refactor: remove redundant setting async
1 parent d848dba commit 56ecf60

11 files changed

+297
-217
lines changed

.eslintrc

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"extends": [
3-
"react-ts"
4-
]
2+
"extends": ["react-ts"],
3+
"ignorePatterns": ["*.js"]
54
}

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
node_modules
2-
1+
/node_modules
2+
/dist

dist/bootstrapMicroFrontend.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { ComponentType } from 'react';
22
import { MicroFrontendAppProps } from './types';
3-
declare const bootstrapMicroFrontend: (microFrontendName: string, App: React.ComponentType<MicroFrontendAppProps>, callback?: VoidFunction | undefined, rootId?: string) => void;
3+
declare const bootstrapMicroFrontend: (microFrontendName: string, App: ComponentType<MicroFrontendAppProps>, callback?: VoidFunction | undefined, rootId?: string) => void;
44
export default bootstrapMicroFrontend;

dist/index.es.js

+11-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+14-13
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
"license": "MIT",
88
"private": false,
99
"source": "src/index.ts",
10+
"main": "dist/index.es.js",
1011
"module": "dist/index.es.js",
1112
"types": "dist/index.d.ts",
1213
"files": [
1314
"dist/"
1415
],
16+
"sideEffects:": false,
1517
"scripts": {
16-
"build": "rollup -c",
17-
"build:config": "tsc rollup.config.ts --target es2017 --module es2015 --moduleResolution node --skipLibCheck --allowSyntheticDefaultImports --resolveJsonModule",
18+
"build": "rollup -c rollup/rollup.config.js",
19+
"build:config": "tsc -p rollup",
1820
"commit": "git-cz",
1921
"format": "prettier --write \"src/**/*.{ts,tsx,md}\"",
2022
"lint": "eslint 'src/**/*.{ts,tsx}'",
@@ -26,35 +28,34 @@
2628
},
2729
"dependencies": {
2830
"cb-react-micro-frontend-core": "^0.0.5",
29-
"cb-toolset": "^0.1.2"
31+
"cb-toolset": "^0.2.0"
3032
},
3133
"devDependencies": {
3234
"@commitlint/cli": "^8.3.5",
3335
"@commitlint/config-conventional": "^8.3.4",
34-
"@rollup/plugin-node-resolve": "^7.1.3",
36+
"@rollup/plugin-node-resolve": "^8.0.0",
3537
"@size-limit/preset-small-lib": "^4.5.0",
36-
"@types/history": "^4.7.5",
3738
"@types/js-cookie": "^2.2.6",
38-
"@types/node": "^13.13.5",
39+
"@types/node": "^14.0.5",
3940
"@types/react": "^16.9.34",
4041
"@types/react-dom": "^16.9.7",
4142
"@types/react-router-dom": "^5.1.5",
43+
"cb-rollup-plugin-filesize": "^9.0.0-5",
4244
"commitizen": "^4.1.2",
4345
"cz-conventional-changelog": "^3.2.0",
44-
"del-cli": "^3.0.0",
46+
"del-cli": "^3.0.1",
4547
"eslint": "^7.0.0",
4648
"eslint-config-react-ts": "^2.1.0",
4749
"husky": "^4.2.3",
48-
"lint-staged": "^10.2.2",
50+
"lint-staged": "^10.2.4",
4951
"react": "^16.13.1",
5052
"react-dom": "^16.13.1",
51-
"release-it": "^13.5.8",
52-
"rollup": "^2.8.2",
53+
"release-it": "^13.6.1",
54+
"rollup": "^2.10.5",
5355
"rollup-plugin-cleanup": "^3.1.1",
54-
"rollup-plugin-filesize": "^8.0.2",
55-
"rollup-plugin-typescript2": "^0.27.0",
56+
"rollup-plugin-typescript2": "^0.27.1",
5657
"size-limit": "^4.5.0",
57-
"typescript": "^3.8.3"
58+
"typescript": "^3.9.3"
5859
},
5960
"peerDependencies": {
6061
"react": "> 16.8.0",

rollup.config.js

-27
This file was deleted.

rollup/rollup.config.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import typescript from 'rollup-plugin-typescript2';
2+
import resolve from '@rollup/plugin-node-resolve';
3+
import cleanup from 'rollup-plugin-cleanup';
4+
import filesize from 'cb-rollup-plugin-filesize';
5+
import pkg from '../package.json';
6+
const external = [
7+
'react',
8+
'react-dom',
9+
'react-router-dom',
10+
'history',
11+
];
12+
const tsconfig = './tsconfig.json';
13+
const plugins = [
14+
typescript({ tsconfig, clean: true }),
15+
resolve(),
16+
cleanup({ comments: 'none' }),
17+
filesize(),
18+
];
19+
const watch = { include: ['src/**'] };
20+
const esOptions = {
21+
input: pkg.source,
22+
external,
23+
output: {
24+
file: pkg.module,
25+
format: 'es',
26+
sourcemap: true,
27+
},
28+
plugins,
29+
watch,
30+
};
31+
const options = [esOptions];
32+
export default options;

rollup.config.ts renamed to rollup/rollup.config.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ import { RollupOptions, ExternalOption, Plugin, WatcherOptions } from 'rollup';
33
import typescript from 'rollup-plugin-typescript2';
44
import resolve from '@rollup/plugin-node-resolve';
55
import cleanup from 'rollup-plugin-cleanup';
6-
import filesize from 'rollup-plugin-filesize';
7-
import pkg from './package.json';
6+
import filesize from 'cb-rollup-plugin-filesize';
7+
import pkg from '../package.json';
88

9-
const external: ExternalOption = ['react', 'react-dom', 'react-router-dom'];
9+
const external: ExternalOption = [
10+
'react',
11+
'react-dom',
12+
'react-router-dom',
13+
'history',
14+
];
1015
const tsconfig = './tsconfig.json';
1116
const plugins: Plugin[] = [
1217
typescript({ tsconfig, clean: true }),
@@ -22,6 +27,7 @@ const esOptions: RollupOptions = {
2227
output: {
2328
file: pkg.module,
2429
format: 'es',
30+
sourcemap: true,
2531
},
2632
plugins,
2733
watch,

rollup/tsconfig.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2017",
4+
"module": "ES2015",
5+
"lib": ["ES2020"],
6+
"allowJs": true,
7+
"downlevelIteration": true,
8+
"strict": true,
9+
"noImplicitAny": true,
10+
"strictNullChecks": true,
11+
"strictFunctionTypes": true,
12+
"strictBindCallApply": true,
13+
"strictPropertyInitialization": true,
14+
"noImplicitThis": true,
15+
"alwaysStrict": true,
16+
"noUnusedLocals": true,
17+
"noUnusedParameters": true,
18+
"noImplicitReturns": true,
19+
"moduleResolution": "node",
20+
"esModuleInterop": true,
21+
"forceConsistentCasingInFileNames": true,
22+
"skipLibCheck": true,
23+
"allowSyntheticDefaultImports": true,
24+
"resolveJsonModule": true
25+
},
26+
"include": ["."]
27+
}

src/lazyLoadMicroFrontend.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const loadScripts = (manifest: Manifest, host: string, scriptId: string) =>
2424
const entryUrl = resolveUrl(host, entry);
2525
const script = document.createElement('script');
2626
script.src = entryUrl;
27-
script.async = true;
2827
script.crossOrigin = '';
2928
if (entryUrl === mainJsUrl) script.id = scriptId;
3029
script.onload = () => {

0 commit comments

Comments
 (0)