onGenerateModule (modules, filePath, config) {
        let { esmTransformedCode: code, map, imports, exports, externalImports, dynamicImports, syntheticNamedExports, hoist } = modules[filePath];

        // Validate dependencies exist.
        imports.forEach(dep => {
            if (!modules[dep.source]) {
                throw new Error('File not found: ' + dep.source);
            }
        });

        let hoisted = '';
        if (hoist) {
            let ast = AcornParser.parse(code);
            let s = new MagicString(code);

            for (let i = 0; i < ast.body.length; i++) {
                let node = ast.body[i];

                if (!node) {
                    continue;
                }

                if (node.type === 'FunctionDeclaration') {
                    hoisted += code.substring(node.start, node.end) + ';\n';
                    let export_match = exports.find(e => e.local === node.id.name)
                    if (export_match) {
                        hoisted += `__e__('${export_match.exported}', function () { return ${export_match.local} });`;
                    }

                    s.overwrite(node.start, node.end, blanker(code, node.start, node.end));
                } else if (node.type === 'ClassDeclaration') {
                    hoisted += 'var ' + node.id.name + ';\n';
                    s.prependLeft(node.start, node.id.name + ' = ');
                } else if (node.type === 'VariableDeclaration') {
                    hoisted += 'var ' + node.declarations.flatMap(d => getVariableNames(d.id)).join(', ') + ';\n';
                    if (node.kind === 'var' || node.kind === 'let') {
                        s.overwrite(node.start, node.start + 3, ' ;(');
                    } 

                    if (node.kind === 'const') {
                        s.overwrite(node.start, node.start + 5, '   ;(');
                    }

                    if (code[node.end - 1] === ';') {
                        s.appendRight(node.end - 1, ')');
                    } else {
                        s.appendRight(node.end, ');');
                    }

                }
            }
            
            code = s.toString();
        }

        code = escapeCode(code);

        // Transform the source path so that they display well in the browser debugger.
        let sourcePath = path.relative(process.cwd(), filePath).replace(/\\/g, '/');

        // Append source mapping information
        code += '\\\n';

        if (map) {
            map.sourceRoot = 'nollup:///';
            map.sources[map.sources.length - 1] = sourcePath;
            code += `\\n${ConvertSourceMap.fromObject(map).toComment()}\\n`;
        } 
        
        code += `\\n//# sourceURL=nollup-int:///${sourcePath}`;

        let context = (
            config.moduleContext? (
                typeof config.moduleContext === 'function'? 
                    config.moduleContext(filePath) : 
                    config.moduleContext[filePath]
            ) : undefined
        ) || config.context;

        return `
            function (__c__, __r__, __d__, __e__, require, module, __m__, __nollup__global__) {
                ${this.context.liveBindings? 'var __i__ = {};' : ''}
                ${this.context.liveBindings === 'with-scope'? 'with (__i__) {' : ''}
                
                ${imports.map((i, index) => {
                    let namespace = `_i${index}`;
                    return `var ${namespace}; ${this.context.liveBindings? '' : (!i.export? i.specifiers.map(s => 'var ' + s.local).join(';') : '')};`
                }).join('; ')}

                ${externalImports.map(i => {
                    let namespace = `__nollup__external__${i.source.replace(/[\W]/g, '_')}__`

                    return i.specifiers.map(s => {
                        let output = '';

                        if (i.export) {
                            if (s.imported === '*') {
                                return getExportAllFrom(namespace);
                            }
                            
                            return `__e__("${s.local}", function () { return ${namespace}${s.imported}__ });`;
                        }

                        if (s.imported === '*')
                            output += `var ${s.local} = ${namespace};`;
                        else
                            output += `var ${s.local} = ${namespace}${s.imported}__;`;

                        return output;
                    }).join(';');
                }).join('; ')}

                ${hoisted? hoisted : ''};

                __d__(function () {
                    ${imports.map((i, index) => {
                        let namespace = `_i${index}()`; 

                        return i.specifiers.map(s => {
                            let output = '';

                            if (!i.export) {
                                let value = `${namespace}${s.imported === '*'? '' : `.${s.imported}`}`;
                                if (this.context.liveBindings) {
                                    output = `!__i__.hasOwnProperty("${s.local}") && Object.defineProperty(__i__, "${s.local}", { get: function () { return ${value}}});`;
                                } else {
                                    output = `${s.local} = ${value};`;
                                }
                            }
                            
                            if (i.export) {
                                if (s.imported === '*') {
                                    output += getExportAllFrom(namespace);
                                } else {
                                    output += `__e__("${s.local}", function () { return ${namespace}.${s.imported} });`;
                                }
                            }

                            let import_exported = exports.find(e => e.local === s.local);
                            if (!i.export && import_exported) {
                                let local = this.context.liveBindings? `__i__["${import_exported.local}"]` : import_exported.local;
                                output += `__e__("${import_exported.exported}", function () { return ${local} });`;
                            }

                            return output;
                        }).join(';');
                    }).join('; ')}
                }, function () {
                    "use strict";
                    eval('${code}');
                    ${syntheticNamedExports? getSyntheticExports(syntheticNamedExports) : ''} 
                }.bind(${context}));

                ${this.context.liveBindings === 'with-scope'? '}' : ''}
                ${imports.map((i, index) => {
                    let id = `_i${index}`;
                    return `${id} = __c__(${modules[i.source].index}) && function () { return __r__(${modules[i.source].index}) }`;
                }).join('; ')}
            }   
        `.trim();
    }
@param {Object<string, NollupInternalModule>} modules 
@param {string} filePath
@param {RollupConfigContainer} config
@return {string}