tree-sitter / tree-sitter-typescript

TypeScript grammar for tree-sitter
MIT License
361 stars 108 forks source link

Don't generate node and rust bindings in subfolders tsx/ and typescript/ #181

Closed mjambon closed 3 years ago

mjambon commented 3 years ago

Without this, the following extra files get generated when we run npm run build:

    tsx/Cargo.toml
    tsx/binding.gyp
    tsx/bindings/
    typescript/Cargo.toml
    typescript/binding.gyp
    typescript/bindings/

Files with such names already exist under the project's root e.g. https://github.com/tree-sitter/tree-sitter-typescript/blob/master/Cargo.toml.

I don't know what these files are for so I don't know if this PR does the right thing :-). Maybe the right behavior is instead to keep those under tsx/ and typescript/ and delete the ones under the project root?

Checklist:

mjambon commented 3 years ago

The issues of these new generated files was raised in https://github.com/tree-sitter/tree-sitter-typescript/pull/135 and https://github.com/tree-sitter/tree-sitter-typescript/pull/163

resolritter commented 3 years ago

FWIW when I tried to use --no-bindings locally on https://github.com/tree-sitter/tree-sitter-typescript/pull/135, I got the following:

> ../node_modules/.bin/tree-sitter generate --no-bindings
error: Found argument '--no-bindings' which wasn't expected, or isn't valid in this context

USAGE:
    tree-sitter generate [FLAGS] [OPTIONS] [grammar-path]

For more information try --help

> ../node_modules/.bin/tree-sitter --version
tree-sitter 0.19.2 (d037c4914d7845385dbf330f1a653777f81b7240)
mjambon commented 3 years ago

@resolritter ah, that's good to know.

Here's the relevant section from tree-sitter's git log:

commit 24785cdb39ad2740ca33c111490984333787f5d3
Author: Max Brunsfeld <maxbrunsfeld@gmail.com>
Date:   Mon Mar 8 16:36:59 2021 -0800

    0.19.3

commit 9e50befcf8e1b6855337b7a877aa3099947f5678
Author: Max Brunsfeld <maxbrunsfeld@gmail.com>
Date:   Mon Mar 8 12:02:01 2021 -0800

    For node-types.json, process supertypes in a stable order

commit 8e894ff3f1898fcaa09ae125bbd5fde8467aea42
Author: Max Brunsfeld <maxbrunsfeld@gmail.com>
Date:   Mon Mar 8 12:01:45 2021 -0800

    Add --no-bindings flag to generate subcommand

So we need to set a constraint on tree-sitter >= 0.19.3.

mjambon commented 3 years ago

I added a version constraint and also added the unwanted files to .gitignore as a precaution. Thanks @dcreager and @resolritter for your help.