Skip to content

Double inclusion of referenced files #50

Open
@Valve

Description

@Valve

Assuming I have application.js with

//= require dependency1.js.ts
//= require file1.js.ts
//= require file2.js.ts

And file1.js.ts is:

/// <reference path="dependency1.js.ts" />
class File1 {}

And file2.js.ts is:

/// <reference path="dependency1.js.ts" />
class File2 {}

When I do asset compilation I end up with dependency1 being included 3 times into the resulting file.
First time it's from application.js inclusion, second and third is from file1.js.ts and file2.js.ts respectively.

As far as I can tell this happens because of: https://github.com/typescript-ruby/typescript-rails#referenced-typescript-dependencies

Questions:

  1. Is it possible to include a dependency once? I want asset-pipeline handle this (because we have a big project where everything is setup using asset pipeline).
  2. If not, how can I change the inclusion/walking process? Should I use tsconfig.json for this or something else?

Thanks for your help

Activity

bdrazhzhov

bdrazhzhov commented on Feb 9, 2017

@bdrazhzhov
Member

Hi @Valve,
It's known issue. But right now I have no time for this gem support. I accept PR from other people only which fix some issues or add new features.

markeissler

markeissler commented on May 4, 2017

@markeissler

I'm having a look at this right now. The problem is actually more deeply rooted than this gem...the problem is found in the typescript-node gem because it specifies --out as a compiler flag. When you specify --outa file will be generated that includes referenced dependencies. And that's how we end up with duplication.

Should I use tsconfig.json for this

Well, tsconfig.json is completely ignored by this gem at the moment but even if it wasn't ignored it still wouldn't fix the problem.

Valve

Valve commented on May 4, 2017

@Valve
Author

@markeissler I looked into it myself some time ago and found what you've found too :) The ts compiler lacks this option it seems, but I need to check it for v 2.3. Anyway, I dropped the idea to use TS in my Rails project because of the bad state of TS tooling in Rails. I hope to give it another shot with Rails 5.1 and webpack (because it supports it with webpacker gem).

markeissler

markeissler commented on May 4, 2017

@markeissler

@Valve TS 2.3 still lacks any option to do this. The closest you can get is specifying --noResolve but it outputs a non-suppressible warning at the end letting you know what you already know: that dependencies are missing since you asked to skip the inclusion of dependencies. Doh!

Another option would be to compile using --outDir and then select and cache files that have been already compiled but that's a silly waste of time on a bigger project. This is what happens with all of this highly opinionated software dev. :(

I'm considering just ditching the dependency on typescript-node (and, in turn, typescript-src) and just leaning on a call to tsc directly. Which would then allow for tsconfig.json support.

markeissler

markeissler commented on May 16, 2017

@markeissler

@Valve I just released a new gem (typescript-monkey) that behaves in a more rails-like fashion. My gem also supports inline typescript (using <script> tags).

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

      Double inclusion of referenced files · Issue #50 · typescript-ruby/typescript-rails