strothj / react-docgen-typescript-loader

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

Props aren't being shown when components are in node_modules #57

Open elijah1210 opened 4 years ago

elijah1210 commented 4 years ago

I have two repositories, one containing my storybook which loads a compiled version of another repository as a part of node_modules.

The dependency is compiled to commonjs and generates a bunch of .d.ts and .js files.

This is what my webpack.config looks like:

const path = require("path");
module.exports = ({ config }) => {
  config.module.rules.push({
    test: /\.(ts|tsx)$/,
    use: [
      {
        loader: require.resolve("awesome-typescript-loader")
      }
    ]
  });
  config.module.rules.push({
    test: /\.(ts|tsx)$/,
    use: [
      {
        loader: require.resolve("react-docgen-typescript-loader"),
        options: {
          tsconfigPath: path.resolve(__dirname, '../tsconfig.json')
        }
      }
    ],
    include: path.resolve(__dirname, '../node_modules/@repo2')
  });
  config.resolve.extensions.push(".ts", ".tsx");
  return config;
};

Are there transformations I need to apply to repo2? Or am I missing some configuration?

aviraminy commented 4 years ago

Hi, I have the same issue. Sample project is here: https://github.com/aviraminy/storybook-template-mono-repo

daniel-ac-martin commented 4 years ago

I suspect this is related to #100 as it seems that node_modules/ is excluded by TypeScript by default:

The "exclude" property defaults to excluding the node_modules, bower_components, jspm_packages and directories when not specified.

See also: https://www.typescriptlang.org/v2/tsconfig#exclude

Possibly you could avoid this by explicitly setting exclude in your tsconfig but that might have unintended consequences.