@hyperfrontend/project-scope/tech/buildbuild
Build-tool detectors for the JavaScript/TypeScript build ecosystem.
Covers Webpack, Vite, Rollup, esbuild, Babel, SWC, and Parcel. Each tool exposes its <tool>Detector plus a <TOOL>_CONFIG_PATTERNS constant describing the config-file shapes it recognizes. detectBuildTools runs all detectors and returns the aggregate BuildToolDetection[]. Detectors are unopinionated about preferred build tooling — they return what they find and at what confidence; consumers decide what to do with the results.
API Reference
ƒ Functions
Detect Babel in project.
Parameters
Returns
BuildToolDetectionDetection result or null if not detected
Example
Detecting Babel compiler
const result = babelDetector('/path/to/project', {
name: 'my-app',
devDependencies: { '@babel/core': '^7.23.0', '@babel/preset-env': '^7.23.0' }
})
// => {
// id: 'babel',
// name: 'Babel',
// version: '7.23.0',
// confidence: 60,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@babel/core' },
// { type: 'package.json', field: 'dependencies (@babel packages)' }
// ]
// }Detect all build tools in project.
Parameters
Returns
BuildToolDetection[]Array of detected build tools, sorted by confidence
Example
Detecting multiple build tools
const tools = detectBuildTools('/path/to/project', {
name: 'my-app',
devDependencies: {
'vite': '^5.0.0',
'@vitejs/plugin-react': '^4.0.0',
'@babel/core': '^7.23.0'
}
})
// => [
// { id: 'vite', name: 'Vite', version: '5.0.0', confidence: 70, ... },
// { id: 'babel', name: 'Babel', version: '7.23.0', confidence: 50, ... }
// ]Detect esbuild in project.
Parameters
Returns
BuildToolDetectionDetection result or null if not detected
Example
Detecting esbuild bundler
const result = esbuildDetector('/path/to/project', {
name: 'my-lib',
devDependencies: { 'esbuild': '^0.19.0' },
scripts: { 'build': 'esbuild src/index.ts --bundle --outfile=dist/index.js' }
})
// => {
// id: 'esbuild',
// name: 'esbuild',
// version: '0.19.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.esbuild' },
// { type: 'package.json', field: 'scripts.build' }
// ]
// }Detect Parcel in project.
Parameters
Returns
BuildToolDetectionDetection result or null if not detected
Example
Detecting Parcel bundler
const result = parcelDetector('/path/to/project', {
name: 'my-app',
devDependencies: { 'parcel': '^2.10.0' },
scripts: { 'dev': 'parcel src/index.html', 'build': 'parcel build src/index.html' }
})
// => {
// id: 'parcel',
// name: 'Parcel',
// version: '2.10.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.parcel' },
// { type: 'package.json', field: 'scripts.dev' },
// { type: 'package.json', field: 'scripts.build' }
// ]
// }Detect Rollup in project.
Parameters
Returns
BuildToolDetectionDetection result or null if not detected
Example
Detecting Rollup bundler
const result = rollupDetector('/path/to/project', {
name: 'my-lib',
devDependencies: {
'rollup': '^4.0.0',
'@rollup/plugin-node-resolve': '^15.0.0',
'@rollup/plugin-commonjs': '^25.0.0'
}
})
// => {
// id: 'rollup',
// name: 'Rollup',
// version: '4.0.0',
// confidence: 65,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.rollup' },
// { type: 'package.json', field: 'dependencies (rollup plugins)' }
// ]
// }Detect SWC in project.
Parameters
Returns
BuildToolDetectionDetection result or null if not detected
Example
Detecting SWC compiler
const result = swcDetector('/path/to/project', {
name: 'my-app',
devDependencies: { '@swc/core': '^1.3.0', '@swc/cli': '^0.1.0' }
})
// => {
// id: 'swc',
// name: 'SWC',
// version: '1.3.0',
// confidence: 70,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.@swc/core' },
// { type: 'package.json', field: 'dependencies.@swc/cli' }
// ]
// }Detect Vite in project.
Parameters
Returns
BuildToolDetectionDetection result or null if not detected
Example
Detecting Vite build tool
const result = viteDetector('/path/to/project', {
name: 'my-app',
devDependencies: {
'vite': '^5.0.0',
'@vitejs/plugin-react': '^4.0.0',
'vitest': '^1.0.0'
}
})
// => {
// id: 'vite',
// name: 'Vite',
// version: '5.0.0',
// confidence: 80,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.vite' },
// { type: 'package.json', field: 'dependencies.vitest' },
// { type: 'package.json', field: 'dependencies (vite plugins)' }
// ]
// }Detect Webpack in project.
Parameters
Returns
BuildToolDetectionDetection result or null if not detected
Example
Detecting Webpack bundler
const result = webpackDetector('/path/to/project', {
name: 'my-app',
devDependencies: { 'webpack': '^5.89.0', 'webpack-cli': '^5.1.0' },
scripts: { 'build': 'webpack --mode production' }
})
// => {
// id: 'webpack',
// name: 'Webpack',
// version: '5.89.0',
// confidence: 65,
// detectedFrom: [
// { type: 'package.json', field: 'dependencies.webpack' },
// { type: 'package.json', field: 'dependencies.webpack-cli' },
// { type: 'package.json', field: 'scripts.build' }
// ]
// }◈ Interfaces
Build tool detection result.
● Variables
Config patterns for Babel
All build tool detectors
Config patterns for Parcel
Config patterns for Rollup
Config patterns for SWC
Config patterns for Vite
Config patterns for Webpack