-
-
Notifications
You must be signed in to change notification settings - Fork 78.8k
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(plugins): allow to import separate plugins #26767
Conversation
83c14b1
to
6c1099f
Compare
6c1099f
to
af09846
Compare
build/build-plugins.js
Outdated
} | ||
|
||
// Do not bundle Tooltip in Popover | ||
if (bsPlugins[pluginKey] === bsPlugins.Popover) { |
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.
woudln't pluginKey === 'Popover'
be simpler ?
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.
Yep it'll clearer thanks @stof 👍
31422db
to
f2f18df
Compare
build/build-plugins.js
Outdated
@@ -0,0 +1,80 @@ | |||
/*! | |||
* Script to build our plugins to use them separately. | |||
* Copyright 2017-2018 The Bootstrap Authors |
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.
nitpicking, but this file is new, so 2018 is enough.
|
Yep I'm not confortable with adding a new set of dist files... I thought about deleting our Those files don't have to be tested because the logic is the same. Bundlers are used a lot nowaday, so we should be able to provide distinct plugins |
Please wait for @mdo's feedback too. |
f2f18df
to
6b1c63e
Compare
This wouldn't be a patch release, this would be a minor or major as it adds new functionality IMO. Could be convinced otherwise though. That aside, does anything change once we've removed the jQuery dependency? Does this gain us anything long term? Is there a path forward without generating more dist files? |
Nope nothing will change about that when jQuery will be removed, I choose to build our plugins in UMD (our other dist files are in UMD too, except Unfortunately there is no other path, for example Popper.js (see https://cdnjs.com/libraries/popper.js) is built in three format (UMD, ESM and IIFE) |
The issue is that even without jQuery, your plugins still depend on Util, and these internal dependencies are incompatible with bundlers if they rely on global variables all the time. One solution could be to turn the existing |
Unfortunately it's doesn't work if we build our |
@Johann-S that's not true. UMD builds can still expose their export to be consumed by others. That's the whole point of UMD. |
I tried what you said @stof and that's what I think too, but that's not what I get... Maybe I miss something in my Rollup config 🤔 |
Finally I found a solution using only Babel without Rollup. But for those who do not use a bundler, to use our plugins they will have to add Util['default'].getUid('test') For me it's a breaking change, but with this solution no new dist files... Any feedbacks ? BTW we can suggest in our documentation a quick hack to avoid this : Alert = Alert['default']
Util = Util['default'] |
@Johann-S I don't know enough about it at the moment to make a call myself. Might need to ask you to explain more over Slack? |
Sure @mdo will talk about it on Slack 👌 |
6b1c63e
to
a311074
Compare
@Johann-S how does jquery work for you? i always get TypeError: $ is undefined (referenced in util.js:64:5)
my project is setup with a rollup config where i already tried a thousand things for making jquery work :( |
Pretty difficult to help you without seeing your Rollup config @donni106 |
thanks. ok, currently it is the following. but i tried with setting
|
Oh damn it seems to work with removing |
Finally I succeed to achieve that !
With that PR, folks will be able to choose which plugins they want to import and not all of our plugins.
Examples:
Importing Util
Importing Popover
This PR would help a lot in that case: symfony/webpack-encore#338
TODO
Fixes: #26757