strothj / react-docgen-typescript-loader

Webpack loader to generate docgen information from Typescript React components.
Other
360 stars 47 forks source link

Help wanted for preset CRA #67

Closed mrmckeb closed 4 years ago

mrmckeb commented 4 years ago

Hi there,

I was working with @shilman to get preset-create-react-app working with this, and we're seeing an issue a few other users have reported.

One example: https://github.com/storybookjs/storybook/issues/8114

I was hoping someone from this team could take a quick look.

If you install this locally, you can see a reproduction by running: yarn workspace @storybook/preset-create-react-app storybook

https://github.com/storybookjs/presets

strothj commented 4 years ago

The default behavior for the react-docgen-typescript project appears to be that it initializes a new TypeScript config using defaults if a tsconfig is not explicitly passed.

You might want to recommend setting it in your preset options:

module.exports = [
  {
    name: '@storybook/preset-create-react-app',
    options: {
      scriptsPackageName: '@my/react-scripts',
      useTsDocgenLoader: true,
      tsDocgenLoaderOptions: {
        tsconfigPath: path.resolve(__dirname, "../tsconfig.json"),
      }
    },
  },
];

Or, if you're assuming the standard CRA config, you could default that value for users.

There may be a problem with the default JavaScript docgen babel plugin. They will both be attempting to inject code for the documentation. When using TypeScript, it might make sense to disable the one Storybook injects by default.

mrmckeb commented 4 years ago

Thanks, I'll try this tomorrow!

mrmckeb commented 4 years ago

That was it, amazing - thanks @strothj!

The Babel plugin was conflicting.