I have several Meteor web application which depends on D3.js via NPM in the client.
The v6 version of D3 has removed support for ES5 and only targets browsers with the code they deploy to NPM -- my applications need to support IE11, so require the ES5 support.
I initially attempted to do the transpilation locally via tooling in Meteor directly (https://guide.meteor.com/using-npm-packages.html#recompile and https://docs.meteor.com/packages/ecmascript.html), but have since found that it only works for DIRECT dependencies, not sub-depndencies in apps, and is completely unavailable in Meteor packages.
Turns out, D3 has now broken itself out into many sub-packages. See: https://github.com/d3/d3/blob/master/index.js and https://github.com/d3/d3/blob/master/package.json#L46 -- so all the code the needs recompiled exists in indirect dependencies.
Everything I tried there lead to dead-ends, so I figured I'd more on to other options.
The remaining options seem to be:
- Find a CDN that will do in-place pass-through transparent transpilation back to ES5 syntax and caching of NPM packages or specified JS URL.
- I am almost certain I've seen and used a CDN that did this previously -- I just can't remember the name. It fetched npm packages by name and version/latest (e.g
https://d3js.org/d3.v6.js) and transpiled them to ES5 and cached the result.
- I am almost certain I've seen and used a CDN that did this previously -- I just can't remember the name. It fetched npm packages by name and version/latest (e.g
- Write some local tooling outside meteor to install babel cli, download the file from CDN, transpile it, and save it to the local git repo as application code.
- I don't like this option since it is very manual, requires all developers to have the tooling installed, and search results of the codebase will frequently return code from this large library.
- Create some timed task that once a day downloads the latest NPM release of D3, transpiles it, and publishes the result to a private NPM package used by the applications.
- Sounds like pain
Does anyone know of a CDN that does this? I'd almost be tempted to make one of my own via Lambda@Edge and CloudFront if what I'm thinking of doesn't actually exist if I wasn't worried about some of the performance edge cases.
I'd also accept answers about how to successfully get D3 v6 transpiled natively within MeteorJS to support IE11 (e.g. via the legacy bundle).