d3-require icon indicating copy to clipboard operation
d3-require copied to clipboard

Specify the crossOrigin attribute when loading the module

Open j-f1 opened this issue 5 years ago • 3 comments

This allows scripts like React to properly listen to the error event, allowing better debugging.

j-f1 avatar Nov 07 '19 00:11 j-f1

This will break require against a domain that doesn’t have CORS enabled, however. This should probably be an option. Hmm.

mbostock avatar Nov 07 '19 05:11 mbostock

That’s unfortunate :(

Here are a couple ways of making it an option:

require('d3', { cors: true })
require.cors('d3')

notebook

Note that while the first one doesn’t currently work, it has syntactic parallels with how require.alias supports custom module values (maybe require could support them in the future?), so I prefer the second one. The second one also would make the code much simpler.

j-f1 avatar Nov 07 '19 13:11 j-f1

I’ve added a test, but it seems yarn test doesn’t actually run the tests.

j-f1 avatar Nov 07 '19 14:11 j-f1