Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double inclusion of referenced files #50

Open
Valve opened this issue Feb 7, 2017 · 5 comments
Open

Double inclusion of referenced files #50

Valve opened this issue Feb 7, 2017 · 5 comments

Comments

@Valve
Copy link

Valve commented Feb 7, 2017

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

@bdrazhzhov
Copy link
Member

bdrazhzhov commented Feb 9, 2017

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
Copy link

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
Copy link
Author

Valve commented May 4, 2017

@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
Copy link

@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
Copy link

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants