diff --git a/apps/oxlint/.gitignore b/apps/oxlint/.gitignore index 7d6c1bcaaad85..3db66a0047980 100644 --- a/apps/oxlint/.gitignore +++ b/apps/oxlint/.gitignore @@ -1,4 +1,3 @@ /node_modules/ /dist/ -/debug/ *.node diff --git a/apps/oxlint/package.json b/apps/oxlint/package.json index 02b408c925d3e..65c3512a23a94 100644 --- a/apps/oxlint/package.json +++ b/apps/oxlint/package.json @@ -8,8 +8,8 @@ "license": "MIT", "scripts": { "build": "pnpm run build-napi-release && pnpm run build-js", - "build-dev": "pnpm run build-napi && pnpm run build-js", - "build-test": "pnpm run build-napi-test && pnpm run build-js", + "build-dev": "pnpm run build-napi && cross-env DEBUG=true pnpm run build-js", + "build-test": "pnpm run build-napi-test && cross-env DEBUG=true pnpm run build-js", "build-napi": "napi build --esm --platform --js ./bindings.js --dts ./bindings.d.ts --output-dir src-js --no-dts-cache", "build-napi-test": "pnpm run build-napi --features force_test_reporter", "build-napi-release": "pnpm run build-napi --release --features allocator", @@ -24,6 +24,7 @@ "@types/estree": "^1.0.8", "@typescript-eslint/scope-manager": "8.46.2", "@typescript-eslint/typescript-estree": "^8.47.0", + "cross-env": "catalog:", "eslint": "^9.36.0", "esquery": "^1.6.0", "execa": "^9.6.0", @@ -49,6 +50,6 @@ ] }, "imports": { - "#oxlint": "./debug/index.js" + "#oxlint": "./dist/index.js" } } diff --git a/apps/oxlint/scripts/build.ts b/apps/oxlint/scripts/build.ts index 2e423bfd4acc5..3dd3dab68754b 100755 --- a/apps/oxlint/scripts/build.ts +++ b/apps/oxlint/scripts/build.ts @@ -4,8 +4,7 @@ import { join } from 'node:path'; const oxlintDirPath = join(import.meta.dirname, '..'), srcDirPath = join(oxlintDirPath, 'src-js'), - distDirPath = join(oxlintDirPath, 'dist'), - debugDirPath = join(oxlintDirPath, 'debug'); + distDirPath = join(oxlintDirPath, 'dist'); // Modify `bindings.js` to use correct package names console.log('Modifying bindings.js...'); @@ -24,7 +23,6 @@ execSync('pnpm tsdown', { stdio: 'inherit', cwd: oxlintDirPath }); // Delete `cli.d.ts` console.log('Deleting cli.d.ts...'); rmSync(join(distDirPath, 'cli.d.ts')); -rmSync(join(debugDirPath, 'cli.d.ts')); // Copy native `.node` files from `src-js` console.log('Copying `.node` files...'); @@ -32,7 +30,6 @@ for (const filename of readdirSync(srcDirPath)) { if (!filename.endsWith('.node')) continue; const srcPath = join(srcDirPath, filename); copyFileSync(srcPath, join(distDirPath, filename)); - copyFileSync(srcPath, join(debugDirPath, filename)); } console.log('Build complete!'); diff --git a/apps/oxlint/test/e2e.test.ts b/apps/oxlint/test/e2e.test.ts index 56c976c0896c2..a74a20cd5d01f 100644 --- a/apps/oxlint/test/e2e.test.ts +++ b/apps/oxlint/test/e2e.test.ts @@ -4,7 +4,7 @@ import { PACKAGE_ROOT_PATH, getFixtures, testFixtureWithCommand } from './utils. import type { Fixture } from './utils.ts'; -const CLI_PATH = pathJoin(PACKAGE_ROOT_PATH, 'debug/cli.js'); +const CLI_PATH = pathJoin(PACKAGE_ROOT_PATH, 'dist/cli.js'); // Use current NodeJS executable, rather than `node`, to avoid problems with a Node version manager // installed on system resulting in using wrong NodeJS version diff --git a/apps/oxlint/tsdown.config.ts b/apps/oxlint/tsdown.config.ts index c7e60add42ceb..79b135f81b699 100644 --- a/apps/oxlint/tsdown.config.ts +++ b/apps/oxlint/tsdown.config.ts @@ -3,12 +3,11 @@ import { defineConfig } from 'tsdown'; import type { Plugin } from 'rolldown'; -const ASSERTS_PATH = join(import.meta.dirname, 'src-js/utils/asserts.ts'); +// When run with `DEBUG=true pnpm run build-js`, generate a debug build with extra assertions. +// This is the build used in tests. +const DEBUG = process.env.DEBUG === 'true' || process.env.DEBUG === '1'; -const replaceAssertsPlugin = createReplaceAssertsPlugin(); -const plugins = [replaceAssertsPlugin]; - -const config = defineConfig({ +export default defineConfig({ entry: ['src-js/cli.ts', 'src-js/index.ts'], format: 'esm', platform: 'node', @@ -34,24 +33,14 @@ const config = defineConfig({ }, dts: { resolve: true }, attw: true, - define: { DEBUG: 'false' }, - plugins, + define: { DEBUG: DEBUG ? 'true' : 'false' }, + plugins: DEBUG ? [] : [createReplaceAssertsPlugin()], inputOptions: { // For `replaceAssertsPlugin` experimental: { nativeMagicString: true }, }, }); -// Create separate debug build with debug assertions enabled -const debugConfig = defineConfig({ - ...config, - outDir: 'debug', - define: { DEBUG: 'true' }, - plugins: plugins.filter((plugin) => plugin !== replaceAssertsPlugin), -}); - -export default [config, debugConfig]; - /** * Create a plugin to remove imports of `assert*` functions from `src-js/utils/asserts.ts`, * and replace those imports with empty function declarations. @@ -77,6 +66,8 @@ export default [config, debugConfig]; * @returns Plugin */ function createReplaceAssertsPlugin(): Plugin { + const ASSERTS_PATH = join(import.meta.dirname, 'src-js/utils/asserts.ts'); + return { name: 'replace-asserts', transform: { diff --git a/editors/vscode/package.json b/editors/vscode/package.json index de729b892bfe3..2eb1f623ae7b6 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -259,7 +259,7 @@ "@vscode/test-cli": "^0.0.12", "@vscode/test-electron": "^2.4.1", "@vscode/vsce": "^3.0.0", - "cross-env": "^10.0.0", + "cross-env": "catalog:", "ovsx": "^0.10.0", "rolldown": "1.0.0-beta.51", "tinyglobby": "^0.2.15", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6cb83f3fd365f..51849d378cf0f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,6 +15,9 @@ catalogs: '@types/node': specifier: ^24.0.0 version: 24.9.1 + cross-env: + specifier: ^10.1.0 + version: 10.1.0 publint: specifier: 0.3.15 version: 0.3.15 @@ -104,6 +107,9 @@ importers: '@typescript-eslint/typescript-estree': specifier: ^8.47.0 version: 8.47.0(typescript@5.9.3) + cross-env: + specifier: 'catalog:' + version: 10.1.0 eslint: specifier: ^9.36.0 version: 9.38.0(jiti@2.6.1) @@ -157,7 +163,7 @@ importers: specifier: ^3.0.0 version: 3.6.2 cross-env: - specifier: ^10.0.0 + specifier: 'catalog:' version: 10.1.0 ovsx: specifier: ^0.10.0 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 3f7de3a076521..6588e16eca58f 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -12,6 +12,7 @@ catalog: '@napi-rs/cli': 3.4.1 '@napi-rs/wasm-runtime': 1.0.7 '@types/node': ^24.0.0 + cross-env: ^10.1.0 publint: 0.3.15 rolldown: 1.0.0-beta.51 tsdown: 0.16.6