[Issue]: Can't generate client in 0.177, fails with DTS errors
RayHughes opened this issue · comments
Description
When attempting to generate a client for distribution, the DTS build fails with the following error:
../.wundergraph/generated/wundergraph.internal.client.ts(3,15): error TS2305: Module '"@wundergraph/sdk/server"' has no exported member 'OperationArgsWithInput'.
../.wundergraph/generated/wundergraph.internal.client.ts(3,39): error TS2305: Module '"@wundergraph/sdk/server"' has no exported member 'InternalClient'.
It seems that the internal client generated is referencing legacy imports.
Reproduction
yarn generate
yarn --cwd client/ build <-- fails
TSUP config
export default defineConfig({
entry: [
'../.wundergraph/generated/client.ts',
'../.wundergraph/generated/nextjs.ts',
],
splitting: false,
bundle: true,
clean: true,
dts: true,
outDir: 'dist',
format: ['cjs', 'esm'],
esbuildOptions(options) {
options.external = ['react'];
},
});
Thanks for reporting @RayHughes, we removed the old internal client, but the old generated one doesn't get deleted, causing your build errors.
You can safely remove this file and then your build should work again.
@Pagebakers i do not have this file in git and seems to be generated when the build runs generate.
So this happens locally also after you delete the generated folder first?
Will verify in the morning, but I believe I tried clearing yarn cache and wg generated folder. We don't cache in our ci/cd.
Thanks, I just checked and it doesn't get generated any longer. Not sure what it can be on your CI, but please let us know in the morning.
Running into the same issue too. Works with 0.176.0 but fails with 0.177.0
@Pagebakers @0xJem I figured out the issue:
It's caused by the wundergraph.server.ts
file. If a project was built with a legacy version of WG, the server file is typed with the InternalClient. This is not the case in the newer versions of WG.
Might be worth adding as a release note.
Change
import { configureWunderGraphServer } from '@wundergraph/sdk/server';
import type { HooksConfig } from './generated/wundergraph.hooks';
import type { InternalClient } from './generated/wundergraph.internal.client';
export default configureWunderGraphServer<HooksConfig, InternalClient>(() => ({
hooks: {
queries: {}
}
}));
To:
import { configureWunderGraphServer } from '@wundergraph/sdk/server';
export default configureWunderGraphServer(() => ({
hooks: {
queries: {},
},
}));
This worked, thanks!