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

Error: 'xyz' is not exported by xyz when re-exporting twice #4158

Closed
yhaering opened this issue Jun 29, 2021 · 1 comment · Fixed by #4159
Closed

Error: 'xyz' is not exported by xyz when re-exporting twice #4158

yhaering opened this issue Jun 29, 2021 · 1 comment · Fixed by #4159

Comments

@yhaering
Copy link

yhaering commented Jun 29, 2021

Rollup Version

2.52.3

Operating System (or Browser)

Windows

Node Version (if applicable)

14.15.1

Link To Reproduction

https://rollupjs.org/repl/?version=2.52.3&shareable=JTdCJTIybW9kdWxlcyUyMiUzQSU1QiU3QiUyMm5hbWUlMjIlM0ElMjJtYWluLmpzJTIyJTJDJTIyY29kZSUyMiUzQSUyMmltcG9ydCUyMCU3QiUyMHVzZVN0YXRlJTIwJTdEJTIwZnJvbSUyMCcuJTJGYSclM0IlNUNuJTVDbmNvbnNvbGUubG9nKHVzZVN0YXRlKSUzQiUyMiUyQyUyMmlzRW50cnklMjIlM0F0cnVlJTdEJTJDJTdCJTIybmFtZSUyMiUzQSUyMmEuanMlMjIlMkMlMjJjb2RlJTIyJTNBJTIyZXhwb3J0JTIwKiUyMGZyb20lMjAnLiUyRmInJTIyJTdEJTJDJTdCJTIybmFtZSUyMiUzQSUyMmIuanMlMjIlMkMlMjJjb2RlJTIyJTNBJTIyZXhwb3J0JTIwKiUyMGZyb20lMjAncmVhY3QnJTNCJTIyJTdEJTJDJTdCJTIybmFtZSUyMiUzQSUyMnJvbGx1cC5jb25maWcuanMlMjIlMkMlMjJjb2RlJTIyJTNBJTIyY29uc3QlMjAlN0IlMjBub2RlUmVzb2x2ZSUyMCU3RCUyMCUzRCUyMHJlcXVpcmUoJyU0MHJvbGx1cCUyRnBsdWdpbi1ub2RlLXJlc29sdmUnKSUzQiU1Q25jb25zdCUyMGNvbW1vbmpzJTIwJTNEJTIwcmVxdWlyZSgnJTQwcm9sbHVwJTJGcGx1Z2luLWNvbW1vbmpzJyklM0IlNUNuJTVDbm1vZHVsZS5leHBvcnRzJTIwJTNEJTIwJTdCJTVDbiUyMCUyMCUyMCUyMGlucHV0JTNBJTIwJy4lMkZzcmMlMkZpbmRleC5qcyclMkMlNUNuJTIwJTIwJTIwJTIwb3V0cHV0JTNBJTIwJTdCJTVDbiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGRpciUzQSUyMCdlc20nJTJDJTVDbiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZvcm1hdCUzQSUyMCdlcyclMkMlNUNuJTIwJTIwJTIwJTIwJTdEJTJDJTVDbiUyMCUyMCUyMCUyMGV4dGVybmFsJTNBJTIwJTVCJTJGcmVhY3QlMkYlNUQlMkMlNUNuJTIwJTIwJTIwJTIwcGx1Z2lucyUzQSUyMCU1QiU1Q24lMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBub2RlUmVzb2x2ZSgpJTJDJTVDbiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGNvbW1vbmpzKCklMkMlNUNuJTIwJTIwJTIwJTIwJTVEJTVDbiU3RCUyMiU3RCU1RCUyQyUyMm9wdGlvbnMlMjIlM0ElN0IlMjJmb3JtYXQlMjIlM0ElMjJlcyUyMiUyQyUyMm5hbWUlMjIlM0ElMjJteUJ1bmRsZSUyMiUyQyUyMmFtZCUyMiUzQSU3QiUyMmlkJTIyJTNBJTIyJTIyJTdEJTJDJTIyZ2xvYmFscyUyMiUzQSU3QiU3RCU3RCUyQyUyMmV4YW1wbGUlMjIlM0FudWxsJTdE

Expected Behaviour

When re-exporting an external module twice while having it in the external pattern of the rollup config, rollup seems to not find any export of that module. It can be resolved by either removing one of the re-exports or removing the dependency from the list of external modules. In case of the example linked above, everything starts working again as soon as I import from b.js instead of a.js and results in the bundle below.

import { useState } from 'react';

console.log(useState);

Actual Behaviour

> rollup -c

./src/index.js → esm...
[!] Error: 'useState' is not exported by src\a.js, imported by src\index.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
src\index.js (1:8)
1: import {useState} from './a';
           ^
2:
3: console.log(useState);
Error: 'useState' is not exported by src\a.js, imported by src\index.js
    at error (C:\develop\sandbox_rollup\node_modules\rollup\dist\shared\rollup.js:164:30)
    at Module.error (C:\develop\sandbox_rollup\node_modules\rollup\dist\shared\rollup.js:9888:16)
    at Module.traceVariable (C:\develop\sandbox_rollup\node_modules\rollup\dist\shared\rollup.js:10269:29)
    at ModuleScope.findVariable (C:\develop\sandbox_rollup\node_modules\rollup\dist\shared\rollup.js:9046:39)
    at Identifier.bind (C:\develop\sandbox_rollup\node_modules\rollup\dist\shared\rollup.js:4572:40)
    at CallExpression.bind (C:\develop\sandbox_rollup\node_modules\rollup\dist\shared\rollup.js:2891:31)
    at CallExpression.bind (C:\develop\sandbox_rollup\node_modules\rollup\dist\shared\rollup.js:6995:15)
    at ExpressionStatement.bind (C:\develop\sandbox_rollup\node_modules\rollup\dist\shared\rollup.js:2895:23)
    at Program.bind (C:\develop\sandbox_rollup\node_modules\rollup\dist\shared\rollup.js:2891:31)
    at Module.bindReferences (C:\develop\sandbox_rollup\node_modules\rollup\dist\shared\rollup.js:9884:18)
@lukastaegert
Copy link
Member

Thanks for spotting, fix at #4159

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

Successfully merging a pull request may close this issue.

2 participants