-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Fixed PnP compatibility for bundled components package #18015
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 |
---|---|---|
|
@@ -21,11 +21,19 @@ interface Options { | |
watch?: boolean; | ||
} | ||
|
||
const makeExternalPredicate = (externals: string[]) => { | ||
if (externals.length === 0) { | ||
return () => false; | ||
} | ||
const pattern = new RegExp(`^(${externals.join('|')})($|/)`); | ||
return (id: string) => pattern.test(id); | ||
}; | ||
Comment on lines
+24
to
+30
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. this returns a I guess rollup supports this? 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.
yes, this returns a predicate function testing if a particular import source should be treated as external or not
yes
#18015 (comment) , basically without this you have such a situation: import _ from 'lodash' // treated as external
import pickBy from 'lodash/pickBy' // bundled in your script The |
||
|
||
async function build(options: Options) { | ||
const { input, externals, cwd, optimized } = options; | ||
const setting: RollupOptions = { | ||
input, | ||
external: externals, | ||
external: makeExternalPredicate(externals), | ||
plugins: [ | ||
nodeResolve({ | ||
preferBuiltins: 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.
This might matter for some packages so you don't end up bundling stuff like
lodash/pickBy
, because without a solution like this'lodash'
is treated as an external but all internal submodules are just bundled