Within our project's structure, there exists a directory housing multiple js
files. The possibility of adding or removing these files later on is present. Currently, we have a file named main.js
where each file is imported and a map is created (using the file name as the key and the defined class as the value).
For Example:
Validator1.js
class Validator1 {
constructor() {
this.payRegex = /^[0-9][0-9][0-9]\/[A-Z,0-9][A-Z,0-9]*$/;
}
validate(obj) {
//do something
}
}
export default Validator1;
In main.js
import Validator1 from 'validator1.js';
import NoopValidator from './noop.js';
var validatorMap = {};
validatorMap['validator1'] = new Validator1;
validatorMap['DEFAULT'] = new NoopValidator;
We utilize browserify to compile this file into a bundle.js
. With numerous files in the same folder, the goal is to generate this file during compile time using maven.
- Are there alternative methods besides creating a maven plugin for accomplishing this task?
- We are utilizing EMAScript6.