magesuite / magepack

Next generation Magento 2 advanced JavaScript bundler.
Open Software License 3.0
434 stars 91 forks source link

Add an option to ignore specific scripts #66

Open indykoning opened 3 years ago

indykoning commented 3 years ago

We use the Select2 library on some of our sites, however the implementation of RequireJS is not the best in this library causing the folowing error in the console when bundled https://requirejs.org/docs/errors.html#mismatch

One of the solutions is to accept the small performance impact and load this library seperately. The current way i'll implement to fix this is (automatically) remove this line from the magepack.config.js before bundling or after generating. But this could be error-prone if executed manually.

I propose reading ignored requirements from either a flag or a configuration file during generating or compiling.

I think a configuration file might be the better of the options since it might also allow users to set the cms, category and product url prior to generating so they only need to run magepack generate

Leland commented 3 years ago

+1

There's a private process to exclude modules, which you can see here:

https://github.com/magesuite/magepack/blob/53431ef77d47d1de36dc88775d9ff8b83dd26388/lib/generate/collectModules.js#L82-L110

And the list lives here: https://github.com/magesuite/magepack/blob/53431ef77d47d1de36dc88775d9ff8b83dd26388/lib/generate/excludedModules.js

The easiest way to handle this might be to either allow overriding or adding to that internal list.