-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: transform in common js #47
Conversation
It seems that commonjs transforms the absolute require I think the correct solution is: external-globals should register a external-globals should not transform commonjs modules. |
I think you're right. I'll fix it later |
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
package.json
Outdated
"c8": "^10.1.2", | ||
"endent": "^2.1.0", | ||
"eslint": "^9.5.0", | ||
"globals": "^15.8.0", |
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.
What does globals
do?
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.
Because you imported it in eslint.config.mjs. transitive dependencies is not work in pnpm.
I've deleted it.
test/test.js
Outdated
}] | ||
}, | ||
{ | ||
transformInCommonJs: true |
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 can remove this option.
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.
removed
test/test.js
Outdated
}] | ||
}, | ||
{ | ||
transformInCommonJs: true |
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.
Same as above.
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.
removed
I found another case that behaviour is not as before. Suppose "bar" is the external module.
now the bar can not be resolved. I'm not sure that's a problem, maybe user should not export * from an external global module |
It's a known issue that external-globals doesn't work with export all syntax:
This will only work if |
if a commonjs module imported by es module.the global name will be transformed. but a commonjs module imported by another commonjs module it will not be transformed.
in this case if bar is global.
I think this is not right. so i transformed it after @rollup/plugin-commonjs.
And i added a new config to control this feature, default is closed.