export default function (config) {
    const trimPrefix = (config && config.trimPrefix) || /^.*[/]/;
    return {
        name: 'preload-dynamic-imports',
        renderDynamicImport({ format, targetModuleId }) {
            if (format !== 'es' || !targetModuleId) {
                return null;
            }
            const module = targetModuleId.replace(trimPrefix, '/');
            return {
                left: `(FM.preloadModuleDependencies('${module}'),Promise.resolve(import(`,
                right: ')))',
            };
        },
    };
}

export default function (config) {
    const trimPrefix = (config && config.trimPrefix) || /^.*[/]/;
    return {
        name: 'preload-dynamic-imports',
        renderDynamicImport({ format, targetModuleId }) {
            if (format !== 'es' || !targetModuleId) {
                return null;
            }
            const module = targetModuleId.replace(trimPrefix, '/');
            return {
                left: `(FM.preloadModuleDependencies('${module}'),import(`,
                right: '))',
            };
        },
    };
}

Remove unneccessary promise from dynamic import
Remove unneccessary promise from dynamic import

Now we don't need to invoke in the run loop to flush the run loop queues, this
is no longer doing anything.
