Skip to content

Conversation

@marsninja
Copy link
Collaborator

Summary

  • Add support for user-defined import path aliases in jac-client
  • Aliases sync automatically to both Vite resolve.alias and TypeScript compilerOptions.paths
  • Single source of truth in jac.toml for path configuration

Usage

[plugins.client.paths]
"@components/*" = "./components/*"
"@utils/*" = "./utils/*"
"@api" = "./api/index.jac"

This generates:

vite.config.js:

resolve: {
  alias: {
    "@jac-client/utils": path.resolve(buildDir, "compiled/client_runtime.js"),
    "@jac-client/assets": path.resolve(buildDir, "compiled/assets"),
    "@components": path.resolve(projectRoot, "components"),
    "@utils": path.resolve(projectRoot, "utils"),
  },
}

tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@components/*": ["components/*"],
      "@utils/*": ["utils/*"]
    }
  }
}

Test plan

  • Add [plugins.client.paths] to a test project's jac.toml
  • Run jac build and verify generated configs contain the aliases
  • Verify imports using custom paths compile successfully

marsninja and others added 4 commits January 21, 2026 00:33
…paths]

Add support for user-defined import path aliases that sync to both
Vite resolve.alias and TypeScript compilerOptions.paths.

Users can now configure custom aliases in jac.toml:

```toml
[plugins.client.paths]
"@components/*" = "./components/*"
"@utils/*" = "./utils/*"
```

This generates:
- Vite aliases for module bundling
- TypeScript paths for IDE autocompletion

Changes:
- Add get_paths_config() to JacClientConfig
- Inject user aliases into vite.config.js and vite.dev.config.js
- Inject paths into tsconfig.json with baseUrl
Enable the compiler to resolve custom import path aliases defined in
[plugins.client.paths] during compilation. This allows .jac files to
use aliases like @components/Button that map to ./components/Button.

The resolver now:
1. Checks path aliases before filesystem/Python import resolution
2. Supports wildcard patterns (@alias/* -> ./path/*)
3. Supports exact matches (@alias -> ./path)
4. Uses project root from config for relative path resolution

This complements the Vite/TypeScript alias configuration, enabling
full .jac file compilation with custom import paths.
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