Skip to content

Any plan to support --incremental flag? #249

Open

Description

@dharijanto

Hello,
First off, thanks for this wonderful open source project. I've been regularly using this with browserify :)

Since typescript 3.4 introduced --incremental (see: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html), is there a plan to support the flag on tsify library? Seems it'd be nice not having to recompile everything when the build script is restarted (i.e. computer restart) :)

Activity

  1. cartant commented on Apr 6, 2019

    @cartant
    Contributor

    incremental is a compiler option, so if you specify a project file - i.e. a tsconfig.json file - when you run tsify, you can configure the option in the project file's compilerOptions. tsify will use the options specified in said file.

  2. ericmorand commented on May 6, 2019

    @ericmorand

    Can you show an example of usage? It doesn't seem to work when setup this way:

    plugin: [
                ['tsify', {
                    project: {
                        compilerOptions: {
                            incremental: true
                        }
                    }
                }]
            ]
    

    tsBuildInfoFile is not created and the build is not faster than without the incremental flag.

  3. cartant commented on May 6, 2019

    @cartant
    Contributor

    I guess it doesn't work because tsify passes its own compiler host to TypeScript - to abstract the file system - as the compiled files need to be made available to Browserify via streams.

    I don't have time to look into this, ATM, but if it's something you'd be interested in looking into, I can give you some pointers regarding where to start in this codebase.

  4. ericmorand commented on May 7, 2019

    @ericmorand

    With great pleasure. I've been digging into source code yesterday and will continue today. I'll let you know if I need help with it.

  5. cartant commented on May 7, 2019

    @cartant
    Contributor

    Cool, I'll write up some pointers tonight - in about 6 hours or so.

    The main thing will be to switch debugging on and checkout the logs - to see if TypeScript is using the compiler host's API to write the intermediate data.

  6. cartant commented on May 7, 2019

    @cartant
    Contributor

    @ericmorand I'd forgotten that I'd written an outline of the codebase. You should start with that. It's here.

    Once you've familiarised yourself with that, this is what I'd do:

    • Create a simple example that works with the incremental flag when using the command line.
    • Get the example working with tsify.
    • Enable debug logging.
    • Look to see if TS attempts to write incremental information to the file system in this call.
    • If it does, look at adding some special case handling of file names to ensure the data is written to the file system.
  7. ericmorand commented on May 10, 2019

    @ericmorand

    I finally had the chance to perform a simple test.

    I have a simple TS project that consists of two files:

    • index.ts
    class Foo {
    
    }
    
    
    • tsconfig.json
    {
      "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "sourceMap": true,
        "incremental": true,
        "tsBuildInfoFile": ".foo"
      },
      "exclude": [
        "../node_modules"
      ]
    }
    

    When I run tsc, I successfully obtain a .foo file which means incremental is working.
    When I run npx browserify index.ts -p tsify, I don't get a .foo file which means incrmental is not working.
    When I run npx browserify index.ts -p [tsify {incremental: true, tsBuildInfoFile: ".foo"}], I don't get it either.

    I continue my investigations.

  8. ericmorand commented on May 10, 2019

    @ericmorand

    I also confirm that Host.prototype.writeFile never attemps to write the build info file .foo.

  9. ericmorand commented on May 17, 2019

    @ericmorand

    I think the issue is related to:

    microsoft/TypeScript#29978

    ts-loader guys seems to be stuck at the same point than tsify:

    TypeStrong/ts-loader#913

    What di you think?

  10. cartant commented on May 17, 2019

    @cartant
    Contributor

    Yep. Probably worth having a look at - or keeping an eye on - TypeStrong/ts-loader#935 too.

  11. jleider commented on Jul 2, 2019

    @jleider

    Looks like there has been some progress made regarding an api: microsoft/TypeScript#31432

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions