ensdomains / ensjs-v2

Javascript bindings for the Ethereum Name Service
208 stars 122 forks source link

Next.js: Module parse failed: Unexpected token (2:8) on v3.0.0-alpha.1 #95

Open BrianLi101 opened 2 years ago

BrianLi101 commented 2 years ago

Using the newest alpha version 3.0.0-alpha.1 of this library with Next.js results in the following compile error:

error - ./node_modules/@ensdomains/ensjs/dist/esm/functions/batch.d.ts
Module parse failed: Unexpected token (2:8)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Screen Shot 2022-06-25 at 9 20 45 PM

Earlier versions of the library like 2.1.0 have not caused this issue.

I was able to find a temporary workaround by using next-transpile-modules and modifying the next.config.js file in my project:

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  images: {
    domains: ['storage.googleapis.com'],
  },
};

const withTM = require('next-transpile-modules')(['@ensdomains/ensjs']); // pass the modules you would like to see transpiled

module.exports = withTM(nextConfig);

Raising this issue for visibility, hopefully it helps with identifying the issue.