Skip to content

Commit 2e56113

Browse files
committed
Fixed #22579, no factory calls in README.
1 parent 9763759 commit 2e56113

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

README.md

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,14 @@ bower install highcharts
4242
```
4343

4444
## Load Highcharts as a CommonJS module
45-
Highcharts is using an UMD module pattern, as a result it has support for CommonJS.
45+
Highcharts uses a UMD (Universal Module Definition) module pattern, which provides support for CommonJS. However, starting from version 12, the module system has been simplified.
4646
*The following examples presumes you are using npm to install Highcharts, see [Download and install Highcharts](#download-and-install-highcharts) for more details.*
4747
```js
4848
// Load Highcharts
49-
var Highcharts = require('highcharts');
50-
// Alternatively, this is how to load Highcharts Stock. The Maps and Gantt
51-
// packages are similar.
52-
// var Highcharts = require('highcharts/highstock');
49+
const Highcharts = require('highcharts');
5350

54-
// Load the exporting module, and initialize it.
55-
require('highcharts/modules/exporting')(Highcharts);
51+
// Load the exporting module (no need to initialize explicitly from v12)
52+
require('highcharts/modules/exporting');
5653

5754
// Generate the chart
5855
Highcharts.chart('container', {
@@ -61,7 +58,7 @@ Highcharts.chart('container', {
6158
```
6259

6360
## Load Highcharts as an ES6 module
64-
Since Highcharts supports CommonJS, it can be loaded as an ES6 module with the use of transpilers. Two common transpilers are [Babel](https://babeljs.io/) and [TypeScript](https://www.typescriptlang.org/). These have different interpretations of a CommonJS module, which affects your syntax.
61+
Since Highcharts supports CommonJS, it can be loaded as an ES6 module with the use of transpilers. Two common transpilers are [Babel](https://babeljs.io/) and [TypeScript](https://www.typescriptlang.org/). These have different interpretations of a CommonJS module, which affects your syntax. With Highcharts v12, ES6 modules are supported out of the box without the need to initialize module factories.
6562
*The following examples presumes you are using npm to install Highcharts, see [Download and install Highcharts](#download-and-install-highcharts) for more details.*
6663
### Babel
6764
```js
@@ -70,10 +67,7 @@ import Highcharts from 'highcharts';
7067
// packages are similar.
7168
// import Highcharts from 'highcharts/highstock';
7269

73-
// Load the exporting module.
74-
import Exporting from 'highcharts/modules/exporting';
75-
// Initialize exporting module.
76-
Exporting(Highcharts);
70+
import 'highcharts/modules/exporting';
7771

7872
// Generate the chart
7973
Highcharts.chart('container', {
@@ -82,15 +76,12 @@ Highcharts.chart('container', {
8276
```
8377
### TypeScript
8478
```js
85-
import * as Highcharts from 'highcharts';
79+
import Highcharts from 'highcharts';
8680
// Alternatively, this is how to load Highcharts Stock. The Maps and Gantt
8781
// packages are similar.
8882
// import Highcharts from 'highcharts/highstock';
8983

90-
// Load the exporting module.
91-
import * as Exporting from 'highcharts/modules/exporting';
92-
// Initialize exporting module.
93-
Exporting(Highcharts);
84+
import 'highcharts/modules/exporting';
9485

9586
// Generate the chart
9687
Highcharts.chart('container', {

0 commit comments

Comments
 (0)