Please, don't use dynamic require imports
Instead of such syntax:
const partOfLibName = 'part1';
const myLib = require(partOfLibName + 'LibName');
Please, use such one:
cosnt myLib1 = require('part1LibName');
cosnt myLib2 = require('part2LibName');
// and later
let res;
if (/* some condition here */) {
res = myLib1.method();
} else {
res = myLib2.method();
}
Or with dynamic imports:
cosnt myLib1 = import('part1LibName');
cosnt myLib2 = import('part2LibName');
// and later
let res;
if (/* some condition here */) {
myLib1.then(res => {
// user res here
});
} else {
myLib2.then(res => {
// user res here
});
}
Also you can use the new JavaScript 2020 native dynamic import with await, something like this:
let module = await import('/modules/my-module.js');
This can be written inside an if statement.
Hey @Razzwan, I'm assuming you're referring to these two usages: https://github.com/dOrgTech/DAOcreator/blob/09db2fdb239c69f8c12ad58fd0a84c3789335484/packages/lib/src/dependency/arc/src/migrate-dao.js#L703 and https://github.com/dOrgTech/DAOcreator/blob/09db2fdb239c69f8c12ad58fd0a84c3789335484/packages/lib/src/dependency/arc/src/utils.js#L21-L28
Both of these source files come from this repo: https://github.com/daostack/migration
They're copied into the DAOcreator here: https://github.com/dOrgTech/DAOcreator/blob/master/packages/lib/scripts/prepArc.js
The reason this manual copying is done is to:
- reducing ABI bloat
- removing needless dependencies that cause build problems
If you'd like this code changed, I'd suggest making an issue here: https://github.com/daostack/migration
ok. will try to update migration https://github.com/daostack/migration/issues/373