-
-
Notifications
You must be signed in to change notification settings - Fork 604
feat(commonjs): export properties defined using Object.defineProperty(exports, ..) #222
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for taking the time to put this together, we really appreciate it!
@lukastaegert @NotWoods please have a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me too, just a minor naming suggestion.
packages/commonjs/src/transform.js
Outdated
@@ -299,6 +318,10 @@ export function transformCommonjs( | |||
return; | |||
} | |||
|
|||
// Is this a call to Object.defineProperty(exports, ...)? | |||
const def = defineProperty(node, 'exports'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename the function to isDefinePropertyCall
. Then the comment is also not needed. The return value could be propertyName
, then I do not have to check the function definition what it means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done @lukastaegert 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually on reflection I propose it be called getDefinePropertyCallName
, the java programmer in me is complaining that an isX
function should only return a boolean. See latest commit. That said - happy to rollback if you prefer isDefinePropertyCall
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not return a boolean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but we’d also need to get the property name to add to namedExports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, and you definitely got what I meant 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
…(exports, ..) (rollup#222) * feat: support Object.defineProperty(exports, ..) * chore: rename defineProperty -> isDefinePropertyCall * chore: rename isDefinePropertyCall -> getDefinePropertyCallName
Rollup Plugin Name:
commonjs
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
This pr adds exports that have been defined using the
Object.defineProperty(exports, ...)
technique. I was running into an issue with a 3rd party lib (@material-ui/[email protected]
) where it was using this technique to define the exports. Rollup was falling over with the errorexport 'foo' is not exported by 'path/to/module'
.