These are chat archives for systemjs/systemjs

18th
Dec 2015
Dimitri Rosenberg
@rosendi
Dec 18 2015 16:05
Is it possible to rewrite typescript relative imports? For example the typescript file located in dist/test/e2e with import { Core } from '../../lib/core' and a real path for transpiled lib is 'dist/lib/core'.
Ryan Wischkaemper
@ryanwischkaemper
Dec 18 2015 16:30
@rosendi You can achieve that through using packages in your systemjs config.
Dimitri Rosenberg
@rosendi
Dec 18 2015 16:40
@ryanwischkaemper thank you.
Dimitri Rosenberg
@rosendi
Dec 18 2015 17:20
@ryanwischkaemper Does it work with paths like from '../lib'? If I change '../lib' in the config.js and src/main.ts' to ./lib then it works. http://plnkr.co/edit/gUyMPu6WwBIKOVaf4u3e?p=preview
Ryan Wischkaemper
@ryanwischkaemper
Dec 18 2015 18:25
Dimitri Rosenberg
@rosendi
Dec 18 2015 18:39
@ryanwischkaemper you misunderstood me
Ryan Wischkaemper
@ryanwischkaemper
Dec 18 2015 18:41
@rosendi Sorry. I've been using it to get rid of long relative paths. For example, changing import {App} from '../../../src/app' in one of my .spec.ts files to just import {App} from 'src/app'
Dimitri Rosenberg
@rosendi
Dec 18 2015 18:41
@ryanwischkaemper it's just a plunk. it's showing what I'm trying to achieve. In real project I have to use ../../
Ryan Wischkaemper
@ryanwischkaemper
Dec 18 2015 18:51
@rosendi I get that :p So, to clarify, what is your desired import path from your typescript file located in dist/test/e2e? Using the example you provided in your initial question
Dimitri Rosenberg
@rosendi
Dec 18 2015 19:07
@ryanwischkaemper Well, original typescript files are inlib/ (lib/core.ts for example). Spec files are in test/e2e/.... Transpiled files go to dist (dist/package/lib/, dist/test). I use node module resolution. Then importing lib file in the spec file /test/e2e/todo/todo.ts would be import { X } from '../../../lib/core', since ts files are located in lib. But transpiled lib files located under thedist/package/lib. So what I'm trying to achieve is to transform '../../../lib/core' to 'dist/lib/package/core' .
Ryan Wischkaemper
@ryanwischkaemper
Dec 18 2015 19:56
@rosendi I'm not sure if that can be done. Trying to import something starting with a relative path will always be treated as just that. You could set up an alias package in config.js, that pointed to your transpiled folder and use that alias in your specs to import your transpiled files. But it sounds like that isn't satisfactory for your situation. Sorry I couldn't help
Dimitri Rosenberg
@rosendi
Dec 18 2015 20:03
@ryanwischkaemper thank you. I've changed the folder structure. Now the ts and js relative paths are same. Looking forward to Microsoft/TypeScript#5039
Ryan Wischkaemper
@ryanwischkaemper
Dec 18 2015 20:04
yea that'll be nice