Detect A Package's Presence In Code? Bundle Visualizer Requires Eval()

I’m using bundle-visualizer and I’m noticing it needs to be able to run eval() which conflicts with following line of my browser-policy configuration:


So to get bundle-visualizer to work I have to comment out the above line. A simple solution is to just put a conditional around it but I can’t check for Meteor.isProduction because the --production flag must be passed for bundle-visualizer to work.

Is there some other way to check for a package’s presence in code? Especially bundle-visualizer? I’m having trouble locating it’s source code online. It’s not in the Meteor Github project.

[Disclaimer: I have no idea if this is the recommended way to do this.]

Have you tried checking the Package global? It seems like it contains an entry for each package, so presumably the existence of Package['bundle-visualizer'] would be an indication that it is indeed present.

Easy demo: Go to, open the JS console in your browser, and inspect the Package global to see all the fun stuff there.

You could also set a Node environment variable before running the bundle visualizer, I guess, and check for that instead of trying to check for a specific package.