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

esinstall: handle cjs auto-named-exports with deep reexports #1194

Merged
merged 2 commits into from
Oct 6, 2020

Conversation

FredKSchott
Copy link
Owner

Changes

  • Finish implementing our automatic CJS named export detection, with support for deeply-imported CJS exports (see tests)

Testing

  • tests added / updated.

Docs

  • n/a

@FredKSchott FredKSchott requested a review from a team as a code owner October 3, 2020 05:56
@vercel
Copy link

vercel bot commented Oct 3, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pikapkg/snowpack/9c0h387g3
✅ Preview: https://snowpack-git-wip-cjs-reexports-support.pikapkg.vercel.app

@@ -92,7 +98,7 @@ export function rollupPluginWrapInstallTargets(
const cjsExports = isExplicitAutoDetect
? cjsAutoDetectExportsRuntime(val)
: cjsAutoDetectExportsStatic(val);
if (cjsExports) {
if (cjsExports && cjsExports.length > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍🏻

const resolvedReexports = reexports.map((e) =>
cjsAutoDetectExportsStatic(require.resolve(e, {paths: [path.dirname(filename)]}), visited),
);
return Array.from(new Set([...exports, ...resolvedReexports]));
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍🏻

@@ -0,0 +1 @@
module.exports = require('./reexported');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ha! This is awesome we’re handling this

Copy link
Collaborator

@drwpow drwpow left a comment

Choose a reason for hiding this comment

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

Tests look good!

@FredKSchott FredKSchott merged commit d03cb5c into master Oct 6, 2020
@FredKSchott FredKSchott deleted the wip-cjs-reexports-support branch October 6, 2020 04:34
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

Successfully merging this pull request may close these issues.

2 participants