diff --git a/packages/cli/rolldown.config.ts b/packages/cli/rolldown.config.ts index 549daae60e..265ef651b5 100644 --- a/packages/cli/rolldown.config.ts +++ b/packages/cli/rolldown.config.ts @@ -30,20 +30,28 @@ export default defineConfig({ if (source === '../../binding/index.js' || source === '../binding/index.js') { return true; } + if (source === '../versions.js') { + return true; + } return false; }, plugins: [ { - name: 'fix-binding-path', - // Rewrite the binding import path for the output directory. - // Source files import from ../../binding/index.js (relative to src/*/). - // Output is in dist/global/, so the correct path is ../../binding/index.js (two dirs up). - // Rolldown normalizes it to ../binding/index.js which is wrong. + name: 'fix-external-paths', + // Rewrite external import paths for the output directory (dist/global/). + // Rolldown normalizes relative paths from source locations, but the output + // is two directories deep (dist/global/), so the paths need adjustment. renderChunk(code) { - if (code.includes('../binding/index.js')) { - return { code: code.replaceAll('../binding/index.js', '../../binding/index.js') }; + let result = code; + // ../../binding/index.js → Rolldown normalizes to ../binding/index.js, needs ../../ + if (result.includes('../binding/index.js')) { + result = result.replaceAll('../binding/index.js', '../../binding/index.js'); } - return null; + // ../versions.js → Rolldown normalizes to ./versions.js, needs ../ + if (result.includes('./versions.js')) { + result = result.replaceAll('./versions.js', '../versions.js'); + } + return result !== code ? { code: result } : null; }, }, { diff --git a/packages/cli/src/migration/migrator.ts b/packages/cli/src/migration/migrator.ts index 74d5c40595..aa0fa0ea0c 100644 --- a/packages/cli/src/migration/migrator.ts +++ b/packages/cli/src/migration/migrator.ts @@ -233,7 +233,10 @@ export async function migrateEslintToOxlint( // Steps 1-2: Only run @oxlint/migrate if there's an eslint config at root if (eslintConfigFile) { - const migratePackage = '@oxlint/migrate'; + // Pin @oxlint/migrate to the bundled oxlint version. + // @ts-expect-error — resolved at runtime from dist/global/ → dist/versions.js + const { versions } = await import('../versions.js'); + const migratePackage = `@oxlint/migrate@${versions.oxlint}`; // Step 1: Generate .oxlintrc.json from ESLint config spinner.start('Migrating ESLint config to Oxlint...');