docs icon indicating copy to clipboard operation
docs copied to clipboard

Javascript component aliases

Open jolelievre opened this issue 4 years ago • 5 comments

PrestaShop javascript components are now accessible via aliases We need to explain how a module can use these components and setup its module webpack environment to use them easily

jolelievre avatar Mar 04 '20 19:03 jolelievre

Javascripts components are accessible via aliases because of our webpack configuration. Without this configuration it's not possible to use them :sweat_smile: https://github.com/PrestaShop/PrestaShop/blob/develop/admin-dev/themes/new-theme/.webpack/common.js#L108

PierreRambaud avatar Mar 05 '20 11:03 PierreRambaud

@PierreRambaud If I understand correctly, it means modules cannot use components because they do not rely on our webpack config ? 🤔

matks avatar Jul 30 '20 10:07 matks

@matks yes, modules have their own webpack config scope, aliases are not usable outside the proper webpack config scope

We could maybe provide a webpack configuration at the root of the project, or root of modules, or an array of aliases that they can easily add to their own webpack configuration, but this is really ugly and as we seen on blockwishlist last week, having dependencies from the core is breaking a lot of things (because when you build the module for example, it require to have it inside a prestashop directory which is not the case for every modules developers depending on their environement)

NeOMakinG avatar Jul 31 '20 10:07 NeOMakinG

@matks yes, modules have their own webpack config scope, aliases are not usable outside the proper webpack config scope

We could maybe provide a webpack configuration at the root of the project, or root of modules, or an array of aliases that they can easily add to their own webpack configuration

That would be interesti,g

having dependencies from the core is breaking a lot of things (because when you build the module for example, it require to have it inside a prestashop directory

I'm afraid we wont be able to change this for now. "Module, in order to work, must be inside prestashop" is a requirement that have been here for ages so everything is done with this in mind (on both frontend and backend).

Although we should look for a long term solution for this design issue, I think for now we can "keep working with this" as fighting it makes things a lot more complex. Accepting this bad requirement make things a lot easier 😅

matks avatar Jul 31 '20 10:07 matks

I created a POC of how we can provide usefull things to external developers :

https://github.com/PrestaShop/PrestaShop/pull/20313

This solution is probably the best we can do for the moment, without introducing big changes !

NeOMakinG avatar Jul 31 '20 10:07 NeOMakinG