Skip to content

Commit bb56d69

Browse files
committed
build: split vite plus core and test
1 parent 5c5403a commit bb56d69

66 files changed

Lines changed: 2907 additions & 2470 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/build-upstream/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ runs:
2121
fi
2222
pnpm --filter rolldown build-node
2323
pnpm --filter rolldown-vite build-types
24+
pnpm --filter=@voidzero-dev/vite-plus-core build
25+
pnpm --filter=@voidzero-dev/vite-plus-test build
2426
CC=clang pnpm --filter=@voidzero-dev/vite-plus build --target ${{ inputs.target }} --use-napi-cross
2527
env:
2628
TARGET_CC: clang
@@ -35,6 +37,8 @@ runs:
3537
fi
3638
pnpm --filter rolldown build-node
3739
pnpm --filter rolldown-vite build-types
40+
pnpm --filter=@voidzero-dev/vite-plus-core build
41+
pnpm --filter=@voidzero-dev/vite-plus-test build
3842
TARGET_CFLAGS="-D_BSD_SOURCE" pnpm --filter=@voidzero-dev/vite-plus build --target ${{ inputs.target }} --use-napi-cross
3943
env:
4044
TARGET_CC: clang
@@ -49,4 +53,6 @@ runs:
4953
fi
5054
pnpm --filter rolldown build-node
5155
pnpm --filter rolldown-vite build-types
56+
pnpm --filter=@voidzero-dev/vite-plus-core build
57+
pnpm --filter=@voidzero-dev/vite-plus-test build
5258
pnpm --filter=@voidzero-dev/vite-plus build --target ${{ inputs.target }}

.github/workflows/release.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,16 @@ jobs:
9292
if-no-files-found: error
9393
- name: Remove .node files before upload dist
9494
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
95-
run: rm ./packages/cli/dist/**/*.node
95+
run: |
96+
rm ./packages/core/dist/**/*.node
97+
98+
- name: Upload core dist
99+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
100+
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
101+
with:
102+
name: core
103+
path: ./packages/core/dist
104+
if-no-files-found: error
96105

97106
- name: Upload cli dist
98107
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
@@ -133,13 +142,19 @@ jobs:
133142

134143
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
135144
with:
136-
path: packages/cli/dist
145+
path: packages/cli/dist/binding
137146
pattern: vite-plus-native-*
138147
merge-multiple: true
139148

140149
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
141150
with:
142-
path: packages/cli/dist/rolldown/shared
151+
path: packages/core/dist
152+
pattern: core
153+
merge-multiple: true
154+
155+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
156+
with:
157+
path: packages/core/dist/rolldown/shared
143158
pattern: rolldown-native-*
144159
merge-multiple: true
145160

@@ -149,10 +164,15 @@ jobs:
149164
pattern: global
150165
merge-multiple: true
151166

167+
- name: Build test
168+
run: pnpm --filter=@voidzero-dev/vite-plus-test build
169+
152170
- name: Set npm packages version
153171
run: |
154-
sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/global/package.json
172+
sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/core/package.json
173+
sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/test/package.json
155174
sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/cli/package.json
175+
sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/global/package.json
156176
157177
# Setup node correctly for publishing to github registry
158178
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
@@ -166,7 +186,9 @@ jobs:
166186

167187
- name: Publish
168188
run: |
169-
pnpm publish --filter=./packages/global --registry https://npm.pkg.github.com --no-git-checks
189+
pnpm publish --filter=./packages/core --registry https://npm.pkg.github.com --no-git-checks
190+
pnpm publish --filter=./packages/test --registry https://npm.pkg.github.com --no-git-checks
170191
pnpm publish --filter=./packages/cli --registry https://npm.pkg.github.com --no-git-checks
192+
pnpm publish --filter=./packages/global --registry https://npm.pkg.github.com --no-git-checks
171193
env:
172194
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.oxfmtrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"ignorePatterns": [
4+
"packages/cli/binding/index.d.ts",
5+
"packages/cli/binding/index.js"
6+
],
7+
"singleQuote": true
8+
}

