Picture of AIi W
Issue with Dependencies within a custom extension
by AIi W - Sunday, 10 February 2019, 6:58 AM

I am writing an extension that depends on a js library (call it module X, for illustration purposes), there is an npm packages available for it.

Currently this is what i am doing:

1- In my plugin root folder, I edited the bower.json file and added modules X,  (the extension depends on X which in-turn depends on Y) 

2- Created a .bowerrc file in my plugin root folder with directory specified as "./js"

3- Manually ran bower install in plugin root, both X and Y get installed in the js folder under X and Y subfolders

4- In my plugin main.js file i have
define(["./Y/Y.js", "./X/X.js", "core/js/adapt"),
function(Y,X,Adapt) {/*plugincode*/})

5- grunt dev runs successfully and builds

Issue: When i run the code, I get browser console error "ReferenceError: Y is not defined  (X.js: line n)" (plugin depends on X which depends on Y)