Skip to content

Commit b4aff04

Browse files
committed
Merge pull request #212 from Softpagehomeware/master
added support for compiling without module option
2 parents 317ca90 + 131dbf6 commit b4aff04

File tree

12 files changed

+98
-5
lines changed

12 files changed

+98
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ bin/
2626
obj/
2727
*.user
2828
*.suo
29+
.project
30+
.settings/

Gruntfile.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,22 @@ module.exports = function (grunt) {
464464
options: {
465465
fast: 'never'
466466
}
467+
},
468+
withemptymodule: {
469+
test: true,
470+
options: {
471+
module: ''
472+
},
473+
src: 'test/withemptymodule/ts/Main.ts',
474+
out: 'test/withemptymodule/js/Main.js'
475+
},
476+
withwrongmodule: {
477+
fail: true,
478+
options: {
479+
module: 'nothing'
480+
},
481+
src: 'test/withwrongmodule/ts/*.ts',
482+
outDir: 'test/withwrongmodule/js'
467483
}
468484
}
469485
});

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ For file ordering, look at [JavaScript Generation](#javascript-generation).
8484
|[htmlModuleTemplate](#htmlmoduletemplate)|option|`string` - HTML template namespace|
8585
|[htmlVarTemplate](#htmlvartemplate)|option|`string` - HTML property name|
8686
|[mapRoot](#maproot)|option|`string` - root for referencing `.js.map` files in JS|
87-
|[module](#module)|option|`'amd'` (default) or `'commonjs'` - specifies external module style|
87+
|[module](#module)|option|default to be nothing, If you want to set it you set it to either `'amd'` or `'commonjs'`|
8888
|[noImplicitAny](#noimplicitany)|option|`true`, `false` (default) - enable for stricter type checking|
8989
|[noResolve](#noresolve)|option|`true`, `false` (default) - for deprecated version of TypeScript|
9090
|[options](#grunt-ts-target-options)|target||

tasks/modules/compile.js

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tasks/modules/compile.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,16 @@ export function compileAllFiles(targetFiles: string[], target: ITargetOptions, t
184184

185185
// string options
186186
args.push('--target', task.target.toUpperCase());
187-
args.push('--module', task.module.toLowerCase());
187+
188+
// check the module compile option
189+
if (task.module) {
190+
var moduleOptionString: string = task.module.toLowerCase();
191+
if (moduleOptionString === 'amd' || moduleOptionString === 'commonjs') {
192+
args.push('--module', moduleOptionString);
193+
} else {
194+
console.warn('WARNING: Option "module" does only support "amd" | "commonjs"'.magenta);
195+
}
196+
}
188197

189198
// Target options:
190199
if (target.out) {

tasks/ts.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tasks/ts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function pluginFn(grunt: IGrunt) {
9999
compile: true,
100100
declaration: false,
101101
mapRoot: '',
102-
module: 'amd', // amd, commonjs
102+
module: null, // amd, commonjs
103103
noImplicitAny: false,
104104
noResolve: false,
105105
comments: null, // false to remove comments

test/withemptymodule/ts/Bar.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Bar {
2+
public value:string;
3+
4+
constructor() {
5+
this.value = 'bar';
6+
}
7+
8+
public getValue() {
9+
return this.value;
10+
}
11+
}

test/withemptymodule/ts/Foo.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path="Bar.ts" />
2+
3+
class Foo extends Bar {
4+
5+
constructor() {
6+
super();
7+
this.value = 'foo ' + this.value;
8+
}
9+
10+
}

test/withemptymodule/ts/Main.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path="Foo.ts" />
2+
3+
class Main {
4+
constructor() {
5+
6+
}
7+
}
8+
9+
new Main();

0 commit comments

Comments
 (0)