Skip to content

Commit df34c13

Browse files
authored
fix(migration): pin @oxlint/migrate to bundled oxlint version (#1243)
Prevent version drift between @oxlint/migrate and the oxlint binary shipped with vite-plus. Without this, `vp migrate` fetches the latest @oxlint/migrate from npm, which may reference rules not yet supported by the bundled oxlint, causing `vp lint` errors after migration.
1 parent a077447 commit df34c13

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

packages/cli/rolldown.config.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,28 @@ export default defineConfig({
3030
if (source === '../../binding/index.js' || source === '../binding/index.js') {
3131
return true;
3232
}
33+
if (source === '../versions.js') {
34+
return true;
35+
}
3336
return false;
3437
},
3538
plugins: [
3639
{
37-
name: 'fix-binding-path',
38-
// Rewrite the binding import path for the output directory.
39-
// Source files import from ../../binding/index.js (relative to src/*/).
40-
// Output is in dist/global/, so the correct path is ../../binding/index.js (two dirs up).
41-
// Rolldown normalizes it to ../binding/index.js which is wrong.
40+
name: 'fix-external-paths',
41+
// Rewrite external import paths for the output directory (dist/global/).
42+
// Rolldown normalizes relative paths from source locations, but the output
43+
// is two directories deep (dist/global/), so the paths need adjustment.
4244
renderChunk(code) {
43-
if (code.includes('../binding/index.js')) {
44-
return { code: code.replaceAll('../binding/index.js', '../../binding/index.js') };
45+
let result = code;
46+
// ../../binding/index.js → Rolldown normalizes to ../binding/index.js, needs ../../
47+
if (result.includes('../binding/index.js')) {
48+
result = result.replaceAll('../binding/index.js', '../../binding/index.js');
4549
}
46-
return null;
50+
// ../versions.js → Rolldown normalizes to ./versions.js, needs ../
51+
if (result.includes('./versions.js')) {
52+
result = result.replaceAll('./versions.js', '../versions.js');
53+
}
54+
return result !== code ? { code: result } : null;
4755
},
4856
},
4957
{

packages/cli/src/migration/migrator.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ export async function migrateEslintToOxlint(
233233

234234
// Steps 1-2: Only run @oxlint/migrate if there's an eslint config at root
235235
if (eslintConfigFile) {
236-
const migratePackage = '@oxlint/migrate';
236+
// Pin @oxlint/migrate to the bundled oxlint version.
237+
// @ts-expect-error — resolved at runtime from dist/global/ → dist/versions.js
238+
const { versions } = await import('../versions.js');
239+
const migratePackage = `@oxlint/migrate@${versions.oxlint}`;
237240

238241
// Step 1: Generate .oxlintrc.json from ESLint config
239242
spinner.start('Migrating ESLint config to Oxlint...');

0 commit comments

Comments
 (0)