@@ -35,6 +35,7 @@ export class PackageBundler {
35
35
return this . bundleEntryPoint ( {
36
36
entryFile : this . buildPackage . entryFilePath ,
37
37
esm5EntryFile : join ( this . buildPackage . esm5OutputDir , 'index.js' ) ,
38
+ importName : `@angular/${ this . buildPackage . name } ` ,
38
39
moduleName : `ng.${ this . buildPackage . name } ` ,
39
40
esm2015Dest : join ( bundlesDir , `${ packageName } .js` ) ,
40
41
esm5Dest : join ( bundlesDir , `${ packageName } .es5.js` ) ,
@@ -48,11 +49,13 @@ export class PackageBundler {
48
49
const packageName = this . buildPackage . name ;
49
50
const entryFile = join ( this . buildPackage . outputDir , entryPoint , 'index.js' ) ;
50
51
const esm5EntryFile = join ( this . buildPackage . esm5OutputDir , entryPoint , 'index.js' ) ;
52
+ const dashedEntryName = dashCaseToCamelCase ( entryPoint ) ;
51
53
52
54
return this . bundleEntryPoint ( {
53
55
entryFile,
54
56
esm5EntryFile,
55
- moduleName : `ng.${ packageName } .${ dashCaseToCamelCase ( entryPoint ) } ` ,
57
+ importName : `@angular/${ this . buildPackage . name } /${ dashedEntryName } ` ,
58
+ moduleName : `ng.${ packageName } .${ dashedEntryName } ` ,
56
59
esm2015Dest : join ( bundlesDir , `${ packageName } ` , `${ entryPoint } .js` ) ,
57
60
esm5Dest : join ( bundlesDir , `${ packageName } ` , `${ entryPoint } .es5.js` ) ,
58
61
umdDest : join ( bundlesDir , `${ packageName } -${ entryPoint } .umd.js` ) ,
@@ -68,6 +71,7 @@ export class PackageBundler {
68
71
private async bundleEntryPoint ( config : BundlesConfig ) {
69
72
// Build FESM-2015 bundle file.
70
73
await this . createRollupBundle ( {
74
+ importName : config . importName ,
71
75
moduleName : config . moduleName ,
72
76
entry : config . entryFile ,
73
77
dest : config . esm2015Dest ,
@@ -76,6 +80,7 @@ export class PackageBundler {
76
80
77
81
// Build FESM-5 bundle file.
78
82
await this . createRollupBundle ( {
83
+ importName : config . importName ,
79
84
moduleName : config . moduleName ,
80
85
entry : config . esm5EntryFile ,
81
86
dest : config . esm5Dest ,
@@ -84,6 +89,7 @@ export class PackageBundler {
84
89
85
90
// Create UMD bundle of ES5 output.
86
91
await this . createRollupBundle ( {
92
+ importName : config . importName ,
87
93
moduleName : config . moduleName ,
88
94
entry : config . esm5Dest ,
89
95
dest : config . umdDest ,
@@ -105,7 +111,7 @@ export class PackageBundler {
105
111
const bundleOptions = {
106
112
context : 'this' ,
107
113
external : Object . keys ( rollupGlobals ) ,
108
- entry : config . entry ,
114
+ input : config . entry ,
109
115
onwarn : ( message : string ) => {
110
116
// TODO(jelbourn): figure out *why* rollup warns about certain symbols not being found
111
117
// when those symbols don't appear to be in the input file in the first place.
@@ -121,14 +127,13 @@ export class PackageBundler {
121
127
} ;
122
128
123
129
const writeOptions = {
124
- // Keep the moduleId empty because we don't want to force developers to a specific moduleId.
125
- moduleId : '' ,
126
- moduleName : config . moduleName || 'ng.material' ,
130
+ name : config . moduleName || 'ng.material' ,
131
+ amd : { id : config . importName } ,
127
132
banner : buildConfig . licenseBanner ,
128
133
format : config . format ,
129
- dest : config . dest ,
134
+ file : config . dest ,
130
135
globals : rollupGlobals ,
131
- sourceMap : true
136
+ sourcemap : true
132
137
} ;
133
138
134
139
// For UMD bundles, we need to adjust the `external` bundle option in order to include
@@ -183,6 +188,7 @@ export class PackageBundler {
183
188
interface BundlesConfig {
184
189
entryFile : string ;
185
190
esm5EntryFile : string ;
191
+ importName : string ;
186
192
moduleName : string ;
187
193
esm2015Dest : string ;
188
194
esm5Dest : string ;
@@ -196,4 +202,5 @@ interface RollupBundleConfig {
196
202
dest : string ;
197
203
format : string ;
198
204
moduleName : string ;
205
+ importName : string ;
199
206
}
0 commit comments