Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/cli/bin/oxfmt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ if (!process.argv.includes('--lsp')) {

import { createRequire } from 'node:module';
import { pathToFileURL } from 'node:url';
import pkg from '../package.json' with { type: 'json' };

const require = createRequire(import.meta.url);
const oxfmtBin = require.resolve('oxfmt/bin/oxfmt');

// This allows oxfmt to load vite.config.ts
// For `vp check` and `vp fmt`, see `src/utils/constants.ts`
process.env.VITE_PLUS_VERSION = pkg.version;
await import(pathToFileURL(oxfmtBin).href);
4 changes: 4 additions & 0 deletions packages/cli/bin/oxlint
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ if (!process.argv.includes('--lsp')) {
import { createRequire } from 'node:module';
import { dirname, join } from 'node:path';
import { pathToFileURL } from 'node:url';
import pkg from '../package.json' with { type: 'json' };

const require = createRequire(import.meta.url);
const oxlintMainPath = require.resolve('oxlint');
const oxlintBin = join(dirname(dirname(oxlintMainPath)), 'bin', 'oxlint');

// This allows oxlint to load vite.config.ts
// For `vp check` and `vp lint`, see `src/utils/constants.ts`
process.env.VITE_PLUS_VERSION = pkg.version;
await import(pathToFileURL(oxlintBin).href);
3 changes: 3 additions & 0 deletions packages/cli/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ export const DEFAULT_ENVS = {
JS_RUNTIME_NAME: process.release.name,
// Indicate that vite-plus is the package manager
NODE_PACKAGE_MANAGER: 'vite-plus',
// This allows oxlint/oxfmt to load vite.config.ts
// For `--lsp` path, see `bin/oxlint` and `bin/oxfmt`
VITE_PLUS_VERSION,
} as const;
Loading