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

Symbol propagation breaks non-scope hoisted targets #8564

Closed
devongovett opened this issue Oct 21, 2022 · 0 comments · Fixed by #8565
Closed

Symbol propagation breaks non-scope hoisted targets #8564

devongovett opened this issue Oct 21, 2022 · 0 comments · Fixed by #8565

Comments

@devongovett
Copy link
Member

devongovett commented Oct 21, 2022

🐛 bug report

If you have a project with multiple targets, at least one of which has scope hoisting enabled, and another that does not, symbol propagation runs and can potentially break the non-scope hoisted targets. This is caused by #8432. cc. @mischnic

🎛 Configuration (.babelrc, package.json, cli command)

Two targets:

{
  "targets": {
    "scope-hoist": {
      "scopeHoist": true,
      "optimize": false
    },
    "no-scope-hoist": {
      "scopeHoist": false,
      "optimize": false
    }
  }
}

🤔 Expected Behavior

When scope hoisting is not enabled, imports are not rewritten so we cannot split them to point at each individual symbol.

import {Icon, UIIcon} from 'icon';

If Icon and UIIcon actually are re-exports to different files, the dependency currently gets rewritten to point to one of them, and the other one ends up as undefined at runtime.

Since the non scope hoisting packager doesn't rewrite each individual symbol, we should probably disable this dependency rewriting for non scope hoisted bundles.

😯 Current Behavior

Symbol propagation rewrites dependencies, even when scope hoisting is disabled for a target.

💻 Code Sample

https://github.com/devongovett/parcel-symbol-propagation-repro

🌍 Your Environment

Software Version(s)
Parcel nightly
Node
npm/Yarn
Operating System
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.

1 participant