Billboard.js: How about to support billboard.js runs in node.

Created on 23 Aug 2018  路  2Comments  路  Source: naver/billboard.js

Description

When I've run billboard.js(bundled) on node.

I found three point that make script error. and It's working OK after fixed it locally.

1. Referenece window in bundled js.

(function webpackUniversalModuleDefinition(root, factory) {
    if(typeof exports === 'object' && typeof module === 'object')
        module.exports = factory();
    else if(typeof define === 'function' && define.amd)
        define([], factory);
    else {
        var a = factory();
        for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
    }
})(window, function() {// <--- window makes script error on node.

It looks like webpack has bug related with this issue.

2. isDefined is not working if parameter is not defined

const win = isDefined(window) && window.Math === Math ?
    window : isDefined(self) && (
        self.Math === Math ?
            self : Function("return this")()

So I replace isDefined to typeof

3. Reference navigator of undefined

var ua = window.navigator.userAgent;

It also could be solved by checking typeof window

After solved these 3 issues. I can see it runs successfully on node.

feature released request

Most helpful comment

Hi @jongmoon, thanks for the suggestion.
For now, billboard.js is targeted to work on visible browser, which are required the objects you mentioned.

The support for SSR work environment sounds good to be implemented.
I'll take this for the future implementation. Thanks!

All 2 comments

Hi @jongmoon, thanks for the suggestion.
For now, billboard.js is targeted to work on visible browser, which are required the objects you mentioned.

The support for SSR work environment sounds good to be implemented.
I'll take this for the future implementation. Thanks!

:tada: This issue has been resolved in version 1.9.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SoYoung210 picture SoYoung210  路  5Comments

stevenmusumeche picture stevenmusumeche  路  3Comments

davidhund picture davidhund  路  5Comments

mafar picture mafar  路  4Comments

serzhiio picture serzhiio  路  4Comments