I have an npm package which is compiled using typescipt It used d3js:
package.json:
{
"dependencies": {
"@types/d3": "^7.4.0",
"d3": "^7.6.1"
}
main.ts:
import * as d3 from 'd3';
Now when I compile using typscript and try to browserfy using:
browserfy lib/index.js -o bundle.js
I get this error:
/home/nathan/projects/private/d3js-git-graph/node_modules/d3/src/index.js:1
export * from "d3-array";
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'
I assume, this is because d3 uses the wrong module syntax?
What can I do about this? How can I bundle this in a single file that can be loaded in the browser?