title: Next.js SyntaxError "Unexpected token 'export'"
body: <p>I'm trying to import a functions from a dependency to my next/react functional component, but somehow I keep getting the following error:</p>
  <blockquote>
  <p>SyntaxError: Unexpected token 'export'</p>
  </blockquote>
  <p>That's the function I'm trying to import:</p>
  <pre><code>export function classes(...args) {
      const list = [];
      for (let i = 0; i &lt; args.length; i++) {
          const entry = args[i];
          if (typeof entry === &quot;string&quot;) {
              list.push(entry);
          }
          else {
              for (let key in entry) {
                  if (entry[key]) {
                      list.push(key);
                  }
              }
          }
      }
      return list.join(&quot; &quot;);
  </code></pre>
  <p>There additionally is a <code>classes.d.ts</code> next to the <code>classes.js</code> above:</p>
  <pre><code>export declare function classes(...args: Array&lt;string | {
      [key: string]: any;
  }&gt;): string;
  </code></pre>
  <p>Exporting this code identically from within the project works fine, but not when I use an external library from <code>node_modules</code>. How so?</p>
  <p>Read about <code>next-transpile-module</code>, but haven't been able to make it run with this one either.</p>
  <p>The only way to make the import work is using relative paths <code>../../node_modules/thedependency/class</code> - how can I make it work properly?</p>