Aurelia-cli, amcharts/exports and requirejs

Hi,
does anyone have a recommendation on how to get amcharts exports working using au-cli and requirejs?

The issue lies with the fabric.js bundled with amcharts.

So far I’ve used:
{
“name”:“amcharts3”,
“main”:“amcharts”,
“path”:"…/node_modules/amcharts3/amcharts/",
“resources”:[
“plugins/export/export.css”,
“plugins/export/libs/FileSaver.js/FileSaver.js”,
“plugins/export/libs/jszip/jszip.js”,
“plugins/export/libs/fabric.js/fabric.js”,
“plugins/export/libs/pdfmake/pdfmake.js”
]
}

but import fabric.js errors in:

Script error for “jsdom”, needed by: amcharts3/plugins/export/libs/fabric.js/fabric

So, does this mean I’ll have to track down all needed deps for fabric.js?

Any hints are welcome :slight_smile:

/hw

It looks like fabric tries to detect whether it’s in browser or nodejs env. It loads lots of nodejs modules when in nodejs env, which aurelia-cli tries to trace.

I would recommend to load amcharts3 as old JavaScript (without requirejs support) as global variable which amcharts3 supports.

Just loaded every files you need in vendor-bunle.js "prepend" section, remember put before "node_modules/requirejs/require.js".

It looks like only these two files are needed.

"../node_modules/amcharts3/amcharts/amcharts.js",
"../node_modules/amcharts3/amcharts/plugins/export/export.min.js"

In addition, you need to load that css file somehow through aurelia-cli copyFiles or css pipline setup.

In this way, it will skip all tracing effect, but you have to access it through global AmCharts variable.

I use "prepend" on many JS libs that either do not play well with AMD or too smart trying to work out browser/nodejs difference.

Thanks a lot.
You gave me enough to get it working.

All I had to to is to put fabric, filesaver and all the ‘export dependencies’ to prepend.

After that, I could to standard import and adding resource export.css.

Thanks again,

/hw