Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module.exports = {
extends: [
'react-app',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
};
43 changes: 21 additions & 22 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,46 @@ on:
types: [opened, synchronize, reopened]

jobs:
lint-and-dedupe:
lint:
runs-on: ubuntu-latest

name: Lint & Deduplicate deps on node 10.x and ubuntu-latest
name: Lint on Bun with Node 20.x

steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Use Node 10.x
uses: actions/setup-node@v1
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
node-version: 10.x

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1
bun-version: latest
- name: Install dependencies
run: bun install

- name: Lint codebase
run: yarn lint:post-build

- name: Deduplicate dependencies
run: yarn deduplicate:check
run: bun run lint:post-build

test:
name: Test on Node ${{ matrix.node }} and ${{ matrix.os }}
name: Test on Bun with Node ${{ matrix.node }} and ${{ matrix.os }}

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['10.x', '12.x', '14.x']
node: ['18.x', '20.x', '22.x']
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
node-version: ${{ matrix.node }}
bun-version: latest

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1
- name: Install dependencies
run: bun install

- name: Test package
run: yarn test:post-build
run: bun run test:post-build
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pretty-quick --staged --pattern '!test/tests/lint/**' && bun run lint && doctoc README.md
286 changes: 286 additions & 0 deletions FUTURE_IMPROVEMENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
# Future Modernization Suggestions for TSDX

This document outlines additional modernization opportunities and improvements that could be considered for future releases of TSDX.

## High Priority Suggestions

### 1. Consider Alternative Build Tools

**Current**: TSDX uses Rollup for bundling.

**Alternatives to evaluate**:
- **Vite**: Modern build tool with excellent DX and speed
- **esbuild**: Extremely fast bundler written in Go
- **tsup**: Zero-config TypeScript bundler based on esbuild

**Benefits**:
- Significantly faster build times
- Better HMR (Hot Module Replacement) experience
- Native ESM support
- Smaller configuration surface

### 2. Add Native ESM Support

**Current**: Outputs CJS and ESM, but ESM could be improved.

**Improvements**:
- Full package.json `exports` field support
- Dual package hazard prevention
- Proper ESM conditional exports
- `.mjs` and `.cjs` extension support

**Example package.json exports**:
```json
{
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
}
}
```

### 3. Implement Module Federation

Support for Webpack Module Federation or similar technology to enable micro-frontends and better code sharing.

### 4. Add SWC as Alternative to Babel

**Current**: Uses Babel for transformation.

**Alternative**: SWC (Speedy Web Compiler)
- Written in Rust, 20x faster than Babel
- Compatible with most Babel plugins
- Better tree-shaking

### 5. Enhance TypeScript Configuration

- Support for project references
- Better monorepo support
- Composite project support
- Solution-style tsconfig

### 6. Add Built-in Monorepo Support

**Consideration**: Support for workspaces and monorepo patterns
- Turborepo integration
- pnpm workspaces
- Yarn workspaces
- Better build caching

## Medium Priority Suggestions

### 7. Modernize CSS Handling

**Current**: Basic PostCSS support via configuration.

**Improvements**:
- CSS Modules support out of the box
- Tailwind CSS integration
- CSS-in-JS optimization (for styled-components, emotion, etc.)
- Modern CSS features (Container Queries, `:has()`, etc.)

### 8. Add Bundle Analysis Tools

Built-in bundle analysis and optimization suggestions:
- Bundle size visualization
- Tree-shaking reports
- Unused code detection
- Dependency analysis

### 9. Improve Development Experience

- Better error messages and stack traces
- Source map improvements
- Live reload optimization
- Better debugging support

### 10. Enhanced Testing Features

**Current**: Basic Jest setup.

**Additions**:
- Vitest support (faster alternative to Jest)
- Built-in code coverage thresholds
- Visual regression testing support
- E2E testing templates

### 11. Add Performance Benchmarking

- Automated bundle size tracking
- Performance budgets
- CI/CD integration for size checks
- Lighthouse CI integration

### 12. Plugin System

Create a formal plugin system for extending TSDX:
- Plugin API for custom transformations
- Hook system for build lifecycle
- Community plugin marketplace

## Low Priority / Future Considerations

### 13. WebAssembly Support

- Native WASM compilation
- Rust/AssemblyScript integration
- WASM module bundling

### 14. Edge Runtime Support

Optimize builds for edge runtimes:
- Cloudflare Workers
- Deno Deploy
- Vercel Edge Functions
- Netlify Edge Functions

### 15. Generate Documentation

Auto-generate documentation from TypeScript:
- TypeDoc integration
- API documentation generation
- Markdown documentation from JSDoc
- Interactive documentation site

### 16. Add GraphQL Support

Built-in support for GraphQL code generation:
- GraphQL Code Generator integration
- Schema validation
- Type-safe queries

### 17. Improve Accessibility

- Built-in a11y linting for React components
- Accessibility testing in Jest
- ARIA attribute validation

### 18. Add Internationalization Support

- i18n template setup
- Message extraction
- Translation management integration

### 19. Container/Docker Support

- Docker templates for deployment
- Container-optimized builds
- Multi-stage build support

### 20. Cloud Deployment Templates

Quick deployment to:
- Vercel
- Netlify
- AWS Lambda
- Google Cloud Functions

## Breaking Changes to Consider

### 1. Drop Node.js 16 Support

Once Node.js 16 reaches EOL, consider requiring Node.js 20+.

### 2. ESM-Only Build

Consider making TSDX itself ESM-only (while still supporting both CJS and ESM outputs for libraries).

### 3. Remove Legacy Browser Support

Drop IE11 support entirely and target modern browsers only.

### 4. Switch to pnpm

Consider using pnpm as the default package manager for better performance and disk space usage.

## Community Requests from Issues

Based on the open issues analyzed:

1. **Better .env file support** (Issue #1153)
- Native environment variable handling
- .env file loading in development

2. **CSS file import support** (Issue #1181)
- Better CSS module support
- Native CSS import without configuration

3. **Module resolution improvements** (Issue #1168)
- Support for newer TypeScript module resolution modes
- Package.json exports field compatibility

4. **Terser configuration** (Issue #1190)
- More granular control over minification
- Preserve intentional unused variables

5. **Fresh project issues** (Issues #1187, #1174)
- Fix compatibility issues with latest TypeScript
- Better error messages for version conflicts

## Implementation Priority

### Phase 1 (Immediate - Next Minor Release)
- โœ… Update all dependencies to latest versions
- โœ… Fix known issues with TypeScript 5
- โœ… Update React to v18
- โœ… Update Storybook to v7

### Phase 2 (Next 6 Months)
- Add native .env file support
- Improve CSS handling
- Add bundle analysis tools
- Better monorepo support

### Phase 3 (6-12 Months)
- Evaluate alternative build tools (Vite, esbuild, tsup)
- Add plugin system
- Enhanced ESM support
- Performance benchmarking

### Phase 4 (12+ Months)
- Major architectural changes
- Breaking changes for v1.0
- Consider ESM-only approach
- Full edge runtime support

## Metrics to Track

To measure the success of modernization efforts:

1. **Build Performance**
- Build time reduction
- Cold start time
- Hot reload speed

2. **Bundle Size**
- Output size optimization
- Tree-shaking effectiveness

3. **Developer Experience**
- Setup time
- Error clarity
- Documentation completeness

4. **Compatibility**
- TypeScript version support
- Node.js version support
- Browser compatibility

5. **Community Health**
- Issue resolution time
- PR merge rate
- Community contributions

## Conclusion

TSDX has been modernized significantly with the current changes, but there are many opportunities for future improvements. The suggestions in this document should be evaluated based on:

1. **Community demand**: What are users requesting?
2. **Maintenance burden**: Will this add significant complexity?
3. **Performance impact**: Will this make builds faster/slower?
4. **Breaking changes**: Can this be done without breaking existing users?

The focus should remain on TSDX's core value proposition: zero-config TypeScript package development with sensible defaults.
Loading