@rsdoctor/client 0.1.5 → 0.1.6-beta.0

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/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@rsdoctor/client",
3
- "version": "0.1.5",
3
+ "version": "0.1.6-beta.0",
4
4
  "main": "dist/index.html",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/web-infra-dev/rsdoctor",
8
8
  "directory": "packages/client"
9
9
  },
10
+ "files": [
11
+ "dist"
12
+ ],
10
13
  "lint-staged": {
11
14
  "*.{js,jsx,ts,tsx,mjs,cjs}": [
12
15
  "node --max_old_space_size=8192 ./node_modules/eslint/bin/eslint.js --fix --color --cache --quiet"
@@ -28,14 +31,14 @@
28
31
  "@types/webpack": "5.28.0",
29
32
  "antd": "5.8.3",
30
33
  "normalize.css": "8.0.1",
31
- "react": "^18",
34
+ "react": "18.2.0",
32
35
  "react-dom": "18.2.0",
33
36
  "react-error-boundary": "^4.0.11",
34
37
  "react-router-dom": "6.4.3",
35
38
  "serve-static": "1.15.0",
36
39
  "typescript": "^5.2.2",
37
- "@rsdoctor/components": "0.1.5",
38
- "@rsdoctor/types": "0.1.5"
40
+ "@rsdoctor/components": "0.1.6-beta.0",
41
+ "@rsdoctor/types": "0.1.6-beta.0"
39
42
  },
40
43
  "publishConfig": {
41
44
  "access": "public",
package/CHANGELOG.md DELETED
@@ -1,57 +0,0 @@
1
- # @rsdoctor/components
2
-
3
- ## 0.1.5
4
-
5
- ## 0.1.4
6
-
7
- ## 0.1.3
8
-
9
- ## 0.1.2
10
-
11
- ## 0.1.1
12
-
13
- ## 0.1.0
14
-
15
- ### Minor Changes
16
-
17
- - e1ac5e7: release: 0.1.0
18
-
19
- ### Patch Changes
20
-
21
- - ab32629: feat(client): add module anaysis components
22
- - ca92633: Optimize(client): optimize ui client
23
- - b88d156: feat(platform): report platform add bundle size page
24
- - 96d0d68: Rsdoctor report platform add overall page (close: #25)
25
- - 612eefd: feat(client): add timeline chart & loader analysis page
26
- - d8bc40e: feat(client): add resolve & loader & plugin pages
27
- - 0e3abb7: feat(bundle): rspack mode add bundle analysis by rspack's hooks and add rules scan.
28
- - fc01584: refactor(client): migrate build tool to Rsbuild
29
-
30
- ## 0.1.0-beta
31
-
32
- ### Minor Changes
33
-
34
- - e1ac5e7: release: 0.1.0
35
-
36
- ## 0.0.2-beta.2
37
-
38
- ### Patch Changes
39
-
40
- - 0e3abb7: feat(bundle): rspack mode add bundle analysis by rspack's hooks and add rules scan.
41
-
42
- ## 0.0.2-beta.1
43
-
44
- ### Patch Changes
45
-
46
- - ca92633: Optimize(client): optimize ui client
47
-
48
- ## 0.0.2-beta.0
49
-
50
- ### Patch Changes
51
-
52
- - ab32629: feat(client): add module anaysis components
53
- - b88d156: feat(platform): report platform add bundle size page
54
- - 96d0d68: Rsdoctor report platform add overall page (close: #25)
55
- - 612eefd: feat(client): add timeline chart & loader analysis page
56
- - d8bc40e: feat(client): add resolve & loader & plugin pages
57
- - fc01584: refactor(client): migrate build tool to Rsbuild
@@ -1,19 +0,0 @@
1
- import { Constants } from '@rsdoctor/types';
2
-
3
- import path from 'path';
4
-
5
- export const DistPath = path.resolve(__dirname, '../dist');
6
-
7
- export const DistResourcePath = path.resolve(__dirname, '../dist/resource');
8
-
9
- export const WebpackRsdoctorDirPath = path.resolve(__dirname, `../dist/${Constants.RsdoctorOutputFolder}`);
10
-
11
- export const WebpackStatsFilePath = path.resolve(__dirname, '../dist/stats.json');
12
-
13
- export const PortForWeb = 8681;
14
-
15
- export const PortForCLI = 8123;
16
-
17
- export const ClientEntry = path.resolve(__dirname, '../src/index.tsx');
18
-
19
- export const RsdoctorWebpackPluginMain = path.resolve(__dirname, '../../webpack-plugin/dist');
package/rsbuild.config.ts DELETED
@@ -1,164 +0,0 @@
1
- import type { Compiler } from 'webpack';
2
- import { defineConfig } from '@rsbuild/core';
3
- import { pluginReact } from '@rsbuild/plugin-react';
4
- import { pluginTypeCheck } from '@rsbuild/plugin-type-check';
5
- import { pluginNodePolyfill } from '@rsbuild/plugin-node-polyfill';
6
- import serve from 'serve-static';
7
- import path from 'path';
8
- import fs from 'fs';
9
- import {
10
- ClientEntry,
11
- DistPath,
12
- PortForCLI,
13
- PortForWeb,
14
- WebpackRsdoctorDirPath,
15
- WebpackStatsFilePath,
16
- } from './config/constants';
17
-
18
- const {
19
- ENABLE_DEVTOOLS_PLUGIN,
20
- OFFICAL_PREVIEW_PUBLIC_PATH,
21
- OFFICAL_DEMO_MANIFEST_PATH,
22
- ENABLE_CLIENT_SERVER,
23
- } = process.env;
24
-
25
- export default defineConfig((env) => {
26
- const IS_PRODUCTION = env.env === 'production';
27
-
28
- return {
29
- plugins: [
30
- pluginReact(),
31
- pluginNodePolyfill(),
32
- pluginTypeCheck({ enable: IS_PRODUCTION }),
33
- ],
34
-
35
- source: {
36
- entry: {
37
- index: ClientEntry,
38
- },
39
- define: {
40
- 'process.env.NODE_DEBUG': JSON.stringify(false),
41
- 'process.env.NODE_ENV': JSON.stringify(env.env),
42
- 'process.env.OFFICAL_DEMO_MANIFEST_PATH': JSON.stringify(
43
- OFFICAL_DEMO_MANIFEST_PATH,
44
- ),
45
- 'process.env.LOCAL_CLI_PORT': JSON.stringify(PortForCLI),
46
- },
47
- },
48
-
49
- output: {
50
- distPath: {
51
- root: path.basename(DistPath),
52
- js: 'resource/js',
53
- css: 'resource/css',
54
- svg: 'resource/svg',
55
- font: 'resource/font',
56
- image: 'resource/image',
57
- media: 'resource/media',
58
- },
59
- assetPrefix: IS_PRODUCTION
60
- ? OFFICAL_PREVIEW_PUBLIC_PATH?.replace(/\/resource$/, '') || '/'
61
- : '/',
62
- cleanDistPath: IS_PRODUCTION,
63
- disableTsChecker: !IS_PRODUCTION,
64
- disableSourceMap: true,
65
- disableMinimize: !IS_PRODUCTION,
66
- },
67
-
68
- performance: {
69
- buildCache: false,
70
- chunkSplit: {
71
- strategy: 'custom',
72
- splitChunks: {
73
- cacheGroups: {
74
- monaco: {
75
- test: /node_modules\/monaco-editor\/*/,
76
- name: 'monaco',
77
- chunks: 'all',
78
- maxSize: 1000000,
79
- minSize: 500000,
80
- },
81
- },
82
- },
83
- },
84
- },
85
-
86
- tools: {
87
- bundlerChain: (chainConfig) => {
88
- if (ENABLE_DEVTOOLS_PLUGIN) {
89
- const { RsdoctorRspackPlugin } =
90
- require('../rspack-plugin/dist') as typeof import('../rspack-plugin/dist');
91
-
92
- class StatsWriter {
93
- apply(compiler: Compiler) {
94
- compiler.hooks.done.tapPromise(
95
- { name: 'webpack-stats-json-writer', stage: 99999 },
96
- async (stats) => {
97
- const json = stats.toJson({
98
- all: false,
99
- assets: true,
100
- chunks: true,
101
- modules: true,
102
- builtAt: true,
103
- hash: true,
104
- ids: true,
105
- version: true,
106
- entrypoints: true,
107
- });
108
- await fs.promises.writeFile(
109
- WebpackStatsFilePath,
110
- JSON.stringify(json, null, 2),
111
- 'utf-8',
112
- );
113
- },
114
- );
115
- }
116
- }
117
-
118
- chainConfig.plugin('stats-writer').use(StatsWriter);
119
- chainConfig.plugin('rsdoctor').use(RsdoctorRspackPlugin, [
120
- {
121
- disableClientServer: !ENABLE_CLIENT_SERVER,
122
- features: {
123
- loader: true,
124
- plugins: true,
125
- resolver: true,
126
- bundle: true,
127
- treeShaking: true,
128
- },
129
- },
130
- ]);
131
- }
132
- },
133
-
134
- devServer: {
135
- historyApiFallback: true,
136
- setupMiddlewares: [
137
- (middlewares) => {
138
- if (fs.existsSync(WebpackRsdoctorDirPath)) {
139
- const fn = serve(WebpackRsdoctorDirPath, {
140
- index: false,
141
- setHeaders(res) {
142
- res.setHeader('Content-Type', 'text/plain; charset=utf-8');
143
- },
144
- });
145
- middlewares.push(fn);
146
- }
147
- },
148
- ],
149
- },
150
- },
151
-
152
- html: {
153
- title: 'Rsdoctor',
154
- },
155
-
156
- server: {
157
- port: PortForWeb,
158
- },
159
-
160
- dev: {
161
- startUrl: ENABLE_CLIENT_SERVER ? undefined : true,
162
- },
163
- };
164
- });
package/src/App.tsx DELETED
@@ -1,146 +0,0 @@
1
- import { Constants } from '@rsdoctor/components';
2
- import { Config, ConfigContext, defaultConfig } from '@rsdoctor/components/config';
3
- import { Layout } from '@rsdoctor/components/elements';
4
- import { getDemoUrl, getLocale, setThemeToStorage, setViewModeToStorage, useDetectIfCloudIdeEnv } from '@rsdoctor/components/utils';
5
- import type { Manifest } from '@rsdoctor/types';
6
- import { Alert, Button, ConfigProvider, Divider, Result, Space, Typography, theme as te } from 'antd';
7
- import React, { useState } from 'react';
8
- import { ErrorBoundary } from 'react-error-boundary';
9
- import { HashRouter as BrowserRouter } from 'react-router-dom';
10
- import Router from './router';
11
-
12
- const { PageState, Theme } = Constants;
13
-
14
- const App: React.FC = (): React.ReactElement => {
15
- const ifCloudIdeEnv = useDetectIfCloudIdeEnv();
16
-
17
- const [state, setState] = useState<Constants.PageState>(PageState.Success);
18
- const [viewMode, setViewMode] = useState<Config['viewMode']>({ ...defaultConfig.viewMode });
19
- const [manifest, setManifest] = useState<Manifest.RsdoctorManifest>();
20
- const [theme, setTheme] = useState(defaultConfig.theme);
21
-
22
- if (state === Constants.PageState.Fail) {
23
- const demoUrl = getDemoUrl();
24
- return (
25
- <Space direction="vertical" style={{ padding: 14 }}>
26
- <Typography.Text strong style={{ fontSize: 16 }}>
27
- load json file of Rsdoctor failed.
28
- </Typography.Text>
29
- <Typography.Text>
30
- try to use <Typography.Text keyboard>command + r</Typography.Text> to refresh page.
31
- </Typography.Text>
32
- {process.env.NODE_ENV === 'development' ? (
33
- <Typography.Text>
34
- in development, you need to run <Typography.Text keyboard>emo run build:analysis</Typography.Text> to make
35
- sure the mock data has been generated.
36
- </Typography.Text>
37
- ) : null}
38
- <Divider />
39
- <Space direction="vertical" style={{ width: '100%' }}>
40
- <Typography.Text style={{ fontSize: 16 }}>
41
- you can
42
- <Typography.Text strong style={{ fontSize: 'inherit' }}>
43
- {' '}
44
- upload a file{' '}
45
- </Typography.Text>
46
- in the area below to analyze your project.
47
- </Typography.Text>
48
- {/* <UploaderComponent /> */}
49
- </Space>
50
- <Divider />
51
- {demoUrl ? (
52
- <Typography.Text style={{ fontSize: 16 }}>
53
- or you can open the{' '}
54
- <Typography.Text strong style={{ fontSize: 'inherit' }}>
55
- <a href={demoUrl} target="_blank" rel="noreferrer">
56
- demo
57
- </a>
58
- </Typography.Text>{' '}
59
- to get started with the Rsdoctor.
60
- </Typography.Text>
61
- ) : null}
62
- </Space>
63
- );
64
- }
65
-
66
- return (
67
- <BrowserRouter>
68
- <ConfigContext.Provider
69
- value={{
70
- ...defaultConfig,
71
- theme,
72
- setTheme: (v) => {
73
- setTheme(v);
74
- setThemeToStorage(v);
75
- },
76
- pageState: state,
77
- json: manifest!,
78
- viewMode,
79
- setManifest,
80
- setPageState: setState,
81
- setViewMode(m, saveStorage = true) {
82
- const res = { ...viewMode, ...m };
83
- setViewMode(res);
84
- saveStorage && setViewModeToStorage(res);
85
- },
86
- }}
87
- >
88
- <ConfigContext.Consumer>
89
- {(v) => {
90
- return (
91
- <ConfigProvider
92
- locale={getLocale(v.locale)}
93
- theme={{
94
- algorithm: theme === Theme.Dark ? te.darkAlgorithm : te.defaultAlgorithm,
95
- }}
96
- >
97
- <Layout>
98
- <>
99
- {ifCloudIdeEnv && (
100
- <Alert
101
- message="Warning"
102
- description={
103
- <a
104
- href={window.location.href.replace(/https/, 'http')}
105
- >{`Please jump to:${window.location.href.replace(/https/, 'http')}`}</a>
106
- }
107
- type="warning"
108
- showIcon
109
- closable
110
- />
111
- )}
112
- <ErrorBoundary
113
- FallbackComponent={({ error, resetErrorBoundary }) => (
114
- <Result
115
- status="error"
116
- title="Sorry, something went wrong."
117
- extra={
118
- <Button type="primary" onClick={resetErrorBoundary} loading={state === PageState.Pending}>
119
- Reload
120
- </Button>
121
- }
122
- >
123
- <Typography.Paragraph>
124
- <Typography.Title level={3}>Error Stack</Typography.Title>
125
- <pre>{error.stack || error.message}</pre>
126
- </Typography.Paragraph>
127
- </Result>
128
- )}
129
- onReset={() => {
130
- window.location.reload();
131
- }}
132
- >
133
- <Router />
134
- </ErrorBoundary>
135
- </>
136
- </Layout>
137
- </ConfigProvider>
138
- );
139
- }}
140
- </ConfigContext.Consumer>
141
- </ConfigContext.Provider>
142
- </BrowserRouter>
143
- );
144
- };
145
-
146
- export default App;
@@ -1 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?><svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 24L43 24" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M28 4H20C18.8954 4 18 4.89543 18 6V14C18 15.1046 18.8954 16 20 16H28C29.1046 16 30 15.1046 30 14V6C30 4.89543 29.1046 4 28 4Z" fill="none" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M16 32H8C6.89543 32 6 32.8954 6 34V42C6 43.1046 6.89543 44 8 44H16C17.1046 44 18 43.1046 18 42V34C18 32.8954 17.1046 32 16 32Z" fill="none" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M40 32H32C30.8954 32 30 32.8954 30 34V42C30 43.1046 30.8954 44 32 44H40C41.1046 44 42 43.1046 42 42V34C42 32.8954 41.1046 32 40 32Z" fill="none" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M24 24V16" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M36 32V24" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 32V24" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>
@@ -1,6 +0,0 @@
1
- @import "normalize.css";
2
- @import "./theme.scss";
3
-
4
- .body {
5
- font-size: 12px;
6
- }
@@ -1,3 +0,0 @@
1
- // body {
2
- // background-color: rgb(247, 245, 245);
3
- // }
package/src/index.tsx DELETED
@@ -1,15 +0,0 @@
1
- import '@rsdoctor/components/i18n';
2
- import App from './App';
3
- import ReactDOM from 'react-dom/client';
4
- import './common/styles/base.scss';
5
-
6
- const rootElement = document.getElementById('root');
7
- const root = ReactDOM.createRoot(rootElement!);
8
-
9
- root.render(<App />);
10
-
11
- const link = document.createElement('link');
12
- link.setAttribute('type', 'image/x-icon');
13
- link.setAttribute('rel', 'icon');
14
- link.setAttribute('href', 'https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/logo/rsdoctor.png');
15
- document.head.appendChild(link);
package/src/router.tsx DELETED
@@ -1,47 +0,0 @@
1
- import React from 'react';
2
- import { Route, Routes } from 'react-router-dom';
3
- import { Overall, BundleSize, LoaderFiles, PluginsAnalyze, ModuleResolve, LoaderTimeline, RuleIndex } from '@rsdoctor/components/pages';
4
-
5
-
6
- export default function Router(): React.ReactElement {
7
- const routes = [
8
- {
9
- path: BundleSize.route,
10
- element: <BundleSize.Page />,
11
- },
12
- {
13
- path: LoaderFiles.route,
14
- element: <LoaderFiles.Page />,
15
- },
16
- {
17
- path: LoaderFiles.route,
18
- element: <LoaderFiles.Page />,
19
- },
20
- {
21
- path: PluginsAnalyze.route,
22
- element: <PluginsAnalyze.Page />,
23
- },
24
- {
25
- path: ModuleResolve.route,
26
- element: <ModuleResolve.Page />,
27
- },
28
- {
29
- path: LoaderTimeline.route,
30
- element: <LoaderTimeline.Page />,
31
- },
32
- {
33
- path: RuleIndex.route,
34
- element: <RuleIndex.Page />,
35
- },
36
- ].filter((e) => Boolean(e)) as { path: string; element: JSX.Element }[];
37
-
38
- return (
39
- <Routes>
40
- <Route path="/" element={<Overall.Page />} />
41
- <Route path={Overall.route} element={<Overall.Page />} />
42
- {routes.map((e) => (
43
- <Route key={e.path} path={e.path} element={e.element} />
44
- ))}
45
- </Routes>
46
- );
47
- }
@@ -1,16 +0,0 @@
1
- declare module '*.png';
2
- declare module '*.jpg';
3
- declare module '*.svg';
4
- declare module '*.jpeg';
5
- declare module '*.gif';
6
- declare module '*.webp';
7
- declare module '*.ttf';
8
- declare module '*.woff';
9
- declare module '*.woff2';
10
- declare module '*.scss';
11
- declare module '*.less';
12
- declare module '*.css';
13
- declare module '*?__inline';
14
- declare module '*?__inline=true';
15
- declare module '*?__inline=false';
16
-
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "@rsdoctor/tsconfig/base",
3
- "compilerOptions": {
4
- "baseUrl": "./",
5
- "jsx": "react-jsx",
6
- "isolatedModules": true,
7
- "declaration": true,
8
- "composite": true,
9
- "outDir": "dist",
10
- },
11
- "include": ["src", "config"],
12
- "exclude": ["**/node_modules"]
13
- }