Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing issuer in Webpack Rule breaks build #299

Open
2 tasks done
droegier opened this issue Aug 15, 2023 · 0 comments
Open
2 tasks done

Missing issuer in Webpack Rule breaks build #299

droegier opened this issue Aug 15, 2023 · 0 comments

Comments

@droegier
Copy link

  • I HAVE READ THE FAQ AND MY PROBLEM WAS NOT DESCRIBED THERE
  • I WILL GIVE 10$ TO BAGUETTE IF MY SOLUTION WAS ACTUALLY IN THE README/FAQ

Are you trying to transpile a local package or an npm package?
Unclear. Could be both.

Describe the bug
When I run next build it fails.

> Build error occurred
TypeError: Cannot read properties of undefined (reading 'and')
    at Object.webpack (/Users/davidroegiers/Jurata/jurata-web/web/node_modules/next-transpile-modules/src/next-transpile-modules.js:201:60)
    at getBaseWebpackConfig (/Users/davidroegiers/.nvm/versions/node/v18.9.0/lib/node_modules/next/dist/build/webpack-config.js:2163:32)
    at async Promise.all (index 0)
    at async Span.traceAsyncFn (/Users/davidroegiers/.nvm/versions/node/v18.9.0/lib/node_modules/next/dist/trace/trace.js:103:20)
    at async webpackBuildImpl (/Users/davidroegiers/.nvm/versions/node/v18.9.0/lib/node_modules/next/dist/build/webpack-build/impl.js:133:21)
    at async webpackBuild (/Users/davidroegiers/.nvm/versions/node/v18.9.0/lib/node_modules/next/dist/build/webpack-build/index.js:137:16)
    at async /Users/davidroegiers/.nvm/versions/node/v18.9.0/lib/node_modules/next/dist/build/index.js:595:123
    at async Span.traceAsyncFn (/Users/davidroegiers/.nvm/versions/node/v18.9.0/lib/node_modules/next/dist/trace/trace.js:103:20)
    at async build (/Users/davidroegiers/.nvm/versions/node/v18.9.0/lib/node_modules/next/dist/build/index.js:148:29)

To Reproduce
run next build for my Jurata project on my local machine

Expected behavior
I expect it to run without failing.

Setup

  • Next.js version: 12.0.8
  • next-transpile-modules version: 9.0.0
  • Node.js version: 18.9.0
  • npm version: 9.8.1
  • Operating System:
  • Webpack 4 or 5: 5.88.2
const path = require('path');
const withTM = require('next-transpile-modules')([
  'jurata-styleguide',
  'strict-uri-encode',
  'split-on-first',
  'query-string',
]);
const { i18n, rewrites, oldHomepagePathsRedirects } = require('./next-i18next.config');

const config = withTM(
  {
    async rewrites() {
      return rewrites;
    },
    webpack(config, options) {
      // Support SVG import
      config.module.rules.push({
        test: /\.(svg)$/,
        use: ['raw-loader'],
      });

      // Prevent duplicate modules from the styleguide package, a better
      // solution is welcome
      config.resolve.alias['react'] = path.resolve('./node_modules/react');
      config.resolve.alias['react-dom'] = path.resolve('./node_modules/react-dom');
      config.resolve.alias['@emotion/core'] = path.resolve('./node_modules/@emotion/core');
      config.resolve.alias['@emotion/react'] = path.resolve('./node_modules/@emotion/react');

      if (!options.isServer) {
        config.resolve.alias['contentful'] = path.resolve('./node_modules/contentful/dist/contentful.legacy.min.js');
      }

      // This is needed
      config.resolve.alias['joi'] = path.resolve('./node_modules/joi/lib/index.js');

      return config;
    },
  },
  { debug: true }
);

module.exports = {
  i18n,
  ...config,
  async redirects() {
    const isProduction = process.env.NEXT_PUBLIC_ENVIRONMENT === 'production';
    const redirects = [
      {
        source: '/rechtsguide/wp-content/uploads/2021/05/Jurata-Virtual-Lawyer.svg',
        destination: 'https://s3.eu-central-1.amazonaws.com/jurata.ch/Jurata-Virtual-Lawyer.svg',
        permanent: false,
      },
      {
        source: `/rechtsguide/:path*`,
        destination: `/de`,
        permanent: false,
      },
      {
        source: `/zkb`,
        destination: `/de/unternehmen-gruenden-zkb`,
        permanent: false,
      },
      {
        source: '/trademark',
        destination: '/de/markenschutz',
        permanent: false,
      },
      {
        source: '/start-summit',
        destination: '/en',
        permanent: false,
      },
      {
        source: '/startup-nights-2022',
        destination: '/',
        permanent: false,
      },
      {
        source: '/gruenden',
        destination: '/de/unternehmen-gruenden',
        permanent: false,
      },
      ...oldHomepagePathsRedirects,
      process.env.NEXT_PUBLIC_MAINTENANCE === 'true'
        ? {
            source: '/((?!maintenance).*)*',
            destination: '/maintenance.html',
            permanent: false,
          }
        : null,
    ].filter(Boolean);

    return isProduction
      ? [
          {
            source: '/:path*',
            has: [
              {
                type: 'query',
                key: 'i',
                value: '(?!.*_admin)(.*(?:incorporation|Incorporation)).*',
              },
            ],
            destination: 'https://www.jurata.ch/de/unternehmen-gruenden',
            permanent: false,
          },
          {
            source: '/:path*',
            has: [
              {
                type: 'query',
                key: 'i',
                value: '(?!.*_admin)(.*(?:trademark|Trademark)).*',
              },
            ],
            destination: 'https://www.jurata.ch/de/markenschutz',
            permanent: false,
          },
          ...redirects,
        ]
      : redirects;
  },
  images: {
    domains: [
      process.env.NEXT_PUBLIC_COCKPIT_URL_PUBLIC.replace('https://', ''),
      'images.ctfassets.net',
      'backend.staging.jurata.ch',
      'backend.jurata.ch',
      'cockpit.staging.jurata.ch',
      'cockpit.jurata.ch',
    ],
    formats: ['image/avif', 'image/webp'],
  },
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant