Skip to content

Commit 670ca13

Browse files
authored
Merge pull request #128 from rlamana/cursor/modernize-repository-to-use-vite-6d47
Modernize repository to use vite
2 parents e4127eb + c79d4ac commit 670ca13

31 files changed

+4789
-10364
lines changed

.babelrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

.eslintrc

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
{
2-
"extends": [
3-
"airbnb-base",
4-
"eslint:recommended"
5-
],
6-
"rules": {
7-
"max-len": ["error", 100],
8-
"indent": ["error", 2, {"SwitchCase": 1}],
9-
"import/prefer-default-export": 0
10-
},
11-
"settings": {
12-
"import/resolver": "webpack"
13-
},
14-
"plugins": [
15-
"import"
16-
],
17-
"parser": "babel-eslint",
182
"env": {
193
"browser": true,
4+
"es2022": true,
205
"node": true
6+
},
7+
"extends": [
8+
"eslint:recommended"
9+
],
10+
"parserOptions": {
11+
"ecmaVersion": 2022,
12+
"sourceType": "module"
13+
},
14+
"rules": {
15+
"indent": ["error", 2],
16+
"linebreak-style": ["error", "unix"],
17+
"quotes": ["error", "single"],
18+
"semi": ["error", "always"]
2119
}
2220
}

MODERNIZATION_SUMMARY.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Ventus Library Modernization - Migration to Vite
2+
3+
## Overview
4+
Successfully modernized the Ventus window manager library from Webpack 4 to Vite 5, updating the build system, dependencies, and module format to use modern JavaScript tooling.
5+
6+
## Major Changes Made
7+
8+
### 1. Build System Migration
9+
- **Replaced Webpack 4** with **Vite 5** for faster development and building
10+
- **Removed old configuration files:**
11+
- `webpack.config.js`
12+
- `webpack.dev.config.js`
13+
- `webpack.prod.config.js`
14+
- `karma.conf.js` (replaced with Vitest)
15+
- `.babelrc` (Vite handles transpilation natively)
16+
17+
### 2. Package.json Updates
18+
- **Updated dependencies** to modern versions:
19+
- Vite 5.4.10
20+
- Autoprefixer 10.4.20
21+
- ESLint 9.14.0
22+
- Less 4.2.0
23+
- PostCSS 8.4.47
24+
- Vitest 2.1.4
25+
- **Removed outdated dependencies:**
26+
- All Webpack-related packages
27+
- Babel packages (no longer needed)
28+
- Karma test runner packages
29+
- **Added module exports configuration** for both ESM and UMD builds
30+
- **Updated scripts** for modern development workflow
31+
32+
### 3. Module System Conversion
33+
- **Converted all AMD modules to ES6 modules:**
34+
- `src/ventus/core/emitter.js`
35+
- `src/ventus/core/view.js`
36+
- `src/ventus/wm/window.js`
37+
- `src/ventus/wm/windowmanager.js`
38+
- `src/ventus/wm/modes/default.js`
39+
- `src/ventus/wm/modes/expose.js`
40+
- **Updated main entry point** (`src/ventus.js`) to use ES6 export syntax
41+
- **Fixed import paths** for LESS files and dependencies
42+
43+
### 4. Configuration Files
44+
- **Created `vite.config.js`** with:
45+
- Library build configuration for UMD and ES module formats
46+
- LESS preprocessing support
47+
- PostCSS with autoprefixer integration
48+
- Source map generation
49+
- Terser minification
50+
- **Updated `postcss.config.js`** to use ES6 module syntax
51+
- **Modernized `.eslintrc`** for ES2022 and ES modules
52+
53+
### 5. Development Environment
54+
- **Added `index.html`** for development testing
55+
- **Set up modern dev server** with hot reloading
56+
- **Configured proper alias resolution** for internal modules
57+
58+
### 6. Testing Migration
59+
- **Migrated from Karma/Mocha/Chai to Vitest**
60+
- **Updated test file** (`test/window.test.js`) to use:
61+
- Modern ES6 import syntax
62+
- Vitest's expect API
63+
- Arrow functions instead of function expressions
64+
65+
## Build Output
66+
The modernized build generates:
67+
- `dist/ventus.js` - ES module build (32KB)
68+
- `dist/ventus.umd.cjs` - UMD build for legacy compatibility (18KB)
69+
- `dist/style.css` - Compiled LESS styles (9.6KB)
70+
- Source maps for debugging
71+
72+
## Development Commands
73+
```bash
74+
# Install dependencies
75+
npm install
76+
77+
# Start development server
78+
npm run dev
79+
80+
# Build for production
81+
npm run build
82+
83+
# Preview production build
84+
npm run preview
85+
86+
# Run tests
87+
npm test
88+
89+
# Run tests once
90+
npm run test:run
91+
92+
# Lint code
93+
npm run lint
94+
```
95+
96+
## Benefits of Modernization
97+
1. **Faster development** - Vite's dev server is significantly faster than Webpack
98+
2. **Modern tooling** - Updated to latest versions of all build tools
99+
3. **Better tree shaking** - ES modules enable better dead code elimination
100+
4. **Improved DX** - Hot module replacement and instant updates
101+
5. **Future-proof** - Uses modern JavaScript standards and tooling
102+
6. **Smaller bundle size** - More efficient bundling with Rollup
103+
7. **Better debugging** - Improved source maps and error reporting
104+
105+
## Backward Compatibility
106+
- UMD build maintains compatibility with older module systems
107+
- Library API remains unchanged
108+
- Both CommonJS (`require()`) and ES modules (`import`) are supported
109+
110+
## Status
111+
**Completed Successfully**
112+
- Build system fully migrated to Vite
113+
- All modules converted to ES6
114+
- Development server working
115+
- Production builds generating correctly
116+
- Library maintains full functionality

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,41 @@ A window manager written in Javascript, HTML5 and CSS3.
77

88
This project started as an experiment and even though it was stable enough **it was never meant to be mantained over time**. However, feel free to fork and send PRs!
99

10-
Version 0.3.0 migrates code to webpack and ES6 and is available in branch: https://github.com/rlamana/Ventus/tree/v0.3.0.
10+
Version 0.3.0 has been modernized to use Vite for faster development and building, with ES6 modules and modern tooling.
11+
12+
## Development Setup
13+
14+
```bash
15+
# Install dependencies
16+
npm install
17+
18+
# Start development server
19+
npm run dev
20+
21+
# Build for production
22+
npm run build
23+
24+
# Run tests
25+
npm test
26+
27+
# Preview production build
28+
npm run preview
29+
```
30+
31+
## Installation
32+
33+
The library is built as both ES modules and UMD for compatibility:
34+
35+
```javascript
36+
// ES modules
37+
import { WindowManager, Window } from 'ventus';
38+
39+
// CommonJS
40+
const { WindowManager, Window } = require('ventus');
41+
42+
// UMD (browser)
43+
const wm = new Ventus.WindowManager();
44+
```
1145

1246
### Creating a new window manager
1347

dist/style.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)