Files
klz-cables.com/.pnpm-store/v10/files/3f/b376900354caa42b77cf22ac3730ea183b166205a8b88a5de58eb3ffba78b58027bada292da5b8105fbf5b7a6259bea75944c991b2dc57dd4bcbafcb532fb5
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

60 lines
1.8 KiB
Plaintext

import ExtractionCompiler from '../../extractor/ExtractionCompiler.js';
import { isDevelopment, isNextBuild } from '../config.js';
import { once } from '../utils.js';
// Single compiler instance, initialized once per process
let compiler;
const runOnce = once('_NEXT_INTL_EXTRACT');
function initExtractionCompiler(pluginConfig) {
const experimental = pluginConfig.experimental;
if (!experimental?.extract) {
return;
}
// Avoid running for:
// - info
// - start
// - typegen
//
// Doesn't consult Next.js config anyway:
// - telemetry
// - lint
//
// What remains are:
// - dev (NODE_ENV=development)
// - build (NODE_ENV=production)
const shouldRun = isDevelopment || isNextBuild;
if (!shouldRun) return;
runOnce(() => {
const extractorConfig = {
srcPath: experimental.srcPath,
sourceLocale: experimental.extract.sourceLocale,
messages: experimental.messages
};
compiler = new ExtractionCompiler(extractorConfig, {
isDevelopment,
projectRoot: process.cwd()
});
// Fire-and-forget: Start extraction, don't block config return.
// In dev mode, this also starts the file watcher.
// In prod, ideally we would wait until the extraction is complete,
// but we can't `await` anywhere (at least for Turbopack).
// The result is ok though, as if we encounter untranslated messages,
// we'll simply add empty messages to the catalog. So for actually
// running the app, there is no difference.
compiler.extractAll();
function cleanup() {
if (compiler) {
compiler[Symbol.dispose]();
compiler = undefined;
}
}
process.on('exit', cleanup);
process.on('SIGINT', cleanup);
process.on('SIGTERM', cleanup);
});
}
export { initExtractionCompiler as default };