function hoistTransitiveImports(graph) {
	for (const fileName in graph.bundle) {
		const chunk = graph.bundle[fileName];
		if (chunk.type !== 'chunk') continue;

		const deps = graph.findTransitiveImports(chunk);
		if (deps.css.size === 0 && deps.js.size === 0) continue;

		let appendCode = '';
		chunk.code = chunk.code.replace(/import\((['"`])(.*?)\1\)/gi, (s, quote, url) => {
			const spec = url.startsWith('./') ? posix.join(posix.dirname(fileName), url) : url;
			if (!deps.css.has(spec) && !deps.js.has(spec)) return s;

			const imp = `import(${quote}${url}${quote})`;
			const preloads = [];

			const css = deps.css.get(spec);
			if (css && css.length) {
				const meta = graph.getMeta(fileName);
				// inject the stylesheet loader: (and register it)
				if (!meta.styleLoadFn) {
					// if (DEBUG) console.log(`Injecting style loader into ${url}`);
					meta.styleLoadFn = DEFAULT_STYLE_LOAD_FN;
					appendCode += '\n' + DEFAULT_STYLE_LOAD_IMPL;
				}
				// eslint-disable-next-line no-console
				if (DEBUG) console.log(`Preloading CSS for import(${spec}): ${css}`);
				preloads.push(...css.map(f => `${meta.styleLoadFn}(${toImport(graph.publicPath, f)})`));
			}

			const js = deps.js.get(spec);
			if (js && js.length) {
				// eslint-disable-next-line no-console
				if (DEBUG) console.log(`Preloading JS for import(${spec}): ${js}`);
				preloads.push(
					...js.map(f => {
						if (/^(https?:)?\/\//.test(graph.publicPath)) {
							return `import(${toImport(graph.publicPath, f)})`;
						}
						let rel = posix.relative(posix.dirname('/' + fileName), posix.join(graph.publicPath, f));
						if (!rel.startsWith('.')) rel = './' + rel;
						return `import(${JSON.stringify(rel)})`;
					})
				);
			}

			if (!preloads.length) return s;

			// Option 1: preload CSS, but don't wait for it:
			return `(${preloads.join(',')},${imp})`;
			// Option 2: wait for CSS before resolving:
			// return `Promise.all([${imp},${preloads.join(',')}]).then(r=>r[0])`;
		});

		// inject style loader (once) if required:
		if (appendCode) chunk.code += appendCode;
	}
}
Visit every dynamic import(), and inject hoisted JS + CSS imports from it at the callsite.
Turns this:
  import('/foo.js')
Into this:
  (import('/util.js'),style('/foo.module.css'),import('/foo.js'))
@param {ChunkGraph} graph