speedskater / babel-plugin-rewire

A babel plugin adding the ability to rewire module dependencies. This enables to mock modules for testing purposes.
843 stars 90 forks source link

Documentation clarification #231

Open justin-barca opened 4 years ago

justin-barca commented 4 years ago

In https://github.com/speedskater/babel-plugin-rewire#test-code-2 a named import is used for the rewire api. Later in the documentation you say If no default export is present, the API-Object named __RewireAPI__ becomes the default export of the module. The example code has no default export so I think the example test should use the default import in order to avoid the as syntax and clarify. The statement If no default export is present, the API-Object named __RewireAPI__ becomes the default export of the module. could be improved by adding and is also available as a named import. If the module without a default export has a named export with the rewire, why also provide it as a default export? Naming clashes are unlikely and no module using this should have an export RewireAPI because that would be confusing.