TargetProcess/tauCharts

taucharts not loading when used with requireJS optimizer

Closed this issue · 4 comments

I'm using taucharts with requireJS. It works fine when I load the script at runtime, but when I try to run it through the optimizer and compile them into a single script, it fails. If I take out taucharts it works. Is there a known compatibility issue with taucharts and requireJS? If not, what do I need to do to get this to work with the optimizer?

Hi. Before I try to help you with RequireJS optimizer, check that paths for taucharts and D3 v3 entries are specified in your RequireJS config:

requirejs.config({
    paths: {
        'taucharts': 'node_modules/taucharts/build/development/tauCharts',
        'd3': 'node_modules/d3/d3'
    }
});

Yes, they are specified in the config. It works fine with RequireJS prior to running the optimizer. It fails when I run it through the optimizer. The only way I could get it to work is by loading d3 and taucharts via script tag on the page prior to including the requirejs script. I assume there is a conflict somewhere in taucharts with requierjs. If I put taucharts after the script tag, it fails to load anything. Its like it is hijacking part of requirejs in the global scope. I believe its taucharts, because I don't have this problem with any other library in this project and just by removing taucharts, it solves the issue.

Seems like optimizer couldn't resolve multiple define() calls from Taucharts bundle ("tauCharts.js has more than one anonymous define..."). Replacing define(["d3"]... with define('taucharts', ["d3"]... inside UMD block fixed the issue.

I will think how to reconfigure Webpack bundling.

Please reopen if issue is actual now.