Relative paths using requirejs in combination with Typescript and AMD -
there several javascript files, organized in folders scripts/folder1, scripts/folder2, ...
with requirejs.config.baseurl folder defined default, example scripts/folder1. in requirejs.config.paths files addressed filename, , addressed relative path (like ../folder2/blabla).
when coding typescipt file folder2/blabla.ts need module "math" folder1. write
import mod1 = module("../folder1/math");
regarding typescript, fine that. can find module. however, requirejs there problem. not know module "../folder1/math", knows "math".
the problem seems import statement expects filename, being adressed starting current directory. however, isn't module id requirejs knows about.
using absolute paths anywhere, both in requirejs configuration , import statement in typescript, solves problem.
am doing wrong? or absolute paths way go?
specify baseurl
equivalent root folder of typescript files:
require.config({ baseurl: './scripts', } )
then when use relative paths starting scripts folder can import in typescript , requirejs using same base path.
update: presentation should should answer url / using js typescript questions: http://www.youtube.com/watch?v=4agqpv0mksa code : https://github.com/basarat/typescript-amd/blob/master/readme.md
Comments
Post a Comment