Skip to content

chore: integration build of the v4 migration fixes (#3474, #3475, #3476, #3477) - #3478

Closed
eduardoformiga wants to merge 10 commits into
devfrom
chore/v4-migration-fixes
Closed

eduardoformiga wants to merge 10 commits into
devfrom
chore/v4-migration-fixes

Conversation

@eduardoformiga

Copy link
Copy Markdown
Member

What's the purpose of this pull request?

Integration branch that merges the four independent fixes for the v4 migration blockers, so a single per-commit build (pkg.pr.new) can be installed in a real store and validated end-to-end before each PR is merged on its own:

Not meant to be merged — review and merge the individual PRs. This one exists only to produce the combined build; it will be closed afterwards.

How it works?

Plain merges of the four branches on top of dev (no conflicts, no extra changes).

How to test it?

Install the pkg.pr.new build of this PR's head commit in a store (@faststore/cli plus resolutions for every @faststore/* package) and run yarn build.

Starters Deploy Preview

Pending CodeSandbox / pkg.pr.new build for this PR.

References

#3474, #3475, #3476, #3477

Made with Cursor

Next.js treats moduleResolution as a required compiler option and, for
TypeScript >= 5 with module=esnext, only accepts bundler/node16/nodenext.
With "node" it rewrote every store's generated .faststore/tsconfig.json on
each dev/build and logged "reconfigured your tsconfig.json". Every other
package in the monorepo already uses "bundler"; aligning core removes the
drift between the committed config and what Next actually type-checks with.
…ublic entry

`Resolver`, `Options`, `FeatureFlags`, `PromiseType` and `ArrayElementType`
were ambient (script-scoped) declarations in `src/typings/globals.ts`. Ambient
types are not reachable from the emitted `index.d.ts`, so stores importing
`GraphqlResolver`/`APIOptions` saw them silently degrade to implicit `any`
under `strict: true`, and `GraphqlContext` was not exported at all.

Turn `globals.ts` into a real module, import the helpers explicitly where they
are used, and re-export `GraphqlContext`, `Resolver` and the helper types from
the package entry so the published typings are self-contained. Add a unit test
that compiles a consumer against the entrypoint with strict/noImplicitAny and
asserts the resolver parameters are properly typed.
Type-checking the whole package graph twice, with every @types/* package
loaded, took over 5s under coverage instrumentation and timed out in CI.
Compile both consumer snippets in a single program with `types: []` and
give the setup an explicit budget for slow runners.
Stores that extend the API (e.g. Whirlpool) type their resolvers with the
`Resolver<Root, Args, Return>` signature that `@faststore/api@3` exported.
In v4 the internal `Resolver` became a 4-parameter generic with the context
first, so re-exporting it as-is would still break those stores
(`Resolver<unknown, Args>` -> "unknown does not satisfy Record<string, any>",
`Parameters<Resolver>[2]` -> "requires between 1 and 4 type arguments").

Export `Resolver` as an alias of `GraphqlResolver` with the v3 signature
instead, so existing custom resolvers type-check without changes.
Validated against the 16 resolver files of the Whirlpool monorepo:
115 errors on 4.6.0 -> 0 with this build.
`faststore build`/`generate` passed the codegen `documents` glob and the
output directory as absolute paths. `@graphql-tools/load` treats a pointer
that contains whitespace and is not valid SDL as a broken inline document
and throws ("Failed to parse the GraphQL document. Syntax Error: Unexpected
character: '/'"), so any store cloned under a directory with a space in its
name (e.g. `/Users/me/My Store`) could not build.

Express the documents glob, the schema and the output dir relative to the
directory codegen resolves pointers from (`process.cwd()`), so the parent
directories are never part of the pointer. Glob-special characters in the
relative segments are still escaped, and symlinks are resolved on both sides
so the relative path does not climb back through the parents.

Also alias `graphql` to its CJS build in the CLI vitest config: the code
under test and the externalized @graphql-tools packages otherwise load two
instances and fail `instanceof` checks, which prevented an end-to-end test
of the generator.
…e-check

`next build` type-checks everything the `.faststore/tsconfig.json` includes.
Stores keep `*.stories.tsx` and `__mocks__/` next to their components under
`src/`, which is copied into `.faststore/src/customizations/src`, so the build
compiled them against dev-only dependencies (`@storybook/*`, `@jest/globals`)
and failed. Validated with the Whirlpool monorepo: 316 of the 331 type errors
in its v4 build came from its own stories.

Extend the exclude globs added in #3459 for test files to cover stories and
manual mocks as well.
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Comment @coderabbitai help to get the list of available commands.

@sonar-workflows

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant