Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename doesn't work if node is of type ExportAllDeclaration or ExportNamedDeclaration #9

Open
RedTn opened this issue Jan 27, 2023 · 0 comments

Comments

@RedTn
Copy link

RedTn commented Jan 27, 2023

Hi @Lazyuki , thanks again for the plugin, I've been using it for a while now but noticed a bug on a certain case.

When we want to externalize a library, and we do it via ExportAllDeclaration or ExportNamedDeclaration the rename is not working. It does work in cjs mode but not in es mode.

Example:

export { default as Accordion } from '@mui/material/Accordion';
export * from '@mui/material/Accordion';

Result:

export { default as Accordion } from './node_modules/@mui/material/Accordion/Accordion.js';
export { default as accordionClasses, getAccordionUtilityClass } from './node_modules/@mui/material/Accordion/

Rollup:

export default defineConfig([
  {
    input: ['index.js'],
    output: [
      {
        dir: 'dist',
        format: 'es',
        sourcemap: true,
        preserveModules: true,
        exports: 'named',
      },
    ],
    plugins: [
      // common libs renamed from node_modules to _ext
      renameNodeModules('_ext'),
      nodeResolve(),
      commonjs(),
    ],
  },
]);

Demo:

See the example here: https://stackblitz.com/edit/node-o5xhzp?file=package.json
Simply run yarn build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant