Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

482
Views
export 'default' was not found when I try to import my webpack library

This is my source code ./source/client/main.jsx.

export default {
  test: () => console.log('Flow')
};

And this is my webpack.config.cjs.

const path = require('path');
const webpack = require('webpack');
const packageJSON = require('./package.json');

module.exports = (env, argv) => {
  return {
    mode: 'development',
    entry: './source/client/main.jsx',
    // entry: './main.js',
    output: {
      path: path.join(__dirname, 'release'),
      filename: 'main.js',
      library: {
        name: packageJSON.name,
        type: 'umd'
      }
    },
    devtool: 'source-map',
    module: {
      rules: [
        {
          test: /\.jsx?$/,
          exclude: /node_modules/,
          use: {
            loader: 'babel-loader',
            options: {
              presets: [
                '@babel/preset-env',
                '@babel/preset-react'
              ],
              plugins: [
                '@babel/plugin-transform-runtime'
              ]
            }
          }
        }
      ]
    }
  };
};

My package.json contains a list of dependencies and both main and module pointing to the webpack product.

  "main": "./release/main.js",
  "module": "./release/main.js",

However, when I try to import my module in another webpack project, I get the default was not found error.

import Test from 'test';
export 'default' (imported as 'Test') was not found in 'test' (module has no exports)

Am I building the module wrong?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!