Skip to content

refactor: adopt module system from effect-smol#746

Merged
patroza merged 6 commits into
mainfrom
copilot/adopt-module-system-effect-smol
May 10, 2026
Merged

refactor: adopt module system from effect-smol#746
patroza merged 6 commits into
mainfrom
copilot/adopt-module-system-effect-smol

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 10, 2026

Adopts the module system pattern from effect-smol:

Changes

1. No barrel imports from any root package index

Replaced all barrel imports from "effect-app", "effect", and "@effect-app/*" root indices with specific submodule imports throughout packages/infra, packages/vue, packages/vue-components, packages/effect-app, and packages/cli.

2. Use import * as X from "package/Module" style

Each module namespace is now imported directly from its submodule path:

  • Effect-app custom modules: import * as Effect from "effect-app/Effect", import * as Context from "effect-app/Context", import * as S from "effect-app/Schema", etc.
  • Effect modules without custom versions: import * as Cause from "effect/Cause", import * as Exit from "effect/Exit", import * as Data from "effect/Data", etc.
  • Individual utility functions (flow, pipe, identity) imported from "effect/Function" (not the "effect" root barrel)
  • @effect-app/vue barrel replaced with specific submodules: /mutate, /lib, /makeClient, /makeContext, /makeIntl

3. Remove barrel export * from "effect" from effect-app index

The export * from "effect" barrel in packages/effect-app/src/index.ts has been removed.

4. Auto-load module augmentations via submodule entry points

packages/effect-app/src/Option.ts includes import "./builtin.js" so that the declare module "effect/Option" augmentations (e.g. None<A>.value) activate automatically whenever a file does import * as Option from "effect-app/Option", without requiring the barrel index to be loaded first.

5. Fix duplicate imports

Several files had duplicate imports of the same module with different aliases (e.g., import * as Schema from "effect/Schema" and import * as S from "effect/Schema"). Consolidated these into single imports.

Stats

  • ~250 files changed across all packages
  • All pre-existing type errors remain (Sendgrid/mail types, tanstack-query updateMeta) - no new errors introduced

@patroza
Copy link
Copy Markdown
Member

patroza commented May 10, 2026

@copilot 4 should not be needed. Why would the module extensions not activate? Should we add them loaded into Option module wrapper so they auto load on import * as Option from "effect-app/Option" ?

@patroza
Copy link
Copy Markdown
Member

patroza commented May 10, 2026

@copilot fox checks

… revert Option.value workarounds

Agent-Logs-Url: https://github.com/effect-app/libs/sessions/1d56ee50-d3a9-4a84-bbe0-4d034a977447

Co-authored-by: patroza <42661+patroza@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 10, 2026

@copilot 4 should not be needed. Why would the module extensions not activate? Should we add them loaded into Option module wrapper so they auto load on import * as Option from "effect-app/Option" ?

The root cause was that builtin.ts (which has declare module "effect/Option" { interface None<A> { get value(): A | undefined } }) was only loaded via import "./builtin.js" in index.ts. Once files stopped using the barrel import and switched to import * as Option from "effect-app/Option", builtin.ts was never loaded, so the None.value augmentation didn't activate.

Fixed in 49d42bb by adding import "./builtin.js" to Option.ts — now importing effect-app/Option auto-loads the module augmentations. Reverted the Option.isSome/Option.getOrUndefined workarounds in commander.ts and query.ts since they're no longer needed.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 10, 2026

@copilot fox checks

Fixed in 2ce9c1a. The CI was failing with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH because the lockfile was missing the overrides and patchedDependencies sections after a pnpm install --no-frozen-lockfile run in the previous session. Regenerated the lockfile properly — pnpm install --frozen-lockfile now succeeds.

@patroza
Copy link
Copy Markdown
Member

patroza commented May 10, 2026

@copilot don't import anything from any root barrel "effect-app", "effect", "@effect-app/*".
so e.g import flow/pipe from /Function

@patroza
Copy link
Copy Markdown
Member

patroza commented May 10, 2026

@copilot force running with pnpm 10 and undo the pnpm lock changes etc

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 10, 2026

@copilot don't import anything from any root barrel "effect-app", "effect", "@effect-app/*".
so e.g import flow/pipe from /Function

Done in 0d20c39. All root barrel imports have been replaced with specific submodule imports:

  • flow/pipe/identity from "effect""effect/Function" (20 files)
  • @effect-app/vue barrel split into @effect-app/vue/mutate, /lib, /makeClient, /makeContext, /makeIntl

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 10, 2026

@copilot force running with pnpm 10 and undo the pnpm lock changes etc

Done in 7c9f10c. Reverted the lockfile to the base commit state, updated engines.pnpm to >= 10.0.0, then regenerated the lockfile with pnpm 10.33.4. pnpm install --frozen-lockfile now succeeds with pnpm 10.

@patroza patroza marked this pull request as ready for review May 10, 2026 10:29
@patroza patroza merged commit 439cbeb into main May 10, 2026
3 checks passed
@patroza patroza deleted the copilot/adopt-module-system-effect-smol branch May 10, 2026 10:29
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