• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

naver / billboard.js / 24550161999

17 Apr 2026 05:54AM UTC coverage: 93.567% (-0.2%) from 93.76%
24550161999

push

github

web-flow
feat(esm): tree-shakable grid, regions, category modules

* feat(esm): make export and flow APIs tree-shakable

- Introduce exportApi() and flow() module functions for opt-in ESM import
- Remove apiExport from Chart core and apiFlow from axis resolver
- Add stubs on Chart.prototype with logError for missing module guidance
- UMD bundle auto-includes both via index.ts
- Optimize isStackingRadiusData from O(n²) to O(n) pre-computed Set
- Add ESM tests for optional module loading behavior

BREAKING CHANGE: chart.export() and chart.flow() are no longer
included automatically in the ESM build. Explicit import required:

  import bb, { bar, exportApi, flow } from "billboard.js";
  bb.generate({ ...bar(), ...exportApi(), ...flow(), data: { ... } });

UMD bundle users are not affected.

* refactor(esm): remove prototype stubs for export and flow modules

Remove the stub implementations and delete calls that were added as
fallbacks — they are unnecessary now that the resolver pattern handles
lazy loading directly without stub cleanup.

* feat(esm): make grid, regions, category APIs tree-shakable

- Introduce grid(), regions(), category() resolver modules for opt-in ESM import
- Remove apiGrid, apiRegion, apiCategory from axis resolver
- Remove internal grid/region renderers from axis resolver
- Extend Chart/api/stubs with xgrids/ygrids/regions/category/categories stubs
- Add optional chaining in redraw/eventrect/flow/ChartInternal for grid/region methods
- Update UMD entry to auto-invoke new resolvers
- Update ESM entry to export new resolvers
- Point runtime error docs to new MODULE_IMPORTS.md guide
- Add tests for new optional modules

Add CHANGELOG-v4.md for release notes and MODULE_IMPORTS.md as the
canonical module import guide referenced from runtime error messages.

BREAKING CHANGE: In ESM builds, chart.xgrids()/ygrids(), chart.regions(),
chart.category()/categories() now require explicit import:

  import bb, {bar, grid, regions, category} from "billbo... (continued)

6909 of 7688 branches covered (89.87%)

Branch coverage included in aggregate %.

59 of 69 new or added lines in 14 files covered. (85.51%)

14 existing lines in 1 file now uncovered.

8711 of 9006 relevant lines covered (96.72%)

20703.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.72
/src/module/error.ts
1
import {API_MODULE_NEEDED, TYPE, TYPE_METHOD_NEEDED} from "../config/const";
2
import {window} from "./browser";
3
import {camelize, isEmpty} from "./util";
4

5
/**
6
 * Copyright (c) 2021 ~ present NAVER Corp.
7
 * billboard.js project is licensed under the MIT license
8
 */
9
/* eslint no-console: "off" */
10
export {checkApiModuleImport, checkModuleImport, logError};
11

12
const MODULE_IMPORT_DOC = "https://github.com/naver/billboard.js/blob/master/MODULE_IMPORTS.md";
231✔
13

14
/**
15
 * Check chart type module imports.
16
 * @param {ChartInternal} ctx Context
17
 * @private
18
 */
19
function checkModuleImport(ctx) {
20
        const $$ = ctx;
6,312✔
21
        const {config} = $$;
6,312✔
22
        let type = "";
6,312✔
23

24
        if (isEmpty(config.data_type || config.data_types) && !$$[TYPE_METHOD_NEEDED.LINE]) {
6,312✔
25
                type = "line";
3✔
26
        } else {
27
                for (const x in TYPE_METHOD_NEEDED) {
6,309✔
28
                        const t = TYPE[x];
125,610✔
29

30
                        if ($$.hasType(t) && !$$[TYPE_METHOD_NEEDED[x]]) {
125,610✔
31
                                type = t;
60✔
32
                                break;
60✔
33
                        }
34
                }
35
        }
36

37
        type &&
6,312✔
38
                logError(`Please, make sure if %c${camelize(type)}`,
39
                        "module has been imported and specified correctly.", MODULE_IMPORT_DOC);
40
}
41

42
/**
43
 * Check optional API module import (e.g. export, flow).
44
 * Invoked by stubs on Chart.prototype when the corresponding resolver module
45
 * was not imported. Throws a helpful error pointing to the module the user
46
 * needs to import.
47
 * @param {string} apiName API name (key of API_MODULE_NEEDED)
48
 * @private
49
 */
50
function checkApiModuleImport(apiName: string): void {
NEW
51
        const moduleName = API_MODULE_NEEDED[apiName];
×
52

NEW
53
        moduleName &&
×
54
                logError(`Please, make sure if %c${moduleName}`,
55
                        "module has been imported and specified correctly.", MODULE_IMPORT_DOC);
56
}
57

58
/**
59
 * Log error and throw error
60
 * @param {string} head Message header
61
 * @param {string} tail Message tail
62
 * @param {string} info Info message
63
 * @private
64
 */
65
function logError(head, tail?: string, info?: string) {
66
        const prefix = "[billboard.js]";
63✔
67
        const hasConsole = window.console?.error;
63✔
68

69
        if (hasConsole) {
63!
70
                const tailMsg = tail ?
63!
71
                        ["background:red;color:white;display:block;font-size:15px", tail] :
72
                        [];
73

74
                console.error(`❌ ${prefix} ${head}`,
63✔
75
                        "background:red;color:white;display:block;font-size:15px", ...tailMsg);
76
                info && console.info("%cℹ️", "font-size:15px", info);
63✔
77
        }
78

79
        throw Error(`${prefix} ${head.replace(/\%c([a-z-]+)/i, "'$1' ")} ${tail ?? ""}`);
63!
80
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc