function transform(
	code,
	{ presets, plugins, parse, filename, ast, generatorOpts, sourceMaps, sourceFileName } = {}
) {
	parse = parse || DEFAULTS.parse;
	generatorOpts = generatorOpts || {};
	const out = new MagicString(code);
	const ctx = createContext({ code, out, parse, generatorOpts, filename });
	const { types, template, visit } = ctx;

	const allPlugins = [];
	resolvePreset({ presets, plugins }, allPlugins);

	/** @type {Record<string, ReturnType<typeof createMetaVisitor>>} */
	const visitors = {};

	for (let i = 0; i < allPlugins.length; i++) {
		const [id, options] = allPlugins[i];
		const stateId = Symbol();
		const plugin = typeof id === 'string' ? require(id) : id;
		const inst = plugin({ types, template }, options);
		for (let i in inst.visitor) {
			// Merged visitors are separated via a pipe symbol:
			// `'ArrowFunctionExpression|FunctionExpression'`
			if (/|/.test(i)) {
				const parts = i.split('|');
				for (let j = 0; j < parts.length; j++) {
					let visitor = visitors[parts[j]] || (visitors[parts[j]] = createMetaVisitor({ filename }));
					visitor.visitors.push({
						stateId,
						visitor: inst.visitor[i],
						opts: options
					});
				}
			} else {
				// Normal visitors can be called directly
				let visitor = visitors[i] || (visitors[i] = createMetaVisitor({ filename }));
				visitor.visitors.push({
					stateId,
					visitor: inst.visitor[i],
					opts: options
				});
			}
		}
	}

	// let start = Date.now();
	let parsed;
	try {
		parsed = ctx.parse(code);
	} catch (err) {
		throw Object.assign(Error(), buildError(err, code, filename));
	}

	// start = Date.now();
	visit(parsed, visitors, new Map());

	let map;
	function getSourceMap() {
		if (!map) {
			map = out.generateMap({
				includeContent: true,
				// Must be set for most source map verifiers to work
				source: sourceFileName || filename,
				file: posix.basename(sourceFileName || filename || '')
			});
		}
		return map;
	}

	if (sourceMaps === 'inline' || sourceMaps === 'both') {
		code += '\n//# sourceMappingURL=' + getSourceMap().toUrl();
	}

	return {
		code: out.toString(),
		get ast() {
			return ast === true ? parsed : undefined;
		},
		get map() {
			return sourceMaps !== 'inline' && sourceMaps !== false ? getSourceMap() : undefined;
		}
	};
}
Implements Babel's `transform()` API on top of Acorn, including transforms, plugins and presets.
@param {string} code
@param {object} [options]
@param {any[]} [options.presets]
@param {any[]} [options.plugins]
@param {typeof DEFAULTS.parse} [options.parse]
@param {string} [options.filename]
@param {boolean} [options.ast = false]
@param {{ compact?: boolean }} [options.generatorOpts]
@param {typeof DEFAULTS.sourceMaps} [options.sourceMaps]
@param {string} [options.sourceFileName]