swc-plugin-purescript-esm
v0.0.7
Published
### Usage
Downloads
2
Readme
swc-plugin-purescript-esm
Usage
npm i -D @swc/core swc-plugin-purescript-esm
import { plugin } from "swc-plugin-purescript-esm";
import { transformSync } from "@swc/core";
// For a directory example with spago see /example
const pursOutput = `
// Generated by purs version 0.14.5
"use strict";
var Effect_Console = require("../Effect.Console/index.js");
var main = Effect_Console.log("\ud83c\udf5d");
module.exports = {
main: main
};
`
const { code } = transformSync(pursOutput, { plugin: plugin() });
console.log(code);
/**
import ___Effect_Console_index_js_b8b84996 from "../Effect.Console/index.js";
;
var Effect_Console = ___Effect_Console_index_js_b8b84996;
var main = Effect_Console.log("🍝");
export { main };
**/
This module is experimental, proceed with caution!
Long story short is Purescript compiler doesn't currently support ESM output and would be nice if it did for tree-shaking etc.
This plugin for SWC can take an output directory created by Spago for instance and transpile it from the spago output module format (commonjs with module.exports) into ESM.
This tool is very specifically focused on some anecdotal compiler output from Purescript and definitely will not handle edge cases.
This project includes a source file from this repo and is subject to copyright from them!