Having difficulty with an import statement in my D3 4.0 and Ionic2/Angular2 project.
I believe the import statement is correct, as everything compiles successfully.
import * as d3Request from 'd3-request';
export class HomePage {
constructor() {
d3Request.xml('assets/mysvg.svg')
.mimeType("image/svg+xml")
.get(function(error, xml) {
if (error) throw error;
document.body.appendChild(xml.documentElement);
});
}
}
After compilation:
var d3Request$1 = unwrapExports(d3Request);
var d3Request$2 = Object.freeze({
default: d3Request$1,
__moduleExports: d3Request
});
...
d3Request$2.xml('assets/mysvg.svg')
.mimeType("image/svg+xml")
.get(function (error, xml) {
if (error) throw error;
document.body.appendChild(xml.documentElement);
});
However, during runtime, the xml
function is not found on d3Request$2.xml
. It actually exists on d3Request$2.__moduleExports.xml
, but the code doesn't compile to that. Why?
I also tested
import d3Request from 'd3-request'
, which compiles but still fails to work. Results in:
var d3Request$1 = unwrapExports(d3Request);
...
d3Request$1.xml('assets/emojis/laughing.svg')
.mimeType("image/svg+xml")...
Even though d3Request$1
is undefined, d3Request.xml
does exist, but the code compiles to d3Request$1.xml
!