@@ -61,15 +61,20 @@ export interface ITypeScriptTaskConfig {
6161 libDir ?: string ;
6262
6363 /**
64- * If defined, drop typescript files from an AMD build here . Defaults to buildConfig.libAMDFolder
64+ * If defined, emit compiled typescript modules here using `module: 'amd'` . Defaults to buildConfig.libAMDFolder
6565 */
6666 libAMDDir ?: string ;
6767
6868 /**
69- * If defined, drop typescript files build using modules=ES6.
69+ * If defined, emit compiled typescript modules here using `module: 'es6'`. Defaults to buildConfig.libES6Folder
7070 */
7171 libES6Dir ?: string ;
7272
73+ /**
74+ * If defined, emit compiled typescript modules here using `module: 'esnext'`. Defaults to buildConfig.libESNextFolder
75+ */
76+ libESNextDir ?: string ;
77+
7378 /**
7479 * If defined, apply these settings on top of the standardized project TypeScript compiler configuration.
7580 */
@@ -83,6 +88,7 @@ export class TypeScriptTask extends GulpTask<ITypeScriptTaskConfig> {
8388 private _tsProject : ts . Project ;
8489 private _tsAMDProject : ts . Project ;
8590 private _tsES6Project : ts . Project ;
91+ private _tsESNextProject : ts . Project ;
8692
8793 constructor ( ) {
8894 super (
@@ -124,7 +130,8 @@ export class TypeScriptTask extends GulpTask<ITypeScriptTaskConfig> {
124130 emitSourceMaps : true ,
125131 libDir : undefined ,
126132 libAMDDir : undefined ,
127- libES6Dir : undefined
133+ libES6Dir : undefined ,
134+ libESNextDir : undefined
128135 }
129136 ) ;
130137 }
@@ -195,6 +202,18 @@ export class TypeScriptTask extends GulpTask<ITypeScriptTaskConfig> {
195202 this . _compileProject ( gulp , this . _tsES6Project , this . taskConfig . libES6Dir , allStreams , result ) ;
196203 }
197204
205+ // If esnext modules are required, also build that.
206+ if ( this . taskConfig . libESNextDir ) {
207+ allStreams . push (
208+ staticSrc . pipe ( gulp . dest ( this . taskConfig . libESNextDir ) ) ) ;
209+
210+ this . _tsESNextProject = (
211+ this . _tsESNextProject ||
212+ ts . createProject ( assign ( { } , compilerOptions , { module : 'esnext' } ) )
213+ ) ;
214+ this . _compileProject ( gulp , this . _tsESNextProject , this . taskConfig . libESNextDir , allStreams , result ) ;
215+ }
216+
198217 // Listen for pass/fail, and ensure that the task passes/fails appropriately.
199218 merge ( allStreams )
200219 . on ( 'queueDrain' , ( ) => {
@@ -223,6 +242,10 @@ export class TypeScriptTask extends GulpTask<ITypeScriptTaskConfig> {
223242 cleanMatch . push ( this . taskConfig . libES6Dir ) ;
224243 }
225244
245+ if ( this . taskConfig . libESNextDir ) {
246+ cleanMatch . push ( this . taskConfig . libESNextDir ) ;
247+ }
248+
226249 return cleanMatch ;
227250 }
228251
@@ -243,6 +266,10 @@ export class TypeScriptTask extends GulpTask<ITypeScriptTaskConfig> {
243266 if ( ! this . taskConfig . libES6Dir ) {
244267 this . taskConfig . libES6Dir = buildConfig . libES6Folder ;
245268 }
269+
270+ if ( ! this . taskConfig . libESNextDir ) {
271+ this . taskConfig . libESNextDir = buildConfig . libESNextFolder ;
272+ }
246273 }
247274
248275 private _compileProject ( gulp : gulpType . Gulp , tsProject : ts . Project , destDir : string ,
0 commit comments