Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Browser] Fix babel output for the browser #39

Closed
wants to merge 1 commit into from
Closed

[Browser] Fix babel output for the browser #39

wants to merge 1 commit into from

Conversation

oliviertassinari
Copy link

I'm having the following code in my /dist/main.js

exports.parse = defaultParse;
exports.defaultHandlers = defaultHandlers;
exports.handlers = handlers;
exports.resolver = resolver;
exports.utils = utils;

But I need

module.exports = {
  parse: defaultParse,
  defaultHandlers: defaultHandlers,
  handlers: handlers,
  resolver: resolver,
  utils: utils,
};

To make this lib work on the browser.
I'm assuming this is the right way to fix the browser support.
I also had to submit this PR (benjamn/recast#238)

I'm having the following code in my `/dist/main.js`
```js
exports.parse = defaultParse;
exports.defaultHandlers = defaultHandlers;
exports.handlers = handlers;
exports.resolver = resolver;
exports.utils = utils;
```
But I need
```js
module.exports = {
  parse: defaultParse,
  defaultHandlers: defaultHandlers,
  handlers: handlers,
  resolver: resolver,
  utils: utils,
};
```
To make this lib work on the browser.
I'm assuming this is the right way to fix this.
@fkling
Copy link
Member

fkling commented Dec 6, 2015

What's the issue you have in the browser? It shouldn't make a difference.

@oliviertassinari
Copy link
Author

I had an undefined error when doing

import reactDocs from 'react-docgen';

reactDocs.parse(''); // Uncaught TypeError: Cannot read property 'parse' of undefined

Is this usage valid?
(I'm using webpack and babel)

@oliviertassinari
Copy link
Author

I will try import {parse} from 'react-docgen'; tomorrow.

@fkling
Copy link
Member

fkling commented Dec 6, 2015

Yeah, parse is a named export, so you need to do import {parse} from 'react-docgen'; or something like import * as reactDocgen from 'react-docgen'; .

@oliviertassinari
Copy link
Author

Alright, sorry for the noise!

@oliviertassinari oliviertassinari deleted the patch-1 branch December 6, 2015 10:15
@vizath vizath mentioned this pull request Jun 21, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants