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

fix [import/named] for importing from a module which re-exports * from node_modules or commonjs module #1569

Merged
merged 2 commits into from
Jan 31, 2020

Conversation

redbugz
Copy link
Contributor

@redbugz redbugz commented Dec 12, 2019

Fixes #1446
Based on #1447

When re-exporting * from a commonjs module, or a module in node_modules which comes through as a commonjs module, do not error since the commonjs exports cannot be evaluated. Treat with similar logic to ignored modules or directly importing from a commonjs module.

When re-exporting *, the module is listed in dependencies instead of reexports. There is similar logic for when re-exporting a named export, to check for a null from the exportCache, which I understand to mean an ignored or unparseable es5/commonjs module:
https://github.com/benmosher/eslint-plugin-import/blob/master/src/ExportMap.js#L91

There is a todo in this location, and I'm not sure if this code satisfies that todo and it can be removed or not.
Also, when logging the value of innerMap, I never it saw it be undefined. So it's possible the continue line is also no longer needed, but I am not sure.

This fixes hasDeep, but there is similar logic in has and get:
https://github.com/benmosher/eslint-plugin-import/blob/master/src/ExportMap.js#L68
https://github.com/benmosher/eslint-plugin-import/blob/master/src/ExportMap.js#L146
I'm not sure if those should get similar treatment, or if those are not relevant for this issue.

@redbugz redbugz changed the title fix [import/named] for importing from a module which re-exports named exports from a node_modules or commonjs module fix [import/named] for importing from a module which re-exports * from a node_modules or commonjs module Dec 12, 2019
@redbugz redbugz changed the title fix [import/named] for importing from a module which re-exports * from a node_modules or commonjs module fix [import/named] for importing from a module which re-exports * from node_modules or commonjs module Dec 12, 2019
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.4%) to 93.837% when pulling 6c30aa6 on redbugz:export-star-named into 4e8960d on benmosher:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.4%) to 93.837% when pulling 6c30aa6 on redbugz:export-star-named into 4e8960d on benmosher:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.4%) to 93.837% when pulling 6c30aa6 on redbugz:export-star-named into 4e8960d on benmosher:master.

@coveralls
Copy link

coveralls commented Dec 12, 2019

Coverage Status

Coverage increased (+0.001%) to 97.838% when pulling 392c6b9 on redbugz:export-star-named into aff3a46 on benmosher:master.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, seems straightforward!

@ljharb ljharb added the bug label Dec 12, 2019
@yuri-sakharov
Copy link

yuri-sakharov commented Dec 23, 2019

Looks like build checks failed. I also need this fix. When will it be in release version? Thanks a lot.

@ljharb ljharb closed this Jan 11, 2020
@ljharb ljharb reopened this Jan 11, 2020
@ljharb ljharb merged commit 392c6b9 into import-js:master Jan 31, 2020
@redbugz redbugz deleted the export-star-named branch February 5, 2020 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

[import/named] fails to track deep exports when re-exporting from a module in node_modules
4 participants