Skip to content

Commit

Permalink
Set moduleResolution to node by default, unit-test that resolution,
Browse files Browse the repository at this point in the history
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
  • Loading branch information
barbatus committed Feb 18, 2016
1 parent e81585d commit 1ba2698
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@ function setCacheDir(cacheDir) {

exports.setCacheDir = setCacheDir;

function getConvertedDefault() {
return convertCompilerOptionsOrThrow(
getDefaultCompilerOptions());
}

var compileCache;
exports.compile = function compile(source, options) {
validateAndConvertOptions(options);

if (! options)
options = {compilerOptions: getDefaultCompilerOptions()};
options = {compilerOptions: getConvertedDefault()};

if (! options.compilerOptions)
options.compilerOptions = getDefaultCompilerOptions();
options.compilerOptions = getConvertedDefault();

if (options.compilerOptions.useCache) {
return tsCompile(source, options);
Expand Down
3 changes: 2 additions & 1 deletion options.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ exports.presetCompilerOptions = presetCompilerOptions;
// Default compiler options.
function getDefaultCompilerOptions() {
return {
module : "commonjs",
target: "ES3",
module : "commonjs",
moduleResolution: "node",
sourceMap: true,
noResolve: false,
diagnostics: true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "meteor-typescript",
"author": "@barbatus",
"version": "0.5.7",
"version": "0.5.8",
"license": "MIT",
"description": "TypeScript wrapper package for use with Meteor",
"keywords": [
Expand Down
12 changes: 11 additions & 1 deletion tests/ts.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("meteor-typescript -> ", function() {

it("should compile with defaults", function() {
var result = meteorTS.compile(testCodeLine);
expect(result.code.indexOf("exports.foo")).toEqual(0);
expect(result.code).toContain("exports.foo");
});

it("should throw on wrong option", function() {
Expand Down Expand Up @@ -93,4 +93,14 @@ describe("meteor-typescript -> ", function() {
});
});

describe("testing module resolution -> ", function() {
var testCodeLine = "import {FakeApi} from 'lib/fake'";

it("should resolve NodeJS-way by default", function() {
var result = meteorTS.compile(testCodeLine);

expect(result.diagnostics.semanticErrors.length).toEqual(0);
});
});

});
4 changes: 1 addition & 3 deletions typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ exports.compile = function compile(fileContent, options) {
normalizePath(filePath)) return;

if (ts.fileExtensionIs(fileName, '.map')) {
var sourceMapPath = options.moduleName ?
options.moduleName : filePath;
sourceMap = prepareSourceMap(outputCode,
fileContent, sourceMapPath);
fileContent, filePath);
} else {
code = outputCode;
}
Expand Down

0 comments on commit 1ba2698

Please sign in to comment.