Skip to content

Commit

Permalink
chore: use unbuild to bundle plugins (#8139)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 13, 2022
1 parent 04c2edd commit 638b168
Show file tree
Hide file tree
Showing 32 changed files with 766 additions and 435 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
playground-temp
temp

2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ module.exports = defineConfig({
}
},
{
files: ['packages/create-vite/template-*/**'],
files: ['packages/create-vite/template-*/**', '**/build.config.ts'],
rules: {
'node/no-missing-import': 'off'
}
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,8 @@ jobs:
- name: Install Playwright
run: pnpm playwright install

- name: Build vite
run: pnpm run ci-build-vite

- name: Build plugin-vue
run: pnpm run build-plugin-vue

- name: Build plugin-react
run: pnpm run build-plugin-react
- name: Build
run: pnpm run build

- name: Test unit
run: pnpm run test-unit
Expand Down Expand Up @@ -107,11 +101,8 @@ jobs:
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"

- name: Prepare
run: |
pnpm run ci-build-vite
pnpm run build-plugin-vue
pnpm run build-plugin-react
- name: Build
run: pnpm run build

- name: Lint
run: pnpm run lint
Expand Down
8 changes: 2 additions & 6 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
docs/.vitepress/dist/
packages/vite/dist/
packages/vite/temp/
packages/plugin-react/dist/
packages/plugin-vue/dist/
packages/*/CHANGELOG.md
playground-temp/
dist/
temp/
LICENSE.md
.prettierignore
pnpm-lock.yaml
pnpm-workspace.yaml
playground/tsconfig-json-load-error/has-error/tsconfig.json
Expand Down
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,26 @@
"preinstall": "npx only-allow pnpm",
"format": "prettier --write .",
"lint": "eslint packages/*/{src,types}/** playground/**/__tests__/** scripts/**",
"typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit",
"test": "run-s test-unit test-serve test-build",
"test-serve": "vitest run -c vitest.config.e2e.ts",
"test-build": "cross-env VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",
"test-unit": "vitest run",
"debug-serve": "cross-env VITE_DEBUG_SERVE=1 vitest run -c vitest.config.e2e.ts",
"debug-build": "cross-env VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 vitest run -c vitest.config.e2e.ts",
"docs": "vitepress dev docs",
"build-docs": "vitepress build docs",
"serve-docs": "vitepress serve docs",
"docs-build": "vitepress build docs",
"docs-serve": "vitepress serve docs",
"build": "pnpm -r --filter=./packages/* run build",
"dev": "pnpm -r --parallel --filter=./packages/* run dev",
"release": "ts-node scripts/release.ts",
"ci-publish": "ts-node scripts/publishCI.ts",
"typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit",
"build": "run-s build-vite build-plugin-vue build-plugin-react",
"build-vite": "cd packages/vite && npm run build",
"build-plugin-vue": "cd packages/plugin-vue && npm run build",
"build-plugin-react": "cd packages/plugin-react && npm run build",
"ci-build-vite": "cd packages/vite && npm run ci-build",
"ci-docs": "run-s build-vite build-plugin-vue build-docs"
"ci-docs": "run-s build docs-build"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.23.1",
"@types/babel__core": "^7.1.19",
"@types/babel__standalone": "^7.1.4",
"@types/convert-source-map": "^1.5.2",
"@types/cross-spawn": "^6.0.2",
"@types/debug": "^4.1.7",
Expand Down Expand Up @@ -83,6 +81,7 @@
"sirv": "^2.0.2",
"ts-node": "^10.7.0",
"typescript": "^4.6.4",
"unbuild": "^0.7.4",
"vite": "workspace:*",
"vitepress": "^0.22.4",
"vitest": "^0.12.4",
Expand Down
10 changes: 10 additions & 0 deletions packages/plugin-legacy/build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
entries: ['src/index'],
clean: true,
declaration: true,
rollup: {
emitCJS: true
}
})
25 changes: 21 additions & 4 deletions packages/plugin-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@
"license": "MIT",
"author": "Evan You",
"files": [
"index.js",
"index.d.ts"
"dist"
],
"main": "index.js",
"types": "index.d.ts",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"scripts": {
"dev": "unbuild --stub",
"build": "unbuild && pnpm run patch-cjs",
"patch-cjs": "ts-node ../../scripts/patchCJS.ts",
"prepublishOnly": "npm run build"
},
"engines": {
"node": ">=14.6.0"
},
Expand All @@ -30,5 +43,9 @@
},
"peerDependencies": {
"vite": "^2.8.0"
},
"devDependencies": {
"vite": "workspace:*",
"@babel/core": "^7.17.10"
}
}

0 comments on commit 638b168

Please sign in to comment.