Docz: Can't import component

Created on 13 Aug 2018  Ā·  9Comments  Ā·  Source: doczjs/docz

Bug Report

Describe the bug

I just wanted to play with docz and check how it works. I've created sample component and sample page and I get this error:

WARNING  Compiled with 1 warnings                                                                                                                                        14:18:41

 warning  in ./src/components/Foo/Foo.mdx

"export 'Foo' was not found in './Foo'

Foo.mdx code

---
name: Foo
---
import { Foo } from "./Foo"

# Foo

this is foo:

<Foo>sample</Foo>

Foo.tsx code

import React, { PureComponent } from "react";

export class Foo extends PureComponent {
  render() {
    return this.props.children;
  }
}

Environment

  • OS: macOS 10.13.6
  • Node/npm version: Node 10.8.0

Have you seen something similar earlier?

// Right now I'm unable to start docz server (versions 0.10.0 and later):

āœ–  fatal     Failed to process your server: TypeError: Cannot read property 'replace' of undefined
    at getRepoUrl (/aaa/node_modules/docz-core/dist/index.js:1:7375)
    at getInitialConfig (/aaa/node_modules/docz-core/dist/index.js:1:9931)
    at Object.init (/aaa/node_modules/docz-core/dist/index.js:1:10148)
    at Promise.all.Array.from.map (/aaa/node_modules/docz-core/dist/index.js:1:10825)
    at Array.map (<anonymous>)
    at DataServer.init (/aaa/node_modules/docz-core/dist/index.js:1:10802)
    at Object.dev (/aaa/node_modules/docz-core/dist/index.js:1:24808)
    at process._tickCallback (internal/process/next_tick.js:68:7)
question

Most helpful comment

When I change it to default export, there are no errors on the build but after I click "Foo" tab on the left I see blue icon of docz on the right and browser crashes (I have to kill chrome process).

zrzut ekranu 2018-08-16 o 10 05 11

All 9 comments

@eskab Can you try to export with default the component?

When I change it to default export, there are no errors on the build but after I click "Foo" tab on the left I see blue icon of docz on the right and browser crashes (I have to kill chrome process).

zrzut ekranu 2018-08-16 o 10 05 11

@nicholasess any ideas?

@eskab do you modify doczrc or add plugins? I’m trying to think about what is happen...

no plugins added, doczrc.js has only title:

export default {
  title: "Fooo",
};

@eskab can you create a repository similar? I want to reproduce errors in localhost

Closed due to no response!

Hi guys, I'm facing the same issue and not sure why it happens and how to deal with it.

Repository to reproduce: https://github.com/AntonSerous/docz-error

Rollup gets it build with no question so I wonder why docz doesn't like it. Please help šŸ™ šŸ™ šŸ™

Some additional info. After running docz dev, right before building, it throws an error 2 times:

There was an error loading your config:

SyntaxError: /Users/as24/Sources/my/docz-error/.babelrc: Unexpected token ] in JSON at position 54
    at JSON.parse (<anonymous>)
    at Object.readFileSync (/Users/as24/Sources/my/docz-error/node_modules/jsonfile/index.js:63:17)
    at loadFile (/Users/as24/Sources/my/docz-error/node_modules/load-cfg/dist/index.js:26:23)
    at Object.load (/Users/as24/Sources/my/docz-error/node_modules/load-cfg/dist/index.js:45:29)
    at getBabelConfig (/Users/as24/Sources/my/docz-error/node_modules/docz-core/dist/index.js:1048:34)
    at Bundler.config (/Users/as24/Sources/my/docz-error/node_modules/docz-core/dist/index.js:1171:29)
    at Bundler.mountConfig (/Users/as24/Sources/my/docz-error/node_modules/docz-core/dist/index.js:721:39)
    at dev (/Users/as24/Sources/my/docz-error/node_modules/docz-core/dist/index.js:1830:43)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
There was an error loading your config:

SyntaxError: /Users/as24/Sources/my/docz-error/.babelrc: Unexpected token ] in JSON at position 54
    at JSON.parse (<anonymous>)
    at Object.readFileSync (/Users/as24/Sources/my/docz-error/node_modules/jsonfile/index.js:63:17)
    at loadFile (/Users/as24/Sources/my/docz-error/node_modules/load-cfg/dist/index.js:26:23)
    at Object.load (/Users/as24/Sources/my/docz-error/node_modules/load-cfg/dist/index.js:45:29)
    at getBabelConfig (/Users/as24/Sources/my/docz-error/node_modules/docz-core/dist/index.js:1048:34)
    at Bundler.config (/Users/as24/Sources/my/docz-error/node_modules/docz-core/dist/index.js:1172:29)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

But the config itself seems valid and there is no ] at position 54

{
  "presets": [
    [
      "@babel/preset-env",
    ],
    "@babel/preset-react",
    "@babel/preset-typescript"
  ],
  "plugins": [
    "@babel/plugin-proposal-class-properties"
  ],
}

However, after throwing the error 2 times, it proceeds with building and once finished, displays the annoying warning this issues author described 2 times (!):

 warning  in ./src/components/Test/Test.mdx

"export 'Test' was not found in './Test'

 warning  in ./src/components/Test/Test.mdx

"export 'Test' was not found in './Test'

@pedronauck Could you please reopen? Thanks

UPD: I created a new one, don't need to reopen, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mquandalle picture mquandalle  Ā·  3Comments

regrettably picture regrettably  Ā·  3Comments

wldcordeiro picture wldcordeiro  Ā·  3Comments

mariusespejo picture mariusespejo  Ā·  3Comments

w0wka91 picture w0wka91  Ā·  3Comments