Skip to content
Merged
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
1 change: 0 additions & 1 deletion apps/oxlint/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/node_modules/
/dist/
/debug/
*.node
7 changes: 4 additions & 3 deletions apps/oxlint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -49,6 +50,6 @@
]
},
"imports": {
"#oxlint": "./debug/index.js"
"#oxlint": "./dist/index.js"
}
}
5 changes: 1 addition & 4 deletions apps/oxlint/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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...');
Expand All @@ -24,15 +23,13 @@ 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...');
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!');
2 changes: 1 addition & 1 deletion apps/oxlint/test/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 8 additions & 17 deletions apps/oxlint/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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.
Expand All @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 7 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading