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

Make sure uninitialised exports turn up via .hasOwnProperty for non-ES formats #3957

merged 1 commit into from Feb 12, 2021


Copy link

@lukastaegert lukastaegert commented Feb 12, 2021

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:


This will make sure that even uninitialised named exports will create properties on the exports object in CJS/IIFE/AMD/UMD formats so that checking for those properties via .hasOwnProperty or Object.keys works.
This is important for tools that rely on this for e.g. merging and forwarding namespaces.

This was already working properly for constant exports but was broken for exports that were assigned dynamically later, example:

Note that when updateFoo is not run, the property foo will no exist.

@lukastaegert lukastaegert force-pushed the uninitialised-exports branch from 2d6dce7 to 13d4682 Feb 12, 2021
Copy link

@rollup-bot rollup-bot commented Feb 12, 2021

Thank you for your contribution! ❤️

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

npm install rollup/rollup#uninitialised-exports

or load it into the REPL:

Copy link

@codecov codecov bot commented Feb 12, 2021

Codecov Report

Merging #3957 (e7a3f36) into master (45d8e5e) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3957   +/-   ##
  Coverage   97.19%   97.19%           
  Files         190      191    +1     
  Lines        6694     6694           
  Branches     1958     1958           
  Hits         6506     6506           
  Misses         99       99           
  Partials       89       89           
Impacted Files Coverage Δ
src/ast/nodes/VariableDeclaration.ts 97.87% <100.00%> (-0.13%) ⬇️
src/ast/nodes/VariableDeclarator.ts 100.00% <100.00%> (ø)
src/utils/reassignedExportsMember.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 45d8e5e...e7a3f36. Read the comment docs.

@lukastaegert lukastaegert force-pushed the uninitialised-exports branch from 13d4682 to e7a3f36 Feb 12, 2021
@lukastaegert lukastaegert merged commit 3394ae9 into master Feb 12, 2021
9 checks passed
9 checks passed
14 (Windows)
12 (Windows)
10 (Windows)
ci/circleci: analysis Your tests passed on CircleCI!
ci/circleci: node-v10-latest Your tests passed on CircleCI!
ci/circleci: node-v12-latest Your tests passed on CircleCI!
ci/circleci: node-v14-latest Your tests passed on CircleCI!
codecov/patch 100.00% of diff hit (target 97.19%)
codecov/project 97.19% (+0.00%) compared to 45d8e5e
@lukastaegert lukastaegert deleted the uninitialised-exports branch Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants