question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make astexplorer standalone / embeddable

See original GitHub issue

People reached out to be and showed interest in an embeddable version of astexplorer. This thread should explore how this would look like and what needs to be done.

I think there are two ways to achieve this and ideally we can support both:

  1. Make astexplorer configurable via the URL so it can be embedded via an <iframe>.
  2. Create a (more) reusable React component that can be used wherever React can be rendered.
  3. ?

1. <iframe>

This should be fairly straightforward. The URL could contain UI options, such as the chosen parser, chosen transform, which visualization to show, whether switching parsers is allowed or not, etc. Basically just ways to configure how astexplorer looks like and optimize it a bit for smaller space (e.g. instead of side-by-side panes we could have tabs).

2. Dedicated React component

This probably requires bigger refactoring but could also be the most flexible solution since it could be used outside of browser environments (e.g. Electron apps). The component would be close to the main component in app.js but provide more configuration options. There some open questions:

  • Should the toolbar be part of such a component?
  • If yes, how would lazy loading the parsers work if we don’t have any control over the build step?

Maybe the easier solution is to let the calling code pass the available parsers to the component. They would have to comply with our interface, but that shouldn’t be too bad.

It would also be great if the calling code could add custom visualization / output panes (e.g. the transpiled code like in https://babeljs.io/repl/).

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:7
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
fklingcommented, Apr 6, 2016

Current idea/plan: Create a script that can be loaded and which exposes an API that lets you render astexplorer into a given element. Something like:

<link href="path/to/astexplorer.css" />
<script src="path/to/astexplorer_embed.js"></script>
<script>
  astexplorer.render({
    parser: 'acorn',
    parserSettings: {
      // ...
    },
    code: '...',
   // transform: ...
   // etc.
  }, someElement);
</script>

That would make it easy to configure examples. For that I still have to do

  • Namespace CSS rules
  • Create embeddable entry script
  • Create API
  • Make parser settings settable from the outside (not only inside each parser).
0reactions
LunaticMuchcommented, Sep 26, 2022

This issue is quite old. Any progress done?

Read more comments on GitHub >

github_iconTop Results From Across the Web

AST explorer
An online AST explorer.
Read more >
Felix Kling (@fkling42) / Twitter
I've been experimenting with Svelte for astexplorer and I enjoy it a lot! The other nice side effect of switching UI frameworks is...
Read more >
Walkthrough of a Sample JavaScript/TypeScript Audit Rule
When writing a JavaScript rule, it is helpful to be able to look at the syntax tree for the particular case being audited....
Read more >
Transforming Markdown with Remark & Rehype - ryanfiller.com
To make my workflow less coupled to a specific technology, ... I found that copy / pasting HTML into this AST Explorer tool...
Read more >
Ideas
Write either in JavaScript (or TypeScript) and maybe desktop version using embedded browser. Or write in Dart / Flutter and make web version ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found