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

Deno.emit ast manipulation #9851

Closed
timreichen opened this issue Mar 21, 2021 · 4 comments
Closed

Deno.emit ast manipulation #9851

timreichen opened this issue Mar 21, 2021 · 4 comments
Labels
public API related to "Deno" namespace in JS suggestion suggestions for new features (yet to be agreed)

Comments

@timreichen
Copy link
Contributor

Ref: #3354
I would like to be able to manipulate the ast when using Deno.emit. Something similar to typescript compiler API transfomers. I think this functionality would render the use of the ts module obsolete in most cases in favour of native and faster Deno.emit.

Maybe something like this:

const { files } = await Deno.emit("/mod.ts", {
  sources: {
    "/mod.ts": `import * as a from "./a.ts";\nconsole.log(a);\n`,
    "/a.ts": `export const a: Record<string, string> = {};\n`,
  },
  transformers: [
    (node) => {
      const visitor = (node) => {
        if (node.type === "ImportDeclaration") {
          // do something
        }
        return node
      };
      return visitor(node)
    }
  ]
});

What do you think?

@timreichen timreichen changed the title Deno.emit transfomers Deno.emit ast manipulation Mar 21, 2021
@kitsonk kitsonk added suggestion suggestions for new features (yet to be agreed) public API related to "Deno" namespace in JS labels Mar 21, 2021
@kitsonk
Copy link
Contributor

kitsonk commented Mar 21, 2021

Personal opinion is that it is overly complex to even considering implementing anytime in the foreseeable future.

@shadowtime2000
Copy link

I feel like an AST API would be cool and nice and stuff, but I don't think it is necessary to implement a visitor API or other API for modifying ASTs.

@MKRhere
Copy link
Contributor

MKRhere commented Jun 4, 2021

Would be a cool addition, even later down the roadmap.

@timreichen
Copy link
Contributor Author

timreichen commented May 22, 2022

Closing this issue because Deno.emit is a separate mod now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
public API related to "Deno" namespace in JS suggestion suggestions for new features (yet to be agreed)
Projects
None yet
Development

No branches or pull requests

4 participants