5

I would like to use the modularizeImports option of the Next.js compiler on a library that its barrel file exports from multiple directories within the library package.

What I mean is the index.ts file for the library looks something like this:

//index.ts
export {default as SomeComponent} from './components/SomeComponent';
export {default as someFun} from './utils/someFunction';
export {default as someHook} from './hooks/someHook';

ideally I would like to have something like this

//next.config.js
  modularizeImports: {
    '@some/library': {
      transform: '@some/library/dist/(components|hooks|utils)/{{member}}',
    },
  },

but

  1. I am not sure if this functionality is even possible
  2. if it is I am not sure how to to write it.

I also tried passing it an array of transforms but it only accepts a single string.

Under the hood this option is implemented with https://docs.rs/handlebars/latest/handlebars/ afaik

Dimitris Karagiannis
  • 8,942
  • 8
  • 38
  • 63

0 Answers0