{"record":{"id":"94561f404071169d","repo":"parcel-bundler/parcel","slug":"no-dynamic-require-possible-workerpath","errorCode":null,"errorMessage":"No dynamic require possible: ${workerPath}","messagePattern":"No dynamic require possible: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/workers/src/WorkerFarm.js","lineNumber":111,"sourceCode":"        farmOptions.shouldTrace ? 1 : DEFAULT_MAX_CONCURRENT_CALLS,\n      ),\n      forcedKillTime: 500,\n      warmWorkers: false,\n      useLocalWorker: true, // TODO: setting this to false makes some tests fail, figure out why\n      backend: detectBackend(),\n      ...farmOptions,\n    };\n\n    if (!this.options.workerPath) {\n      throw new Error('Please provide a worker path!');\n    }\n\n    // $FlowFixMe\n    if (process.browser) {\n      if (this.options.workerPath === '@parcel/core/src/worker.js') {\n        this.localWorker = coreWorker;\n      } else {\n        throw new Error(\n          'No dynamic require possible: ' + this.options.workerPath,\n        );\n      }\n    } else {\n      // $FlowFixMe this must be dynamic\n      this.localWorker = require(this.options.workerPath);\n    }\n\n    this.localWorkerInit =\n      this.localWorker.childInit != null ? this.localWorker.childInit() : null;\n\n    this.run = this.createHandle('run');\n\n    // Worker thread stdout is by default piped into the process stdout, if there are enough worker\n    // threads to exceed the default listener limit, then anything else piping into stdout will trigger\n    // the `MaxListenersExceededWarning`, so we should ensure the max listeners is at least equal to the\n    // number of workers + 1 for the main thread.\n    //","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/workers/src/WorkerFarm.js#L93-L129","documentation":"Thrown by WorkerFarm when process.browser is true (running in a browser bundle) and options.workerPath is not the one allowed browser entry '@parcel/core/src/worker.js'. In a browser there is no dynamic require, so only the pre-bundled coreWorker reference is permitted; any other path is rejected.","triggerScenarios":"Bundling @parcel/workers for the browser (e.g. with webpack/rollup) and setting workerPath to a custom module; running Parcel's worker code in a browser context that is not the bundled core worker.","commonSituations":"Reusing @parcel/workers in a browser/web worker toolchain; accidentally including Parcel's worker code in a web bundle via a misconfigured bundler; web-based Parcel playgrounds.","solutions":["In browser builds, leave workerPath unset or set it to '@parcel/core/src/worker.js' so the pre-bundled coreWorker is used.","Avoid bundling @parcel/workers into browser code unless you specifically support the web worker backend.","Use the 'web' worker backend and ensure the bundler exposes coreWorker via the expected module id."],"exampleFix":"// before (browser bundle)\nnew WorkerFarm({ workerPath: './myWorker.js' });\n\n// after\nnew WorkerFarm({ workerPath: '@parcel/core/src/worker.js' });","handlingStrategy":"validation","validationCode":"if (process.browser && options.workerPath !== '@parcel/core/src/worker.js') {\n  throw new Error('In browser builds only the bundled core worker path is allowed.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In browser bundles, default workerPath to '@parcel/core/src/worker.js'.","Avoid bundling @parcel/workers into the browser unless you support the web backend.","Mark Node-only worker modules as external/excluded in the browser bundler config."],"tags":["worker-farm","browser","dynamic-require","parcel-workers"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}