/* eslint-disable no-undef */
const withCss = require('@zeit/next-css');

module.exports = withCss({
  typescript: {
    // enable rendering when there are type errors
    ignoreDevErrors: true,
    ignoreBuildErrors: true,
  },
  webpack: config => {
    // append docgen loader to the babel loader (executed bottom->top)
    const babelConfig = config.module.rules[0];
    const initialBabelUse = babelConfig.use;
    babelConfig.use = [
      initialBabelUse,
      {
        loader: 'react-docgen-typescript-loader',
      },
    ];

    // apply parsing to imports from other packages src/ folders
    // docgen doesn't work on transpiled packages, and ts parsing isn't
    // applied outside of vx-demo without this
    babelConfig.include.push(/vx-.*\/src/);

    return config;
  },
});

@@ -65,16 +65,46 @@
 t-css');
+%0Aconst path = require('path');
 %0A%0Amodule
@@ -544,16 +544,552 @@
 oader',%0A
+        options: %7B%0A          // display types from outside a component's source even tho%0A          // we hide these with the propFilter below, if we don't do%0A          // this the component's own props become any%0A          tsconfigPath: path.resolve(__dirname, './tsconfig.json'),%0A          // filter props like React.HTMLProps/React.SVGProps%0A          propFilter(prop) %7B%0A            if (prop.parent) %7B%0A              return !prop.parent.fileName.includes('node_modules');%0A            %7D%0A%0A            return true;%0A          %7D,%0A        %7D,%0A
       %7D,

add tsconfig path to react-docgen-typescript-loader, filter non-package props