@@ -5,11 +5,10 @@ import {
5
5
DIST_COMPONENTS_ROOT , PROJECT_ROOT , COMPONENTS_DIR , HTML_MINIFIER_OPTIONS
6
6
} from '../constants' ;
7
7
import { sassBuildTask , tsBuildTask , execNodeTask , copyTask , sequenceTask } from '../task_helpers' ;
8
- import { writeFileSync } from 'fs' ;
9
8
10
9
// No typings for these.
11
10
const inlineResources = require ( '../../../scripts/release/inline-resources' ) ;
12
- const rollup = require ( 'rollup' ) . rollup ;
11
+ const gulpRollup = require ( 'gulp-better- rollup' ) ;
13
12
const gulpMinifyCss = require ( 'gulp-clean-css' ) ;
14
13
const gulpMinifyHtml = require ( 'gulp-htmlmin' ) ;
15
14
const gulpIf = require ( 'gulp-if' ) ;
@@ -85,30 +84,23 @@ task(':build:components:rollup', () => {
85
84
'rxjs/Observable' : 'Rx'
86
85
} ;
87
86
88
- // Rollup the @angular /material UMD bundle from all ES5 + imports JavaScript files built.
89
- return rollup ( {
90
- entry : path . join ( DIST_COMPONENTS_ROOT , 'index.js' ) ,
87
+ const rollupOptions = {
91
88
context : 'this' ,
92
89
external : Object . keys ( globals )
93
- } ) . then ( ( bundle : { generate : any } ) => {
94
- const result = bundle . generate ( {
95
- moduleName : 'ng.material' ,
96
- format : 'umd' ,
97
- globals,
98
- sourceMap : true ,
99
- dest : path . join ( DIST_COMPONENTS_ROOT , 'material.umd.js' )
100
- } ) ;
101
-
102
- // Add source map URL to the code.
103
- result . code += '\n\n//# sourceMappingURL=./material.umd.js.map\n' ;
104
- // Format mapping to show properly in the browser. Rollup by default will put the path
105
- // as relative to the file, and since that path is in src/lib and the file is in
106
- // dist/@angular /material, we need to kill a few `../`.
107
- result . map . sources = result . map . sources . map ( ( s : string ) => s . replace ( / ^ ( \. \. \/ ) + / , '' ) ) ;
108
-
109
- writeFileSync ( path . join ( DIST_COMPONENTS_ROOT , 'material.umd.js' ) , result . code , 'utf8' ) ;
110
- writeFileSync ( path . join ( DIST_COMPONENTS_ROOT , 'material.umd.js.map' ) , result . map , 'utf8' ) ;
111
- } ) ;
90
+ } ;
91
+
92
+ const rollupGenerateOptions = {
93
+ // Keep the moduleId empty because we don't want to force developers to a specific moduleId.
94
+ moduleId : '' ,
95
+ moduleName : 'ng.material' ,
96
+ format : 'umd' ,
97
+ globals,
98
+ dest : 'material.umd.js'
99
+ } ;
100
+
101
+ return src ( path . join ( DIST_COMPONENTS_ROOT , 'index.js' ) )
102
+ . pipe ( gulpRollup ( rollupOptions , rollupGenerateOptions ) )
103
+ . pipe ( dest ( path . join ( DIST_COMPONENTS_ROOT , 'bundles' ) ) ) ;
112
104
} ) ;
113
105
114
106
/** Builds components with resources (html, css) inlined into the built JS (ESM output). */
0 commit comments