Skip to content
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

BUG: ast cannot be parsed cause replace export class is work when source is export function #245

Open
HoikanChan opened this issue Jan 29, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@HoikanChan
Copy link

// 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!
**/
@HoikanChan HoikanChan added the bug Something isn't working label Jan 29, 2024
@shuerguo999
Copy link
Contributor

class myFunction { return 1; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants