Skip to content

tsify is slow #227

Closed
Closed

Description

@JohnLouderback

I'm wondering if I haven't made a glaring mistake, but tsify is taking around a minute and half to build our codebase's JS whereas with just Flow and Babel it would take around 7 seconds. I've also noticed that if I get any Typescript errors, I'll usually get around 6 repeated of the same error for the same line and column. Are there any caveats I should be aware of, or is tsify just slow?

capturfiles-aug-25-2017_09 28 51

Activity

  1. cartant commented on Aug 26, 2017

    @cartant
    Contributor

    In certain situations, tsify can be rather slow. This has a lot to do with the limited communication that's possible between Browserify and its plugins and transforms.

    tsify works by compiling the TypeScript program, holding the results of the compilation in memory, and returning the compiled content to Browserify via a transform. If transform sees a file that was not part of the compilation, the cache miss will effect a re-compilation. And that can be slow.

    tsify contains diagnostic logging that can be enabled using NODE_DEBUG (see https://github.com/TypeStrong/tsify/blob/master/CONTRIBUTING.md#debugging) and that will clearly show which files are causing cache misses, if they are occurring.

    However, I'm not sure that's your problem. It's not clear to me what build system you are using, but looping through the results of that glob doesn't look right. Unless you are creating multiple bundles, I don't see why you need to repeatedly call browserify, etc. for each .ts and .js file.

    Usually, you specify only the entry point file and Browserify will slurp up the dependent files using require - or import, for .ts files.

  2. HerringtonDarkholme commented on Sep 5, 2017

    @HerringtonDarkholme

    Hi @cartant . I would suggest add a transpileOnly flag to tsify. Like https://github.com/TypeStrong/ts-loader#transpileonly-boolean-defaultfalse

  3. JohnLouderback commented on Sep 5, 2017

    @JohnLouderback
    Author

    @cartant I'm using Gulp. Our build process is configured to bundle multiple top level JS/TS files. Setting NODE_DEBUG=tsify appears to make no discernable difference. I don't see any further output.

  4. cartant commented on Sep 5, 2017

    @cartant
    Contributor

    Without knowing more about your setup, there's not much that can be said. Why are you globbing and bundling every file that matches the glob? That's looks very strange.

  5. cartant commented on Sep 5, 2017

    @cartant
    Contributor

    For the record, it's possible to use multiple top-level files, but you would normally add them and bundle once. You are bundling with each added, top-level file.

  6. cartant commented on Sep 5, 2017

    @cartant
    Contributor

    @HerringtonDarkholme Thanks. I'll bear that in mind. However, I don't have a great deal of time to allocate to this project, at the moment; I'll add it to the backlog.

  7. JohnLouderback commented on Sep 14, 2017

    @JohnLouderback
    Author

    @cartant The glob is because there top-level files are independent bundles. If there's any specific information about our build process you'd like to know, I'd be happy to share with you. Unfortunately, if I can't resolve the 7 second to 1.5 minute build time increase, TypeScript won't be an option for us. Any help would be extremely appreciated. Are minute and a half build times common for tsify?

  8. cartant commented on Sep 14, 2017

    @cartant
    Contributor

    The baseline to use to determine whether or not tsify is slow is tsc - the TypeScript command line compiler. For a one-off build, tsify is not going to be faster than that. If it is significantly slower, it's possible that there could an issue to address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions