Skip to content

chore(core): align tsconfig moduleResolution with bundler - #3475

Merged
eduardoformiga merged 1 commit into
devfrom
chore/core-tsconfig-bundler-resolution
Sep 8, 2026
Merged

chore(core): align tsconfig moduleResolution with bundler#3475
eduardoformiga merged 1 commit into
devfrom
chore/core-tsconfig-bundler-resolution

Conversation

@eduardoformiga

@eduardoformiga eduardoformiga commented Sep 2, 2026

Copy link
Copy Markdown
Member

What's the purpose of this pull request?

On v4.6.0, Next.js rewrites the generated .faststore/tsconfig.json on every dev/build and logs We detected TypeScript in your project and reconfigured your tsconfig.json file.

@faststore/cli copies packages/core/tsconfig.json almost verbatim into each store's .faststore/tsconfig.json, and that file still had "moduleResolution": "node". Next 16 (next/dist/lib/typescript/writeConfigurationDefaults.js) treats moduleResolution as a required option: for TypeScript >= 5 with module: esnext it only accepts bundler | node16 | nodenext, so "node" is rewritten to "bundler" before Next runs its own type-check — every time, in every store.

How it works?

One-line change: packages/core/tsconfig.json moduleResolution goes from "node" to "bundler", matching the root tsconfig.json and every other package in the monorepo (api, sdk, ui, components, diagnostics).

This is not a behaviour change for stores: Next already forces "bundler" on the file it type-checks with, so next build has been running under bundler resolution all along. The change only (a) removes the drift between the committed config and what Next actually uses, so the "reconfigured your tsconfig.json" message stops appearing, and (b) makes editor / standalone tsc diagnostics match the real build.

