Skip to content

Commit

Permalink
feat: use rollup to bundle files
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Sep 30, 2024
1 parent 39b43f1 commit 152772f
Show file tree
Hide file tree
Showing 103 changed files with 965 additions and 107 deletions.
38 changes: 36 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
workflow_dispatch:

jobs:
check:
build-check:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -42,11 +42,45 @@ jobs:
- name: Unit Test
run: pnpm test:unit

bundle-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm bundle

- name: Linter Test
run: pnpm lint

- name: Docs Test
run: |
pnpm --filter @vuepress/ecosystem-docs docs:build
pnpm --filter @vuepress/ecosystem-docs docs:build-webpack
- name: Unit Test
run: pnpm test:unit

check-result:
if: ${{ always() }}
name: check result
runs-on: ubuntu-latest
needs: [check]
needs:
- build-check
- bundle-check
steps:
- if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Build Project
run: pnpm build
run: pnpm bundle

- name: Docs build
env:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: e2e

on:
push:
branches:
pull_request:
branches:
- main
Expand Down Expand Up @@ -37,7 +36,7 @@ jobs:
run: pnpm playwright install chromium

- name: Build source files
run: pnpm build
run: pnpm bundle

- name: E2E test (base /)
run: pnpm test:e2e
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Build Project
run: pnpm build
run: pnpm bundle

