-
Notifications
You must be signed in to change notification settings - Fork 204
feat(rollup): simplify external #80
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,8 +88,19 @@ if (isPreact) { | |
| } | ||
|
|
||
| const externalPattern = new RegExp(`^(${external.join('|')})($|/)`) | ||
| const externalPredicate = | ||
| external.length === 0 ? () => false : id => externalPattern.test(id) | ||
|
|
||
| function externalPredicate(id) { | ||
| const isDep = externalPattern.test(id) | ||
| if (umd) { | ||
| // for UMD, we want to bundle all non-peer deps | ||
| return isDep | ||
| } | ||
| // for esm/cjs we want to make all node_modules external | ||
| // TODO: support bundledDependencies if someone needs it ever... | ||
| const isNodeModule = id.includes('node_modules') | ||
| const isRelative = id.startsWith('.') | ||
| return isDep || (!isRelative && !path.isAbsolute(id)) || isNodeModule | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
what cases are covered by this which are not covered by
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's strange, but this would be called with '@emotion/styled-base' (not listed as a dep because it's added via a babel plugin). So I also need to factor in whether it's relative. But I can't JUST do relative either because for each mistake it's called with both the source string id and the full path to the resolved module.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but arent full paths already covered (kinda) by
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Full paths are, but not non-relative paths. It's weird I know, but I spent a few hours on this in a project that uses a similar config (paypal-scripts) and this was the only way I found to fix it 🤷♂️
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, maybe its brain fart but I still dont get it 😅 non-relative paths can be either:
am i missing something? 🤔
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's kinda hard to explain. All I can say is that if I didn't have the relative and absolute logic in here, then weird things would happen :/
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it shouldnt hurt, so im not opposed to it, was rather just curious why this is needed APPROVED! 👍 |
||
| } | ||
|
|
||
| const filename = [ | ||
| pkg.name, | ||
|
|
||
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'd make it more strict with RegExp
/\/node_modules\//, u'd have to check ifidis normalized here, if not u'd have to construct the regexp based on path.sep (to support windows)