How to test it?

  • cd packages/core && pnpm exec tsc --noEmit -p tsconfig.json with and without --moduleResolution node: the outputs are byte-identical (same 122 pre-existing errors, all under test/**, zero under src/).
  • pnpm lint and cd packages/cli && pnpm test (173 tests, including the .faststore tsconfig copy tests) pass.
  • In a store using this build: run yarn dev / yarn build and confirm the reconfigured your tsconfig.json message is gone and .faststore/tsconfig.json is left untouched by Next. Verified in a Yarn 1 workspaces monorepo: the generated .faststore/tsconfig.json already carries "moduleResolution": "bundler" and Next no longer reports a reconfiguration.

Starters Deploy Preview

Pending CodeSandbox build for this PR.

References

Made with Cursor

Summary by CodeRabbit

  • Chores
    • Updated internal module resolution settings to improve compatibility with modern bundling workflows.

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.
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 0e772dc1-5906-4152-ab79-40321b183157

📥 Commits

Reviewing files that changed from the base of the PR and between cc7941a and 843b659.

📒 Files selected for processing (1)
  • packages/core/tsconfig.json

Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


Walkthrough

The core package changes TypeScript module resolution from node to bundler in its configuration.

Changes

Core TypeScript configuration

Layer / File(s) Summary
Bundler module resolution
packages/core/tsconfig.json
The configuration changes moduleResolution from node to bundler.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 843b6

This localized configuration change aligns generated store settings with the Next.js build behavior and prevents repeated tsconfig rewrites and warnings; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: updating core TypeScript module resolution to match the bundler configuration.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/core-tsconfig-bundler-resolution

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

@eduardoformiga
eduardoformiga marked this pull request as ready for review September 2, 2026 21:11
@eduardoformiga
eduardoformiga requested a review from a team as a code owner September 2, 2026 21:11
@eduardoformiga
eduardoformiga requested review from gabpaladino and ommeirelles and removed request for a team September 2, 2026 21:11
@sonar-workflows

Copy link
Copy Markdown

@hellofanny

Copy link
Copy Markdown
Contributor

Validated this against a real store (Yarn 1 classic, Next.js 16.2.6, TypeScript 5.9.3, module: esnext).

Confirmed the fix works as described:

  • Installed @faststore/cli from this PR's head commit (843b659) via pkg.pr.new.
  • .faststore/tsconfig.json is generated with "moduleResolution": "bundler".
  • The "We detected TypeScript in your project and reconfigured your tsconfig.json file" warning is gone.
  • yarn build completed successfully — TypeScript step finished cleanly (no errors), all pages generated.

Unrelated note, but worth flagging for other Yarn Classic (v1) testers: installing this build initially failed at runtime with:

SyntaxError: Named export 'onExit' not found. The requested module 'signal-exit' is a CommonJS module...

This isn't caused by this PR's change — it's inherent to the v4 base @faststore/cli's dependency tree (oclif@^4 + @inquirer/prompts@^7.10.1), which nests several @inquirer/* sub-packages (expand, password, checkbox, search, number, rawlist, editor, etc.) each requiring signal-exit@^4.1.0 (ESM named exports). Under Yarn 1, some of the deeply-nested copies don't get their own hoisted/nested signal-exit, and resolve up to an older signal-exit@3.0.7 (CJS-only, hoisted from unrelated deps like execa/cli-cursor/nyc) — which crashes on the named onExit import.

This is the same class of issue the official v4 upgrade guide already documents for @inquirer/type (monorepo stores need "resolutions": { "@inquirer/type": "^1.5.5" }) — just surfacing on a different nested package. Adding:

"resolutions": {
  "signal-exit": "^4.1.0"
}

fixed it for me. Might be worth adding to that same doc/guide alongside the @inquirer/type note, since any Yarn 1 store on v4+ will likely hit this regardless of this specific PR.

Also re-tested against the combined #3478 integration build (01e29fe, bundles #3474/#3475/#3476/#3477) with the same signal-exit resolution in place — clean build there too.

@eduardoformiga
eduardoformiga merged commit 715f7a4 into dev Sep 8, 2026
18 of 20 checks passed
@eduardoformiga
eduardoformiga deleted the chore/core-tsconfig-bundler-resolution branch September 8, 2026 23:11
eduardoformiga added a commit that referenced this pull request Sep 8, 2026
)

## What's the purpose of this pull request?

A store cloned under a directory whose name contains a space (e.g.
`/Users/me/My Store/store`, `C:\Users\John Doe\...`) cannot run
`faststore build` / `faststore dev` / `faststore generate`:

```
[STARTED] Load GraphQL documents
[FAILED] Failed to load documents from /Users/me/My Store/store/.faststore/src/**/*.{ts,tsx},!/Users/me/My Store/store/.faststore/@generated/:
[FAILED] Failed to parse the GraphQL document. Syntax Error: Unexpected character: "/".
```

This had been assumed fixed by #3454 — it is not: #3454 fixed the `next`
binary resolution, this is a different failure in the GraphQL codegen
step. Reproduced on `4.6.0` and on `dev` (`4.7.1-dev.2`) with a real
Yarn 1 workspaces store cloned under a path with a space.

Root cause: `generate-types.ts` passed the codegen `documents` glob and
the `generates` output dir as **absolute paths**. `@graphql-tools/load`
(`isDocumentString`) treats any pointer that contains whitespace and is
not parseable SDL as a broken inline document and throws instead of
falling through to the glob loader. The `@graphql-codegen/client-preset`
also appends `!<outputDir>` to the documents, so the output dir hit the
same check.

## How it works?

- New `getCodegenPointers(root, cwd = process.cwd())` builds the
`documents` glob, the `schema` path and the output dir **relative to the
directory codegen resolves pointers from**, so the parent directories
(where the space lives) are never part of the pointer:
- `.faststore/src/**/*.{ts,tsx}` /
`.faststore/@generated/schema.graphql` / `.faststore/@generated/`
- Glob-special characters in the relative segments are still escaped
(`globby.convertPathToPattern`, same approach as #3454 for the typeDefs
glob); the schema and output dir are plain paths, not globs, so they are
not escaped.
- Symlinks are resolved on both sides (`/var` → `/private/var` on macOS)
so the relative path does not climb back through the parents.
- `genTsTypes` now awaits the codegen run (it was fire-and-forget).
- CLI `vitest.config.ts`: alias `graphql` to its CJS build. The code
under test and the externalized `@graphql-tools/*` otherwise load two
`graphql` instances and fail `instanceof` checks ("Duplicate graphql
modules"), which made an end-to-end test of the generator impossible.

No behaviour change for paths without spaces: the same files are matched
and written, only the pointer form changes.

## How to test it?

- `cd packages/cli && pnpm test` — 177 tests. New in
`generate-types.test.ts`:
- `getCodegenPointers` never embeds the absolute project path, targets
`.faststore` when present, escapes glob-special characters only in the
glob.
- `genTsTypes` end-to-end from a store under `<tmp>/faststore gen (x86)
XXXX/store`: merges a custom `thirdParty` typeDef and generates
`graphql.ts` containing the query type.
- Manual: clone any store into a directory with a space, install this
CLI build and run `yarn build`. On `dev` it fails at "Load GraphQL
documents"; with this branch the generate step completes.

### Starters Deploy Preview

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

## References

- #3454 (`next` binary resolution — different issue, same symptom
family)
- Companion PRs (independent): #3474, #3475, #3477

Made with [Cursor](https://cursor.com)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved CLI TypeScript type generation for projects located in paths
containing spaces, special characters, or symlinks.
  * Ensured type generation completes reliably before the CLI proceeds.

* **Tests**
* Expanded automated coverage for schema discovery, path handling, and
generated TypeScript output.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

2 participants