Currently custom imports require a name. This name must then be places into two places: as an option to moduleToFunction and as an argument to the function constructor.
const importName = '__import__'
const ast = parse(source, { ecmaVersion: 'latest', sourceType: 'module' })
// 1. Utility option
moduleToFunction(ast, { importName })
const transformed = generate(ast)
// 2. Function constructor
const fn = new AsyncFunction(importName, transformed)
It might be nice if the custom import can be taken from the arguments object, so the user doesn’t have to specify the importName argument for the function constructor.
- const importName = '__import__'
const ast = parse(source, { ecmaVersion: 'latest', sourceType: 'module' })
// 1. Utility option
- moduleToFunction(ast, { importName })
+ moduleToFunction(ast, { importName: 0 })
const transformed = generate(ast)
// 2. Function constructor
- const fn = new AsyncFunction(importName, transformed)
+ const fn = new AsyncFunction(transformed)
Currently custom imports require a name. This name must then be places into two places: as an option to
moduleToFunctionand as an argument to the function constructor.It might be nice if the custom import can be taken from the
argumentsobject, so the user doesn’t have to specify theimportNameargument for the function constructor.