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

TSC's helpers cause module to be marked as CommonJS #8467

Closed
devongovett opened this issue Sep 12, 2022 · 2 comments
Closed

TSC's helpers cause module to be marked as CommonJS #8467

devongovett opened this issue Sep 12, 2022 · 2 comments

Comments

@devongovett
Copy link
Member

TSC builds helpers that look like this:

var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || ...

The this reference there causes Parcel to mark the module as CommonJS. This in turn causes the packager to add a setter to the $parcel$export call, which may include invalid syntax (e.g. function (v) { return (parcelRequire("3RBLs")) = v; }).

let set = asset.meta.hasCJSExports
? ', ' + this.buildFunctionExpression(['v'], `${resolved} = v`)
: '';

These are potentially two separate issues:

  1. We should detect that the this reference is only a read, not a write to avoid marking as CJS.
  2. We should detect that the resolved export is a parcelRequire and not add a setter in that case?
@devongovett
Copy link
Member Author

Filed a TSC issue: microsoft/TypeScript#50761

@devongovett
Copy link
Member Author

Fixed by #9318 #9330

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant