While you technically do not need to map it in your SystemJS configuration file, as the script tag will suffice to load the polyfill, by adding it to your configuration you can load it on demand ensuring it is loaded only when needed and in an appropriate order relative to your application.
Your config might look like
SystemJS.config({
map: {
"canvas-polyfill": "https://canvasjs.com/assets/script/canvasjs.min.js"
},
meta: {
"https://canvasjs.com/assets/script/canvasjs.min.js": {
"format": "global",
"scriptLoad": true,
"build": false
}
}
});
You can then add an import to any modules that employ the canvas API to ensure it is loaded when needed without mucking around with script tags and implicit dependencies.
import 'canvas-polyfill';
import {Component} from '@angular/core';
// etc.
EDIT: I realized this isn't a polyfill exactly so it would be better style to write
SystemJS.config({
map: {
"canvasjs": "https://canvasjs.com/assets/script/canvasjs.min.js"
},
meta: {
"https://canvasjs.com/assets/script/canvasjs.min.js": {
"format": "global",
"exports": ["CanvasJS"],
"scriptLoad": true,
"build": false
}
}
});
And import it in your application code via
import CanvasJS from 'canvasjs';
import {Component} from '@angular/core';
// etc.
However, both approaches work fine.
CanvasJSis not defined error in my console.