-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide API method to transform a source code string #20
Comments
It's very useful! 👏👏👏👏 |
Maybe you can use it like this import { transpileModule, ModuleKind } from 'typescript'
import { cjsToEsm } from 'cjstoesm'
const input = `
const {foo: bar} = require("./my-module")
module.exports = {baz: 3}
`
const result = transpileModule(input, {
transformers: cjsToEsm(),
compilerOptions: {
module: ModuleKind.ES2020,
},
})
// console.log(result.outputText) |
I have the same needs |
1 similar comment
I have the same needs |
We can use https://github.com/streamich/memfs as a filesystem to read from memory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The currently provided
transform
method takes a path to a file (or an array of paths) and optionally writes the transformed file(s) to the file system.It would be nice to provide another method which takes a source code string and returns a transformed source code string. For example:
(The method name could be different.)
The text was updated successfully, but these errors were encountered: