3

I'm switching from Rollup 1.27 to 2.48.

I had this dependency communicated in rollup.config.js

alias({
    Paths: {
        'uikit-util': './node_modules/uikit/src/js/util',
    },
    Extensions: ['js', 'json']
}),

so Rollup knows what to do when this occurs

import UIkit from 'uikit';
import { $, on, ajax, hasClass, removeClass, addClass } from 'uikit-util';

At the moment i get this error message:

[!] Error: 'default' is not exported by node_modules\uikit\dist\js\uikit.js, imported by src\js\components\compo_a.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
src\js\components\savedsearches.js (1:7)
1: import UIkit from 'uikit';

I tried using resolve and namedExports in the rollup config, but looks like that's not working.

Mike
  • 5,416
  • 4
  • 40
  • 73

1 Answers1

-1

The solution for this default export problem is to update commonjs option to make it as below

import commonjs from '@rollup/plugin-commonjs';
// rollup.config.js
export default {
  input: 'src/app.ts',
  output: [
    {
...
    commonjs({
      include: /node_modules/,
      requireReturnsDefault: 'auto', // <---- this solves default issue
    }),

documentation link: https://www.npmjs.com/package/@rollup/plugin-commonjs search for requireReturnsDefault

Akshay Vijay Jain
  • 13,461
  • 8
  • 60
  • 73