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

Use old namespace reexport code pattern for better Node named export sniffing #4826

Merged
merged 2 commits into from
Jan 28, 2023

Conversation

lukastaegert
Copy link
Member

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

Description

This changes the CommonJS pattern for export * from 'external' to always use the older

var foo = require('foo');

Object.keys(foo).forEach(function (k) {
	if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = foo[k];
});

over the newer

var foo = require('foo');

for (var k in foo) {
	if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = foo[k];
}

when live-bindings are disabled (or const is allowed). See also nodejs/cjs-module-lexer#79

@netlify
Copy link

netlify bot commented Jan 27, 2023

Deploy Preview for rollupjs ready!

Name Link
🔨 Latest commit 803ba35
🔍 Latest deploy log https://app.netlify.com/sites/rollupjs/deploys/63d4b365aa68160007863984
😎 Deploy Preview https://deploy-preview-4826--rollupjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Jan 27, 2023

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install rollup/rollup#unify-export-pattern

or load it into the REPL:
https://deploy-preview-4826--rollupjs.netlify.app/repl/?pr=4826

@codecov
Copy link

codecov bot commented Jan 27, 2023

Codecov Report

Merging #4826 (803ba35) into master (b87a2e5) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #4826      +/-   ##
==========================================
- Coverage   99.00%   99.00%   -0.01%     
==========================================
  Files         219      219              
  Lines        7835     7834       -1     
  Branches     2169     2168       -1     
==========================================
- Hits         7757     7756       -1     
  Misses         26       26              
  Partials       52       52              
Impacted Files Coverage Δ
src/finalisers/shared/getExportBlock.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@lukastaegert lukastaegert merged commit db2f2fc into master Jan 28, 2023
@lukastaegert lukastaegert deleted the unify-export-pattern branch January 28, 2023 05:49
@rollup-bot
Copy link
Collaborator

This PR has been released as part of rollup@3.12.0. You can test it via npm install rollup.

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.

Rollup ^3.0.0 cjs re-exports edge case with externalLiveBindings: false
2 participants