- name: Update npmrc
run: |
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"type": "module",
"scripts": {
"build": "pnpm build:tsc && pnpm build:copy && pnpm build:style",
"build:bundle": "pnpm -r --stream bundle",
"build:copy": "pnpm --parallel --stream copy",
"build:style": "pnpm --parallel --stream style",
"build:tsc": "tsc -b tsconfig.build.json",
"bundle": "pnpm build:bundle && pnpm build:copy && pnpm build:style",
"clean": "pnpm --parallel --stream clean",
"format": "prettier --write .",
"lint": "eslint . && prettier --check . && stylelint **/*.{css,html,scss,vue}",
Expand All @@ -33,6 +35,8 @@
"@commitlint/config-conventional": "^19.5.0",
"@lerna-lite/cli": "^3.9.1",
"@lerna-lite/publish": "^3.9.1",
"@rollup/plugin-commonjs": "^28.0.0",
"@rollup/plugin-node-resolve": "^15.3.0",
"@types/node": "^22.7.4",
"@types/webpack-env": "^1.18.5",
"@vitest/coverage-istanbul": "^2.1.1",
Expand All @@ -48,6 +52,10 @@
"prettier": "^3.3.3",
"prettier-config-vuepress": "^5.0.0",
"rimraf": "^6.0.1",
"rollup": "^4.22.5",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.1.1",
"rollup-plugin-resolve-shebang": "^1.0.1",
"sass-embedded": "1.79.4",
"sort-package-json": "^2.10.1",
"stylelint": "^16.9.0",
Expand Down
1 change: 1 addition & 0 deletions plugins/analytics/plugin-baidu-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"dependencies": {
Expand Down
9 changes: 9 additions & 0 deletions plugins/analytics/plugin-baidu-analytics/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { rollupBundle } from '../../../scripts/rollup.js'

export default [
...rollupBundle('node/index'),
...rollupBundle({
base: 'client',
files: ['config', 'index'],
}),
]
1 change: 1 addition & 0 deletions plugins/analytics/plugin-google-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"peerDependencies": {
Expand Down
9 changes: 9 additions & 0 deletions plugins/analytics/plugin-google-analytics/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { rollupBundle } from '../../../scripts/rollup.js'

export default [
...rollupBundle('node/index'),
...rollupBundle({
base: 'client',
files: ['config', 'index'],
}),
]
1 change: 1 addition & 0 deletions plugins/analytics/plugin-umami-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"dependencies": {
Expand Down
9 changes: 9 additions & 0 deletions plugins/analytics/plugin-umami-analytics/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { rollupBundle } from '../../../scripts/rollup.js'

export default [
...rollupBundle('node/index'),
...rollupBundle({
base: 'client',
files: ['config', 'index'],
}),
]
1 change: 1 addition & 0 deletions plugins/blog/plugin-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"dependencies": {
Expand Down
8 changes: 8 additions & 0 deletions plugins/blog/plugin-blog/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { rollupBundle } from '../../../scripts/rollup.js'

export default [
...rollupBundle('node/index', {
external: ['chokidar'],
}),
...rollupBundle('client/index'),
]
1 change: 1 addition & 0 deletions plugins/blog/plugin-comment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo",
"style": "sass src:lib --embed-sources --style=compressed"
},
Expand Down
27 changes: 27 additions & 0 deletions plugins/blog/plugin-comment/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { rollupBundle } from '../../../scripts/rollup.js'

const COMMENT_PROVIDERS = ['Artalk', 'Giscus', 'Twikoo', 'Waline']

export default [
...rollupBundle('node/index'),
...rollupBundle(
{
base: 'client',
files: [
...COMMENT_PROVIDERS.map((name) => `components/${name}Comment`),
'config',
'index',
],
},
{
external: [
'@vuepress/plugin-comment/service',
'@waline/client/component',
'@waline/client/pageview',
'artalk/dist/Artalk.mjs',
'giscus',
'twikoo',
],
},
),
]
1 change: 1 addition & 0 deletions plugins/blog/plugin-feed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"dependencies": {
Expand Down
5 changes: 5 additions & 0 deletions plugins/blog/plugin-feed/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { rollupBundle } from '../../../scripts/rollup.js'

export default rollupBundle('node/index', {
external: ['xml-js'],
})
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { rollupBundle } from '../../../scripts/rollup.js'

export default [
...rollupBundle('node/index'),
...rollupBundle({
base: 'client',
files: ['config', 'index'],
}),
]
1 change: 1 addition & 0 deletions plugins/development/plugin-git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"dependencies": {
Expand Down
5 changes: 5 additions & 0 deletions plugins/development/plugin-git/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { rollupBundle } from '../../../scripts/rollup.js'

export default rollupBundle('node/index', {
external: ['execa'],
})
1 change: 1 addition & 0 deletions plugins/development/plugin-palette/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"dependencies": {
Expand Down
5 changes: 5 additions & 0 deletions plugins/development/plugin-palette/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { rollupBundle } from '../../../scripts/rollup.js'

export default rollupBundle('node/index', {
external: ['chokidar'],
})
1 change: 1 addition & 0 deletions plugins/development/plugin-reading-time/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"dependencies": {
Expand Down
10 changes: 10 additions & 0 deletions plugins/development/plugin-reading-time/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { rollupBundle } from '../../../scripts/rollup.js'

export default [
...rollupBundle('node/index', {
dtsExternal: ['@vuepress/helper/shared'],
}),
...rollupBundle('client/index', {
dtsExternal: ['@vuepress/helper/shared'],
}),
]
1 change: 1 addition & 0 deletions plugins/development/plugin-rtl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"dependencies": {
Expand Down
9 changes: 9 additions & 0 deletions plugins/development/plugin-rtl/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { rollupBundle } from '../../../scripts/rollup.js'

export default [
...rollupBundle('node/index'),
...rollupBundle({
base: 'client',
files: ['config', 'index'],
}),
]
1 change: 1 addition & 0 deletions plugins/development/plugin-sass-palette/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"dependencies": {
Expand Down
5 changes: 5 additions & 0 deletions plugins/development/plugin-sass-palette/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { rollupBundle } from '../../../scripts/rollup.js'

export default rollupBundle('node/index', {
external: ['chokidar'],
})
1 change: 1 addition & 0 deletions plugins/development/plugin-theme-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo",
"copy": "cpx \"src/**/*.d.ts\" lib"
},
Expand Down
14 changes: 14 additions & 0 deletions plugins/development/plugin-theme-data/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { rollupBundle } from '../../../scripts/rollup.js'

export default [
...rollupBundle('node/index'),
...rollupBundle(
{
base: 'client',
files: ['config', 'index'],
},
{
external: ['@internal/themeData', '@vue/devtools-api'],
},
),
]
1 change: 1 addition & 0 deletions plugins/development/plugin-toc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo"
},
"dependencies": {
Expand Down
14 changes: 14 additions & 0 deletions plugins/development/plugin-toc/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { rollupBundle } from '../../../scripts/rollup.js'

export default [
...rollupBundle('node/index'),
...rollupBundle(
{
base: 'client',
files: ['config', 'index'],
},
{
external: ['vue-router'],
},
),
]
1 change: 1 addition & 0 deletions plugins/features/plugin-back-to-top/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
"clean": "rimraf --glob ./lib ./*.tsbuildinfo",
"copy": "cpx \"src/**/*.svg\" lib",
"style": "sass src:lib --embed-sources --style=compressed"
Expand Down
Loading

0 comments on commit 152772f

Please sign in to comment.