Skip to content

Specify the crossOrigin attribute when loading the module#31

Open
j-f1 wants to merge 4 commits intod3:mainfrom
j-f1:patch-1
Open

Specify the crossOrigin attribute when loading the module#31
j-f1 wants to merge 4 commits intod3:mainfrom
j-f1:patch-1

Conversation

@j-f1
Copy link
Copy Markdown

@j-f1 j-f1 commented Nov 7, 2019

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

This allows scripts like React to properly listen to the `error` event, allowing better debugging.
@mbostock
Copy link
Copy Markdown
Member

mbostock commented Nov 7, 2019

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

@j-f1
Copy link
Copy Markdown
Author

j-f1 commented Nov 7, 2019

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
Copy link
Copy Markdown
Author

j-f1 commented Nov 7, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants