Skip to content

Commit 87cea4e

Browse files
committed
refactor: migrate to ES Modules and Rollup
- Transitioned src/angular-chart.js to native import/export syntax. - Introduced Rollup to generate UMD, ESM, and CJS bundles. - Added live-reload development loop with `npm run dev`. - Updated package.json with `module` and `exports` for modern tool compatibility. - Updated examples and test fixtures to point to dist/ bundles. - Cleaned up legacy JS bundling and minification logic from gulpfile.js. - Configured ESLint and Karma to support the new module structure.
1 parent 64975d6 commit 87cea4e

40 files changed

Lines changed: 2872 additions & 478 deletions

.eslintrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@
5959
"angular/no-service-method": "off"
6060
},
6161
"overrides": [
62+
{
63+
"files": ["src/**/*.js", "rollup.config.js"],
64+
"parserOptions": {
65+
"sourceType": "module"
66+
},
67+
"rules": {
68+
"strict": "off"
69+
}
70+
},
6271
{
6372
"files": ["test/**/*.js"],
6473
"globals": {

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
1. Create an issue
44
1. Fork the repo
55
1. Install dependencies: `npm install`
6-
1. Make your changes and add tests
76
1. This project follows the [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html).
7+
1. Use `npm run dev` for a live-reload development loop.
8+
1. Make your changes in `src/` and add tests.
89
1. Ensure your code is lint-free: `npm run lint`
9-
1. Run tests: `npm test`
10+
1. Run tests: `npm test` (this will run lint, unit, and integration tests).
11+
1. Ensure the build works: `npm run build`
1012
1. Submit pull request

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,20 @@ but must be set via standard options e.g. `ChartJsProvider.setOptions({ responsi
3434

3535
npm install --save angular-chart.js
3636

37-
### cdn
38-
3937
https://cdn.jsdelivr.net/npm/angular-chart.js@latest/dist/angular-chart.min.js
4038

39+
### ESM / Modern Bundlers
40+
41+
If you are using a modern bundler like Vite, Webpack 5, or Rollup:
42+
43+
```javascript
44+
import angular from 'angular';
45+
import Chart from 'chart.js';
46+
import angularChart from 'angular-chart.js';
47+
48+
angular.module('app', [angularChart]);
49+
```
50+
4151
### manually
4252

4353
or copy the files from `dist/`.
@@ -250,7 +260,29 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
250260

251261
# Development
252262

253-
This project uses [ESLint](https://eslint.org/) to enforce the [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html).
263+
This project uses **Rollup** for bundling and **Gulp** for task automation.
264+
The source code is located in `src/` and uses native ES Modules.
265+
266+
## Local Development Loop
267+
268+
To start the development server with live reload:
269+
270+
```bash
271+
npm run dev
272+
```
273+
274+
This will:
275+
1. Start a local server at `http://localhost:8045`.
276+
2. Watch `src/` for changes and rebuild the `dist/` files instantly.
277+
3. Automatically reload the browser when changes are detected.
278+
279+
## Building
280+
281+
To generate the production bundles in `dist/`:
282+
283+
```bash
284+
npm run build
285+
```
254286

255287
## Linting
256288

0 commit comments

Comments
 (0)