Background
The @guildpass/env package currently hardcodes .js file imports for schemas (./schemas/dashboard.js, ./schemas/access-api.js, etc.). This tight coupling to output file format causes failures when:
- TypeScript configuration changes (e.g., switching from
.js to .ts imports)
- Build output location shifts
- The package is consumed differently (e.g., directly from source in development, or bundled)
Problem
Explicit .js imports in packages/env/src/index.ts or similar:
import * as dashboardSchema from './schemas/dashboard.js';
import * as accessApiSchema from './schemas/access-api.js';
Assume:
- Files are always compiled to
.js format
- Output is always in a specific directory structure
- Runtime resolution matches TypeScript's emit strategy
This breaks when:
- TypeScript configuration changes
- ESM vs. CommonJS strategies shift
- Source files are consumed directly (e.g., in tests or development)
Expected Outcome
- Schema imports use TypeScript syntax (
.ts or no extension)
- Build system handles
.js output transparently
- Package works in multiple consumption modes (compiled, bundled, or source)
- Tests and docs reference schemas via stable import paths
Suggested Implementation
-
Change schema imports in packages/env/src/ from:
import * as dashboardSchema from './schemas/dashboard.js';
To:
import * as dashboardSchema from './schemas/dashboard';
// OR
import * as dashboardSchema from './schemas/dashboard.js' assert { type: 'json' }; // if JSON
-
Update packages/env/tsconfig.json to ensure consistent module resolution:
{
"compilerOptions": {
"moduleResolution": "bundler",
"resolveJsonModule": true
}
}
-
If schemas are separate modules, ensure they export types properly:
// schemas/dashboard.ts
export const dashboardSchema = { /* ... */ };
export type DashboardSchema = typeof dashboardSchema;
-
Update imports throughout packages/env/src/ consistently
-
Add TypeScript triple-slash directives if needed:
/// <reference path="./schemas/dashboard.d.ts" />
-
Test with pnpm build -r --filter @guildpass/env and verify downstream builds (apps/dashboard, etc.) succeed
Acceptance Criteria
Affected Files/Directories
packages/env/src/index.ts (or all source files with schema imports)
packages/env/src/schemas/*.ts
packages/env/tsconfig.json
- Any consumer files importing from
@guildpass/env
Background
The
@guildpass/envpackage currently hardcodes.jsfile imports for schemas (./schemas/dashboard.js,./schemas/access-api.js, etc.). This tight coupling to output file format causes failures when:.jsto.tsimports)Problem
Explicit
.jsimports inpackages/env/src/index.tsor similar:Assume:
.jsformatThis breaks when:
Expected Outcome
.tsor no extension).jsoutput transparentlySuggested Implementation
Change schema imports in
packages/env/src/from:To:
Update
packages/env/tsconfig.jsonto ensure consistent module resolution:{ "compilerOptions": { "moduleResolution": "bundler", "resolveJsonModule": true } }If schemas are separate modules, ensure they export types properly:
Update imports throughout
packages/env/src/consistentlyAdd TypeScript triple-slash directives if needed:
/// <reference path="./schemas/dashboard.d.ts" />Test with
pnpm build -r --filter @guildpass/envand verify downstream builds (apps/dashboard, etc.) succeedAcceptance Criteria
.jsextensions in source importspackages/envbuilds successfully with new import strategyapps/dashboard, etc.) resolve schemas correctlyAffected Files/Directories
packages/env/src/index.ts(or all source files with schema imports)packages/env/src/schemas/*.tspackages/env/tsconfig.json@guildpass/env