Skip to content

Commit

Permalink
Remove moment from dependencies (#6745)
Browse files Browse the repository at this point in the history
* Remove moment from dependencies
* Remove version number in docs
  • Loading branch information
benmccann authored and etimberg committed Nov 15, 2019
1 parent 7f97adf commit 8f0de52
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
2 changes: 1 addition & 1 deletion docs/axes/cartesian/time.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The time scale is used to display times and dates. When building its ticks, it w

## Date Adapters

The time scale requires both a date library and corresponding adapter to be present. By default, Chart.js includes an adapter for Moment.js. You may wish to [exclude moment](../../getting-started/integration.md) and choose from [other available adapters](https://github.com/chartjs/awesome#adapters) instead.
The time scale requires both a date library and corresponding adapter to be present. By default, Chart.js includes an adapter for Moment.js. You may wish to choose from [other available adapters](https://github.com/chartjs/awesome#adapters) instead.

## Data Sets

Expand Down
22 changes: 1 addition & 21 deletions docs/getting-started/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,6 @@ import Chart from 'chart.js';
var myChart = new Chart(ctx, {...});
```

**Note:** Moment.js is installed along Chart.js as dependency. If you don't want to use Moment.js (either because you use a different date adapter or simply because don't need time functionalities), you will have to configure your bundler to exclude this dependency (e.g. using [`externals` for Webpack](https://webpack.js.org/configuration/externals/) or [`external` for Rollup](https://rollupjs.org/guide/en#peer-dependencies)).

```javascript
// Webpack
{
externals: {
moment: 'moment'
}
}
```

```javascript
// Rollup
{
external: {
['moment']
}
}
```

## Require JS

**Important:** RequireJS [can **not** load CommonJS module as is](https://requirejs.org/docs/commonjs.html#intro), so be sure to require one of the UMD builds instead (i.e. `dist/Chart.js`, `dist/Chart.min.js`, etc.).
Expand All @@ -55,7 +35,7 @@ require(['path/to/chartjs/dist/Chart.min.js'], function(Chart){
});
```

**Note:** starting v2.8, Moment.js is an optional dependency for `Chart.js` and `Chart.min.js`. In order to use the time scale with Moment.js, you need to make sure Moment.js is fully loaded **before** requiring Chart.js. You can either use a shim:
**Note:** in order to use the time scale, you need to make sure [one of the available date adapters](https://github.com/chartjs/awesome#adapters) and corresponding date library are fully loaded **before** requiring Chart.js. The date adapter for Moment.js is included with Chart.js, but you still need to include Moment.js itself if this is the date adapter you choose to use. You can either use a shim:

```javascript
require.config({
Expand Down
7 changes: 4 additions & 3 deletions docs/getting-started/v3-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released in April 2016. In the years since then, as Chart.js has grown in popularity and feature set, we've learned some lessons about how to better create a charting library. In order to improve performance, offer new features, and improve maintainability it was necessary to break backwards compatibility, but we aimed to do so only when necessary.

## Setup
## End user migration

Chart.js is no longer providing the `Chart.bundle.js` and `Chart.bundle.min.js`. Please see the [installation](installation.md) and [integration](integration.md) docs for details on the recommended way to setup Chart.js if you were using these builds.
### Setup and installation

## End user migration
* Chart.js is no longer providing the `Chart.bundle.js` and `Chart.bundle.min.js`. Please see the [installation](installation.md) and [integration](integration.md) docs for details on the recommended way to setup Chart.js if you were using these builds.
* `moment` is no longer specified as an npm dependency. If you are using the time scale, you must include one of [the available adapters](https://github.com/chartjs/awesome#adapters) and corresponding date library. If you are using a date library other than moment, you no longer need to exclude moment from your build.

### Ticks

Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"karma-rollup-preprocessor": "^7.0.0",
"karma-safari-private-launcher": "^1.0.0",
"merge-stream": "^1.0.1",
"moment": "^2.10.2",
"pixelmatch": "^5.0.0",
"rollup": "^1.0.0",
"rollup-plugin-babel": "^4.3.3",
Expand All @@ -71,7 +72,6 @@
"yargs": "^14.0.0"
},
"dependencies": {
"chartjs-color": "^2.1.0",
"moment": "^2.10.2"
"chartjs-color": "^2.1.0"
}
}

0 comments on commit 8f0de52

Please sign in to comment.