Skip to content

Commit

Permalink
chore: add rsdoctor some examples
Browse files Browse the repository at this point in the history
  • Loading branch information
easy1090 committed Mar 25, 2024
1 parent 08aaa0d commit 0ed7668
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 43 deletions.
4 changes: 2 additions & 2 deletions rsdoctor/arco-pro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"scripts": {
"dev": "rspack serve",
"doctor": "RSDOCTOR=true rspack serve",
"build:analysis": "RSDOCTOR=true rspack serve",
"build": "rspack build",
"analyze": "pnpm run build --analyze",
"preview": "cd dist && serve -s",
Expand Down Expand Up @@ -55,7 +55,7 @@
"serve": "14.1.2",
"style-loader": "^3.3.1",
"swc-loader": "^0.2.3",
"@rsdoctor/rspack-plugin": "0.1.0"
"@rsdoctor/rspack-plugin": "^0.1.8"
},
"browserslist": {
"production": [
Expand Down
15 changes: 6 additions & 9 deletions rsdoctor/modern-minimal/modern.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { appTools, defineConfig } from '@modern-js/app-tools';
import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';

const pluginName = 'Rsdoctor';

export default defineConfig({
export default defineConfig<'rspack'>({
runtime: {
router: true,
state: true,
Expand All @@ -21,13 +21,10 @@ export default defineConfig({
},
plugins: [appTools()],
tools: {
bundlerChain: (chain) => {
chain.plugin(pluginName).use(RsdoctorWebpackPlugin, [
{
disableClientServer: !process.env.ENABLE_CLIENT_SERVER,
features: ['bundle', 'plugins', 'loader', 'resolver'],
},
]);
rspack: (config, { appendPlugins }) => {
if (process.env.RSDOCTOR === 'true') {
appendPlugins([new RsdoctorRspackPlugin()]);
}
},
},
});
16 changes: 5 additions & 11 deletions rsdoctor/modern-minimal/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
{
"name": "@examples/doctor-modern-minimal",
"name": "rsdoctor-modern-minimal",
"version": "0.0.1",
"description": "",
"files": [
"dist",
"src",
"package.json"
],
"scripts": {
"start:analysis": "ENABLE_CLIENT_SERVER=true modern start",
"build:analysis": "ENABLE_CLIENT_SERVER=true modern build",
"build:analysis": "RSDOCTOR=true modern build",
"build": "modern build"
},
"author": "",
Expand All @@ -22,9 +16,9 @@
"react-dom": "^18"
},
"devDependencies": {
"@modern-js/runtime": "2.41.0",
"@rsdoctor/webpack-plugin": "0.1.7",
"@modern-js/app-tools": "2.41.0",
"@modern-js/runtime": "2.48.3",
"@rsdoctor/rspack-plugin": "^0.1.8",
"@modern-js/app-tools": "2.48.3",
"@types/node": "14.18.26",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand Down
4 changes: 2 additions & 2 deletions rsdoctor/modern-minimal/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"target": "ES2019",
"lib": ["DOM", "ESNext"],
"allowJs": true,
"module": "ES2020",
"module": "NodeNext",
"outDir": "dist",
"baseUrl": ".",
"strict": true,
Expand All @@ -15,7 +15,7 @@
"noUnusedParameters": true,
"jsx": "preserve",
"resolveJsonModule": true,
"moduleResolution": "Bundler"
"moduleResolution": "NodeNext"
},
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Base"
Expand Down
2 changes: 2 additions & 0 deletions rsdoctor/next-minimal/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';

const nextConfig = {
webpack: (config) => {
if (process.env.RSDOCTOR === 'true') {
config.plugins.push(
new RsdoctorWebpackPlugin({
disableClientServer: true,
})
)
}
return config
},
};
Expand Down
9 changes: 5 additions & 4 deletions rsdoctor/next-minimal/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "next-app",
"name": "rsdoctor-next-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"doctor": "RSDOCTOR=true next build",
"start": "next start",
"lint": "next lint",
"doctor": "npm run build && npx rsdoctor analyze --profile ./.next/.rsdoctor/manifest.json"
"build:analysis": "npm run doctor && npx rsdoctor analyze --profile ./.next/.rsdoctor/manifest.json"
},
"dependencies": {
"next": "14.1.0",
Expand All @@ -16,8 +17,8 @@
"react-dom": "^18"
},
"devDependencies": {
"@rsdoctor/cli": "^0.1.7",
"@rsdoctor/webpack-plugin": "0.1.7",
"@rsdoctor/cli": "^0.1.8",
"@rsdoctor/webpack-plugin": "^0.1.8",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand Down
9 changes: 4 additions & 5 deletions rsdoctor/rsbuild-minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"package.json"
],
"scripts": {
"start:analysis": "ENABLE_CLIENT_SERVER=true rsbuild dev",
"build:analysis": "ENABLE_CLIENT_SERVER=true rsbuild build",
"build:analysis": "RSDOCTOR=true rsbuild build",
"build": "rsbuild build"
},
"author": "",
Expand All @@ -21,9 +20,9 @@
"semver7": "npm:[email protected]"
},
"devDependencies": {
"@rsbuild/core": "0.3.0",
"@rsbuild/plugin-react": "0.3.0",
"@rsdoctor/rspack-plugin": "0.1.7",
"@rsbuild/core": "0.5.2",
"@rsbuild/plugin-react": "0.5.2",
"@rsdoctor/rspack-plugin": "^0.1.8",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/semver6": "npm:@types/[email protected]",
Expand Down
11 changes: 1 addition & 10 deletions rsdoctor/rsbuild-minimal/rsbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@ export default defineConfig({
plugins: [pluginReact()],
tools: {
bundlerChain: (chain) => {
chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [
{
disableClientServer: !process.env.ENABLE_CLIENT_SERVER,
features: ['bundle', 'plugins', 'loader', 'resolver']
},
]);
process.env.RSDOCTOR === 'true' && chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [{}]);
}
},
output: {
disableFilenameHash: true,
disableMinimize: true
}
});

0 comments on commit 0ed7668

Please sign in to comment.