Using Browserify, this works:
var b = require('path/file.js')
But this one not:
var a = 'file'
var b = require('path/' + a + '.js')
Any ideas why?
Using Browserify, this works:
var b = require('path/file.js')
But this one not:
var a = 'file'
var b = require('path/' + a + '.js')
Any ideas why?
Because Browserify parses the source code and not execute it to figure out dependencies. The second case would required the execution of code to find the dependency path. In this case it is a simple variable which is constant but it could be any other value which is computed based on some query from some API etc.