This commit is contained in:
Kevin Krausse 2026-09-26 08:50:30 -04:00 • committed by GitHub
commit ef95d0f48e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 81 additions and 3 deletions

View file

@ -382,9 +382,10 @@ impl Scanner {
return (vec![], vec![], vec![]);
};
// Use synchronous walk for the initial build (lower overhead) and parallel
// walk for subsequent calls (watch mode) where the overhead is amortised.
let all_entries = if self.has_scanned_once {
// Use synchronous walk for the initial build (lower overhead). On supported
// platforms, use the parallel walk for subsequent calls where the overhead
// is amortised.
let all_entries = if self.has_scanned_once && cfg!(any(unix, windows)) {
walk_parallel(walker)
} else {
walk_synchronous(walker)

View file

@ -58,6 +58,83 @@ testFn(
},
)
testFn(
'@tailwindcss/oxide-wasm32-wasi discovers changes across incremental scans',
{
fs: {
'package.json': json`
{
"dependencies": {
"@tailwindcss/oxide-wasm32-wasi": "workspace:^"
}
}
`,
'src/index.js': js`const className = 'flex'`,
'index.mjs': js`
import { Scanner } from '@tailwindcss/oxide-wasm32-wasi'
import { readFileSync, statSync, utimesSync, writeFileSync } from 'node:fs'
import { join, relative } from 'node:path'
let source = join(process.cwd(), 'src/index.js')
let scanner = new Scanner({
sources: [
{
base: join(process.cwd(), 'src'),
pattern: '**/*',
negated: false,
},
],
})
function scan() {
let candidates = scanner.scan()
return {
candidates: candidates.filter(
(candidate) => candidate === 'flex' || candidate === 'grid',
),
files: scanner.files.map((file) => relative(process.cwd(), file)),
scannedFiles: scanner.scannedFiles.map((file) => relative(process.cwd(), file)),
}
}
let initial = scan()
let unchanged = scan()
writeFileSync(source, readFileSync(source, 'utf8').replace('flex', 'grid'))
let mtime = statSync(source).mtime
utimesSync(source, mtime, new Date(mtime.getTime() + 2000))
let changed = scan()
console.log(JSON.stringify({ initial, unchanged, changed }))
process.exit()
`,
},
},
async ({ expect, exec }) => {
let output = await exec(`node index.mjs`)
expect(JSON.parse(output)).toEqual({
initial: {
candidates: ['flex'],
files: ['src/index.js'],
scannedFiles: ['src/index.js'],
},
unchanged: {
candidates: ['flex'],
files: ['src/index.js'],
scannedFiles: [],
},
changed: {
candidates: ['flex', 'grid'],
files: ['src/index.js'],
scannedFiles: ['src/index.js'],
},
})
},
)
testFn(
'`@tailwindcss/oxide` falls back to the wasm build when no native binding is available',
{