Skip to content

Commit

Permalink
feat: smartly install missing babel plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Nov 14, 2023
1 parent 3f5f82e commit e75e1cc
Show file tree
Hide file tree
Showing 9 changed files with 232 additions and 81 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ temp
temp/*
.eslintcache
coverage
temp-spa
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"vite": ">=4.0.0"
},
"dependencies": {
"@antfu/install-pkg": "^0.1.1",
"@babel/core": "^7.22.20",
"@babel/preset-env": "^7.22.20",
"@babel/preset-typescript": "^7.22.20",
Expand All @@ -73,10 +74,13 @@
"esbuild": "^0.19.5",
"esbuild-plugin-browserslist": "^0.10.0",
"fs-extra": "^11.1.1",
"local-pkg": "^0.5.0",
"magic-string": "^0.30.5",
"on-change": "^4.0.2",
"parse5": "^7.1.2",
"picocolors": "^1.0.0",
"prompts": "^2.4.2",
"std-env": "^3.5.0",
"tiny-glob": "^0.2.9",
"watcher": "^2.3.0"
},
Expand All @@ -90,6 +94,7 @@
"@types/debug": "^4.1.10",
"@types/fs-extra": "^11.0.3",
"@types/node": "^20.8.9",
"@types/prompts": "^2.4.8",
"bumpp": "^9.2.0",
"conventional-changelog-cli": "^4.1.0",
"cross-env": "^7.0.3",
Expand Down
3 changes: 2 additions & 1 deletion playground/temp-spa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@babel/plugin-transform-property-mutators": "^7.22.15",
"@babel/plugin-transform-react-constant-elements": "^7.23.3",
"@babel/preset-react": "^7.23.3",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"@vitejs/plugin-legacy": "^4.1.1",
Expand Down
5 changes: 2 additions & 3 deletions playground/temp-spa/public-typescript/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ declare global {
}
}

const a = 1
console.log(a)
import { flexible } from 'modern-flexible'

export {}
flexible()
5 changes: 0 additions & 5 deletions playground/temp-spa/public/out/test.e02bfaae.js

This file was deleted.

7 changes: 6 additions & 1 deletion playground/temp-spa/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export default defineConfig(() => ({
manifestName: 'manifest',
outputDir: 'out',
destination: 'file',
babel: true,
babel: {
config: {
plugins: ['@babel/plugin-transform-react-constant-elements'],
presets: ['@babel/preset-react'],
}
},
}),
injectScripts((manifest) => [
{
Expand Down
Loading

0 comments on commit e75e1cc

Please sign in to comment.