Skip to content

Commit 1ba2698

Browse files
committed
Set moduleResolution to node by default, unit-test that resolution,
default compiler options should be converted to TS format bug fix This is part of the effort to create the official TypeScript compiler: Urigo/angular2-meteor#89 Urigo/angular2-meteor#90 Urigo/angular2-meteor#102
1 parent e81585d commit 1ba2698

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,20 @@ function setCacheDir(cacheDir) {
1818

1919
exports.setCacheDir = setCacheDir;
2020

21+
function getConvertedDefault() {
22+
return convertCompilerOptionsOrThrow(
23+
getDefaultCompilerOptions());
24+
}
25+
2126
var compileCache;
2227
exports.compile = function compile(source, options) {
2328
validateAndConvertOptions(options);
2429

2530
if (! options)
26-
options = {compilerOptions: getDefaultCompilerOptions()};
31+
options = {compilerOptions: getConvertedDefault()};
2732

2833
if (! options.compilerOptions)
29-
options.compilerOptions = getDefaultCompilerOptions();
34+
options.compilerOptions = getConvertedDefault();
3035

3136
if (options.compilerOptions.useCache) {
3237
return tsCompile(source, options);

options.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ exports.presetCompilerOptions = presetCompilerOptions;
4545
// Default compiler options.
4646
function getDefaultCompilerOptions() {
4747
return {
48-
module : "commonjs",
4948
target: "ES3",
49+
module : "commonjs",
50+
moduleResolution: "node",
5051
sourceMap: true,
5152
noResolve: false,
5253
diagnostics: true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "meteor-typescript",
33
"author": "@barbatus",
4-
"version": "0.5.7",
4+
"version": "0.5.8",
55
"license": "MIT",
66
"description": "TypeScript wrapper package for use with Meteor",
77
"keywords": [

tests/ts.spec.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe("meteor-typescript -> ", function() {
77

88
it("should compile with defaults", function() {
99
var result = meteorTS.compile(testCodeLine);
10-
expect(result.code.indexOf("exports.foo")).toEqual(0);
10+
expect(result.code).toContain("exports.foo");
1111
});
1212

1313
it("should throw on wrong option", function() {
@@ -93,4 +93,14 @@ describe("meteor-typescript -> ", function() {
9393
});
9494
});
9595

96+
describe("testing module resolution -> ", function() {
97+
var testCodeLine = "import {FakeApi} from 'lib/fake'";
98+
99+
it("should resolve NodeJS-way by default", function() {
100+
var result = meteorTS.compile(testCodeLine);
101+
102+
expect(result.diagnostics.semanticErrors.length).toEqual(0);
103+
});
104+
});
105+
96106
});

typescript.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ exports.compile = function compile(fileContent, options) {
4343
normalizePath(filePath)) return;
4444

4545
if (ts.fileExtensionIs(fileName, '.map')) {
46-
var sourceMapPath = options.moduleName ?
47-
options.moduleName : filePath;
4846
sourceMap = prepareSourceMap(outputCode,
49-
fileContent, sourceMapPath);
47+
fileContent, filePath);
5048
} else {
5149
code = outputCode;
5250
}

0 commit comments

Comments
 (0)