your description:
I write a transformer to transform
export class A() { name: 'hhh'} =>class A() { name: 'hhh'}; __export__(FILENAME, 'A', A);
there is a error when parsing export function,
errr msg isast cannot be parsed cause replace export class is work when source is export function
// source code
export function myFunction() {
return 1;
}
// transform script
function transform(fileInfo, api, options) {
const $ = api.gogocode
const source = fileInfo.source
// return your transformed code here
return $(source)
.replace(`
export class $_$1 { $_$2 }`,
`
class $_$1 { $_$2 }
__export__('xxx', '${name}', ${name});
`
).root().generate()
}
Got error:
/**
Something goes wrong...
Error: replace failed:
class myFunction { return 1; }
__export__('xxx', '', );
cannot be parsed!
**/
export class A() { name: 'hhh'}
=>class A() { name: 'hhh'}; __export__(FILENAME, 'A', A);
there is a error when parsing export function, errr msg isast cannot be parsed cause replaceexport class
is work when source is export functionGot error: