Created
August 24, 2022 18:49
-
-
Save danny-andrews/375f5d393f0de02b164fd3ae3b0e248d to your computer and use it in GitHub Desktop.
Revisions
-
danny-andrews created this gist
Aug 24, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ import esbuild from "esbuild"; import { readFile } from "node:fs/promises"; import { fileURLToPath } from "node:url"; export async function load(url, context, nextLoad) { const source = await readFile(fileURLToPath(url), "utf-8"); if (/\.jsx$/.test(url)) { const transformedSource = await esbuild.transform(source, { loader: "jsx", }); return { format: "module", source: transformedSource.code, }; } return nextLoad(url, context); }