bench/generate-monorepo.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ class MonorepoGenerator {
147147
const hasVitePlusConfig = Math.random() > 0.3;
148148

149149
// Select dependencies from packages created before this one
150-
const dependencies = i === 0 ? [] : this.selectDependencies(i, allPackageNames.slice(0, i));
150+
const dependencies =
151+
i === 0 ? [] : this.selectDependencies(i, allPackageNames.slice(0, i));
151152

152153
this.packages.set(packageName, {
153154
name: packageName,
@@ -181,9 +182,15 @@ class MonorepoGenerator {
181182

182183
// Create the scenario: A has build, B doesn't, C has build
183184
const scriptName = this.getRandomElement(this.SCRIPT_NAMES);
184-
pkgA.scripts[scriptName] = this.generateScriptCommand(scriptName, nameA);
185+
pkgA.scripts[scriptName] = this.generateScriptCommand(
186+
scriptName,
187+
nameA,
188+
);
185189
delete pkgB.scripts[scriptName]; // B doesn't have the script
186-
pkgC.scripts[scriptName] = this.generateScriptCommand(scriptName, nameC);
190+
pkgC.scripts[scriptName] = this.generateScriptCommand(
191+
scriptName,
192+
nameC,
193+
);
187194
}
188195
}
189196
}
@@ -201,10 +208,13 @@ class MonorepoGenerator {
201208
version: '1.0.0',
202209
main: 'src/index.js',
203210
scripts: pkg.scripts,
204-
dependencies: pkg.dependencies.reduce((deps, dep) => {
205-
deps[`@monorepo/${dep}`] = 'workspace:*';
206-
return deps;
207-
}, {} as Record<string, string>),
211+
dependencies: pkg.dependencies.reduce(
212+
(deps, dep) => {
213+
deps[`@monorepo/${dep}`] = 'workspace:*';
214+
return deps;
215+
},
216+
{} as Record<string, string>,
217+
),
208218
};
209219

210220
fs.writeFileSync(
@@ -352,11 +362,9 @@ module.exports = { ${pkg.name.replace('-', '_')} };
352362
console.log('\nStatistics:');
353363
console.log(`- Total packages: ${this.packages.size}`);
354364
console.log(
355-
`- Average dependencies per package: ${
356-
(
357-
totalDeps / this.packages.size
358-
).toFixed(2)
359-
}`,
365+
`- Average dependencies per package: ${(
366+
totalDeps / this.packages.size
367+
).toFixed(2)}`,
360368
);
361369
console.log(`- Max dependencies in a package: ${maxDeps}`);
362370
console.log(`- Packages with vite-plus.json: ${packagesWithVitePlus}`);

docs/.vitepress/config.mts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ export default defineConfig({
66
description: 'Vite+',
77
themeConfig: {
88
// https://vitepress.dev/reference/default-theme-config
9-
nav: [
10-
{ text: 'Home', link: '/' },
11-
],
9+
nav: [{ text: 'Home', link: '/' }],
1210

1311
sidebar: [],
1412

dprint.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
"quotes": "preferSingle"
1414
},
1515
"excludes": [
16+
"**/*.ts",
17+
"**/*.tsx",
18+
"**/*.js",
19+
"**/*.jsx",
1620
"crates/fspy_detours_sys/detours",
1721
"pnpm-lock.yaml",
1822
"packages/cli/binding/index.d.ts",

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"install-global-cli": "npm install -g ./packages/global",
1414
"typecheck": "tsc -b tsconfig.json",
1515
"lint": "vite lint --type-aware --threads 4",
16-
"test": "vite test run && pnpm --filter=@voidzero-dev/vite-plus test && pnpm -r snap-test",
16+
"test": "vite test run && pnpm -r snap-test",
1717
"prepare": "husky"
1818
},
1919
"devDependencies": {
@@ -27,14 +27,15 @@
2727
"oxfmt": "catalog:",
2828
"oxlint": "catalog:",
2929
"typescript": "catalog:",
30-
"vitest": "catalog:"
30+
"vitest": "workspace:@voidzero-dev/vite-plus-test@*"
3131
},
3232
"lint-staged": {
33-
"*.@(js|ts|tsx|yml|yaml|md|json|html|toml)": [
33+
"*.@(yml|yaml|md|json|html|toml)": [
3434
"dprint fmt --staged"
3535
],
3636
"*.@(js|ts|tsx)": [
37-
"oxlint -- --fix"
37+
"oxlint -- --fix",
38+
"oxfmt"
3839
],
3940
"*.rs": [
4041
"cargo fmt --"

packages/cli/binding/__tests__/run-command.spec.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,27 @@ test('should run command successfully', async () => {
1818

1919
// write file on the temp directory
2020
test('should write file on the temp directory', async () => {
21-
const tempDir = await fs.realpath(await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')));
21+
const tempDir = await fs.realpath(
22+
await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')),
23+
);
2224
const result = await runCommand({
2325
binName: 'node',
2426
args: ['-e', `fs.writeFileSync("test.txt", "Hello, world!")`],
2527
envs: {},
2628
cwd: tempDir,
2729
});
2830
expect(result).toMatchSnapshot();
29-
expect(await fs.readFile(path.join(tempDir, 'test.txt'), 'utf-8')).toBe('Hello, world!');
31+
expect(await fs.readFile(path.join(tempDir, 'test.txt'), 'utf-8')).toBe(
32+
'Hello, world!',
33+
);
3034
await fs.rm(tempDir, { recursive: true });
3135
});
3236

3337
// read file on the temp directory
3438
test('should read file on the temp directory', async () => {
35-
const tempDir = await fs.realpath(await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')));
39+
const tempDir = await fs.realpath(
40+
await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')),
41+
);
3642
await fs.writeFile(path.join(tempDir, 'test.txt'), 'Hello, world!');
3743
const result = await runCommand({
3844
binName: 'node',
@@ -46,10 +52,15 @@ test('should read file on the temp directory', async () => {
4652

4753
// write and read file on the temp directory
4854
test('should write and read file on the temp directory', async () => {
49-
const tempDir = await fs.realpath(await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')));
55+
const tempDir = await fs.realpath(
56+
await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')),
57+
);
5058
const result = await runCommand({
5159
binName: 'node',
52-
args: ['-e', `fs.writeFileSync("test.txt", "Hello, world!"); fs.readFileSync("test.txt", "utf-8")`],
60+
args: [
61+
'-e',
62+
`fs.writeFileSync("test.txt", "Hello, world!"); fs.readFileSync("test.txt", "utf-8")`,
63+
],
5364
envs: {},
5465
cwd: tempDir,
5566
});

0 commit comments

Comments
 (0)