TypeStrong / grunt-ts

A grunt task to manage your complete typescript development to production workflow
https://www.npmjs.com/package/grunt-ts
MIT License
330 stars 122 forks source link

amdloader path should be relative to reference file and not outDir #41

Open jeffmay opened 10 years ago

jeffmay commented 10 years ago

If you have a project like so:

public/
  app/
    main.ts
    reference.ts
  test/
    reference.ts

then when you attempt to compile them both into the same directory with an AMD loader...

target/
  js/
    app/
      main.ts
      reference.js
      amdloader.js
    test/
      reference.js

the outDir is "target/js" so the paths in amdloader are all set to "./../main.js" instead of "./main.js".

We should think about how we want to handle multiple reference files in a project. Maybe a separate ticket for this?

In this case, it would be simple enough to allow the user to specify the root path of the AMD loader (configuration is always a good option since people -- like myself -- always have exotic needs).

Alongside this though, I think we could more wisely default to using the path to reference file's directory appended with references (and then normalize the paths?)

@basarat what do you think?

basarat commented 10 years ago

amdloader path should be relative to reference file and not outDir

Agreed.

it would be simple enough to allow the user to specify the root path of the AMD loader

If you want to. I have name suggestion though, call it baseUrl since that is what requirejs uses.