Code Monkey home page Code Monkey logo

astexplorer's People

Contributors

aceslick911 avatar aladdin-add avatar btmills avatar christianmurphy avatar danez avatar fkling avatar gabelevi avatar gabro avatar gengjiawen avatar hzoo avatar irustm avatar iwanabethatguy avatar jeffmo avatar jlhwung avatar josephfrazier avatar lahmatiy avatar metonym avatar motiz88 avatar mroch avatar nmalaguti avatar nzakas avatar rreverser avatar rundevelopment avatar rwjblue avatar skratchdot avatar smelukov avatar timothygu avatar turbo87 avatar vtrushin avatar wooorm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

astexplorer's Issues

Add Babel 6

Because Babel 6 uses a slightly different AST and plugin definition, I think it makes sense to add it as separate option (parser and transformer) instead of just upgrading Babel.

Feature request: settings for transformer

Transformer doesn't work for some ES7 features like decorators. But parser works fine, as has option for it.

Simple example:

@decorator
class A {}

This cose cause to error in transformer:

image

Let tools specify parser settings

Currently tools can only specify which parser to use (so it is selected by default) but not parser settings, which is required as well sometimes.

Feature request: Show a diff between parsers

Not sure how we would show this or if we could make it look good but it would be useful (for me at least) to compare the AST tree between different parsers (in particular babel/esprima for babel-eslint). 😄

Switch to CloudFlare?

@fkling Would you be interested in putting astexplorer.net behind CloudFlare? Free plan should work perfectly, and will give HTTPS, HTTP/2 + SPDY and CDN out of the box which should speed up loading our bundles for users.

Change placement of parser information

The toolbar is now so wide that parser information is not always shown properly on narrow screens. This is from a 13" screen:

screen shot 2015-12-08 at 10 33 05 am

Any suggestions for how/where to put this? Or should we simply break on white space?

Issue with removing the transform panes when switching

When you switch between languages, should the transform change automatically (ex: after switching from js/babel to html, the babel transform pane is still there). In the case of switching to html the pane stays on the screen even though the transform toggle is disabled.

Feature Request: Indication if transform is stable or not

Would be nice to run the transform script twice, once on the original source, and then again on the transformed source. Then show a warning if the source changes on the second transform. If it does change that means it's probably not safe to run the script multiple times over the same codebase.

Add inline documentation for ast-type constructors

I've been thinking about how to best document jscodeshift and i think that having auto-complete/typeahead inside of astexplorer.net would be huge.

My biggest annoyance when writing codemods is that I want to create a node of type Something
but i don't know what arguments it takes.

Being able to do t.something(<list of arguments from ast-types>) would be great or, maybe at the bottom of the screen, when you select t.something, it shows the type definition.

Minification error

Webpack (therefore UglifyJS) has problems minifying some files:

ERROR in app-6fe76ad4fb1070d5cdee.js from UglifyJs
Unexpected token punc «,», expected arrow «=>» [./~/codemirror/mode/javascript/javascript.js:363,0]

ERROR in 1-595b1745447d2e8d1d87.js from UglifyJs
Unexpected token punc «;», expected arrow «=>» [./~/codemirror/addon/tern/tern.js:324,0]

ERROR in 15-97b6ed0349ff4e6be2c6.js from UglifyJs
Unexpected token punc «;», expected arrow «=>» [./~/recast/lib/printer.js:196,0]

ERROR in 16-9ab0ec6c3bb5ef480ff7.js from UglifyJs
Unexpected token punc «)», expected arrow «=>» [./~/shift-parser/dist/pattern-acceptor.js:146,0]

ERROR in 18-4a8de760966ccf94578c.js from UglifyJs
Unexpected token punc «;», expected arrow «=>» [./~/babel-generator/lib/printer.js:79,0]

ERROR in 19-80325d20605b9cfcf9bf.js from UglifyJs
Unexpected token punc «;», expected arrow «=>» [./~/recast/lib/printer.js:196,0]

ERROR in 20-dc214efd0de9edbdb9bd.js from UglifyJs
Unexpected token punc «;», expected arrow «=>» [./~/typescript/lib/typescript.js:30938,0]

ERROR in 22-2661016f44c06a5eb7c6.js from UglifyJs
Unexpected token punc «)», expected arrow «=>» [./~/webidl2/lib/webidl2.js:234,0]

ERROR in 23-5b2dcb9b24f8a5691072.js from UglifyJs
Unexpected token punc «;», expected arrow «=>» [./~/escodegen/escodegen.js:907,0]

ERROR in 26-6d6700619899083ed12c.js from UglifyJs
Unexpected token punc «;», expected arrow «=>» [./~/esprima/esprima.js:2925,0]

Make astexplorer standalone / embeddable

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/).

not working?

none of the buttons in the nav seems to be working...

Idea: Run recast transformations

Let the visitor write recast code to transform the AST. Maybe even animate the changes somehow? (e.g. step by step walk through).

URL for special language

Maybe we should have some shortcut to enable features. Like if you go to http://astexplorer.net/#postcss it will enable CSS and PostCSS.

Persist parser and parser settings in URL

To make sharing code snippets easier, it would be convenient to store the selected parser and parser settings in the URL.

However, I don't really like to update the current URI with that information, since it will look ugly and mess with the browser history. Instead, we could add a "share" button that shows a copyable version of the URL, just like jsfiddle does.

I'm already working on this.

Can't run locally for modifications

Tried to build & run locally, but got:

TypeError: $def is not a function in browser console in following context:

loadjs.d("323",function(require,module,exports){
// 19.1.3.1 Object.assign(target, source)
var $def = require('./$.def');

$def($def.S + $def.F, 'Object', {assign: require('./$.assign')});
},{"./$.assign":210,"./$.def":219});

loadjs.d("949",function(require,module,exports){

Chrome DevTools fails to set breakpoints

when i try to set a breakpoint in Devtools, it's either not set of jumps to a bad place in the source map. Is this something you're seeing as well?

gif

P.S. Other than that, I really like the breakdown of the app. Really clean

can't run locally

I ran npm install and either npm run watch or npm run build and in another tab terminal I run npm start yet this is the contents of index.html:

<!DOCTYPE html>
<html>
  <head>
    <title>AST explorer</title>
    <meta charset="UTF-8">
    <meta name="description" content="An online AST explorer.">
    <script>
      window.webpackManifest = {%# o.manifest %}
    </script>
  </head>
  <body>
    <div id="page">
      <div id="container"></div>
      <div id="contribution">
        Built using
        <a href="http://facebook.github.io/react/">React</a>,
        <a href="http://babeljs.io/">Babel</a>,
        <a href="http://fortawesome.github.io/Font-Awesome/">Font Awesome</a>,
        <a href="https://parse.com">Parse.com</a>,
        <a href="http://codemirror.net/">CodeMirror</a>
        and
        <a href="https://webpack.github.io/">WebPack</a>
        |
        <a href="https://github.com/fkling/esprima_ast_explorer">GitHub</a>
      </div>
    </div>
  </body>
</html>

it looks like it's not modifying window.webpackManifest = {%# o.manifest %}

I'm on mac os with node v5.1.0 and npm 3.3.12
I'm also getting the same issue on node v4 too

Shows errors for valid jscodeshift transform

Hi,

Thanks for this amazing tool.

This transform is passing tests on my machine locally. But I get this error Cannot read property 'node' of undefined in astexplorer. This is my original repo and the transform is initializer-arity.

Sometime missing a semicolon at the end of statement seems to trigger similar kind of errors. Here is reproducable example And the semicolon is missing for the statement root.find(j.FunctionDeclaration, ...).....

Time to rename repo?

Since it's not just Esprima anymore, maybe it's worth to rename the repo to make it less confusing? Github takes care of redirects after renamings, so it should be harmless.

Add support for shareable URLs

We could either encode the source code in the URL if it's short enough, or use something like Parse.com to store documents (or both!).

Add more tools

There are many more tools besides jscodeshift which could be added to the ast explorer for quick prototyping / testing. For example:

  • eslint plugin development
  • babel plugin development

To make adding new tools easy, some refactoring of the client side code and the DB schema is necessary. I already have a proof of concept commit locally but it still needs more tweaking.

The current idea/plan is that "tools" are React components which are rendered below the code editor and ast panel (just like the transform tool now) and which have access to

  • The current parser
  • The current code
  • An API to highlight parts and show errors in the code editor

Tools would also be able to specify which parsers they work together with. They could render whatever interface they need.

Suggestions

This project is a nice playground for all those parsers. Thank you for making this!

I believe that for most people who stumble upon it, we are trying to find the best AST parser for our specific tasks.

And as far as the decision-making goes, your project is missing some key information that would simplify things for a researcher.

I understand you want your project to stay neutral about all the existing AST projects, but at least some basic statistics would have been really helpful:

  • Performance charts
  • Memory consumption charts
  • Level of support for ES5, ES6, ES7
  • Tree-Navigation features, performance

Not only this would be a great help to those who is trying to make the best pick among AST parsers, but also for the developers of AST projects to be able to see where their project has weaknesses.

Can't recover from infinite loops

For example, just write while(true); in the transform script and the whole browser will freeze when the code is run.

(practically I ran into this by introducing some accidental infinite recursion)

Instead of solving the halting problem, it would be cool if we just put a timeout on the transform and killed it after 30 seconds or so.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.