Docz: Export default as does not work anymore in v1

Created on 12 Apr 2019  路  4Comments  路  Source: doczjs/docz

Bug Report

I'm using "docz": "0.13.7" in production and at the root of my project I have an index file that imports all the components and export them like that

export { default as Button } from './components/Button'

If I update to v1, this line throws an error

ERROR  Failed to compile with 1 errors                                                                                                                            9:17:58 AM

 error  in ./src/index.js

Module parse failed: Unexpected token (18:11)
You may need an appropriate loader to handle this file type.
| export { default as Button } from './components/Button';
| 
> if (typeof default !== 'undefined' && default && default === Object(default)) {
|   Object.defineProperty(default, '__filemeta', {
|     enumerable: true,

 @ ./src/components/DateRangePicker/README.mdx 18:0-65 138:27-42 139:34-56 159:35-50 197:27-42 198:34-56 218:35-50 223:20-42 223:65-87 223:113-135 223:159-181 257:27-42 258:
34-56 278:35-50 312:12-27
 @ ./.docz/app/imports.js
 @ ./.docz/app/root.jsx
 @ ./.docz/app/index.jsx
 @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./.docz/app/index.jsx

Changing it to

import Button from './components/Button';
export { Button }

fix it but it is very annoying if I have to change all my components

Environment

  • OS: OSX 10.14.4
  • Node: v10.15.3
  • npm: 6.4.1

Most helpful comment

I just made a workaround. I think it's enough for this issue. @pedronauck

All 4 comments

We've got the same issue. Anyone know what kind of loader is needed?

same problem with functions in index file:

// Button.jsx
import {b} from './a';

// a.js
export {default as b} from './b';

// b.js
export const b = null;
./src/components/a.js 3:11
Module parse failed: Unexpected token (3:11)
You may need an appropriate loader to handle this file type.
| export { default as b } from './b';
| 
> if (typeof default !== 'undefined' && default && default === Object(default)) {
|   Object.defineProperty(default, '__filemeta', {
|     enumerable: true,

I just made a workaround. I think it's enough for this issue. @pedronauck

Should be fixed by #790 and #805, closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ilyanoskov picture ilyanoskov  路  3Comments

mariusespejo picture mariusespejo  路  3Comments

merelinguist picture merelinguist  路  3Comments

kachkaev picture kachkaev  路  3Comments

w0wka91 picture w0wka91  路  3Comments