Dfinity/agent package loaders error

Hi guys, I have this error with my react/ts setup while using dfinity/agent:

./node_modules/@dfinity/agent/lib/esm/index.js 13:9 Module parse failed: Unexpected token (13:9) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See Concepts | webpack
export * as polling from ‘./polling’;

I’m using next.js and ts-node.
Any pointers and/or resources would be much appreciated. Thanks

try installing

npm install --save-dev babel-loader @babel/core @babel/plugin-proposal-export-namespace-from

then modify your webpack.config.js

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.js$/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: [
              '@babel/preset-env'
            ],
            plugins: [
              '@babel/plugin-proposal-export-namespace-from'
            ]
          }
        }
      }
    ]
  }
  // ...
};
1 Like