How to deal with turbopack erroring out when encountering optional peerDependencies?
Unanswered
Lenz Weber-Tronic posted this in #help-forum
Now that
Now, the server-side code includes
Is there any way to have turbopack deal with this gracefully, e.g. by transpiling the
turbopack is the default, we get more users also using that for server-side code, since of course it also bundles route handlers etc.Now, the server-side code includes
@apollo/server, which in a try..catch block tries to import an optional peerDependency - which causes turbopack to error.> Build error occurred
Error: Turbopack build failed with 1 errors:
./node_modules/.pnpm/@apollo+server@5.1.0_graphql@16.12.0/node_modules/@apollo/server/dist/cjs/incrementalDeliveryPolyfill.js:44:75
Module not found: Can't resolve '@yaacovcr/transform'
42 | async function tryToLoadLegacyExecuteIncrementally() {
43 | try {
> 44 | const transform = await Promise.resolve().then(() => __importStar(require('@yaacovcr/transform')));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45 | legacyExecuteIncrementally = transform.legacyExecuteIncrementally;
46 | }
47 | catch {Is there any way to have turbopack deal with this gracefully, e.g. by transpiling the
require call to (() => throw new Error("module not found"))() or something similar?