I have a external file, (gridster and jquery), that I installed with npm and added the typings. Jquery seems to load no problem but not gridster. I tried adding the gridster script manually in the index.html but there seems to be a sequence issue as with gridster you need jquery loaded first. If I add Jquery to the index.html ionic seems to replace jquery by its load process later and gridster is lost.
not sure if this is the best way but I got js files going into the app.bundle.js file by playing with the src property of the browserify command in the gulpfile. I still have a issue with jquery loading in the right order but a bit closer.
@grendo I’m a bit late to reply so I guess that you already read this:
I’m not absolutely sure about this, but I guess that it handled by the transpiler. I’ll suggest you to take a look at the tasks browserify-typescript and browserify-es2015. You could pass options to the transpiler.
But when you can configure your gulpfile.js as you wish, why don’t you just create a task that combines the files in the required order and produces a single file, which you can just include in your index.html?
Problem seems to be jquery gets picked up by browserify but gridster does not, might be because gridster does not have a main tag in its package.json. If I load both files in index.html somehow jquery ends up in the bundle. Was so much easier in ionic 1. Trying out browerfiy-shim, but it can’t be this hard to just add an external js file can it ?
It could be harder than it should be, when using the wrong tool for the job. Basically you want to ensure that a few scripts are always included and executed in a specific order - why bother wrestling with the transpiler and a complex multistep process instead of just combining the scripts in the desired order and saving them to a single file. As a starting point I would suggest you the following (disclaimer: untested, but you should get the idea):
I worked around this by installing all my external js files using bower so they did not get caught up in the whole browserify/npm/browserify shim bundling, (just keep getting issues trying to stop browserify to ignore some files that were installed with npm like jquery), then added a gulp task to package up the js as you suggested. Works well for me, (although with time I might have been able to get going using browserify shim and npm). Thanks for your help.