Skip to content

Commit d6bc532

Browse files
committed
Fix typings for bundled definitions
1 parent 1194cf0 commit d6bc532

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

tools/gulp/tasks/release.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import {spawn} from 'child_process';
2-
import {existsSync, statSync, copySync} from 'fs-extra';
2+
import {existsSync, statSync, copySync, writeFileSync} from 'fs-extra';
33
import {join} from 'path';
44
import {task, src, dest} from 'gulp';
55
import {execTask, sequenceTask} from '../util/task_helpers';
6-
import {DIST_RELEASE, DIST_BUNDLES, DIST_MATERIAL, COMPONENTS_DIR} from '../constants';
6+
import {
7+
DIST_RELEASE, DIST_BUNDLES, DIST_MATERIAL, COMPONENTS_DIR, LICENSE_BANNER
8+
} from '../constants';
79
import * as minimist from 'minimist';
810

911
/** Parse command-line arguments for release task. */
1012
const argv = minimist(process.argv.slice(3));
1113

12-
// Capture all d.ts files output by typescript compilation except for the
13-
// special files generated by ngc.
14-
const typingsGlob = [
15-
join(DIST_MATERIAL, '**', '*.d.ts'),
16-
`!${join(DIST_MATERIAL, 'index.d.ts')}`,
17-
`!${join(DIST_MATERIAL, 'public_api.d.ts')}`,
18-
];
14+
// Capture all d.ts files output by typescript compilation.
15+
const typingsGlob = join(DIST_MATERIAL, '**', '*.d.ts');
1916

2017
const assetsGlob = join(COMPONENTS_DIR, '+(package.json|README.md)');
2118

@@ -43,29 +40,38 @@ task(':package:release', [
4340
/** Copy metatadata.json and associated d.ts files to the root of the package structure. */
4441
task(':package:metadata', () => {
4542
// See: https://github.com/angular/angular/blob/master/build.sh#L293-L294
46-
copySync(join(DIST_MATERIAL, 'public_api.d.ts'), join(DIST_RELEASE, 'public_api.d.ts'));
47-
copySync(join(DIST_MATERIAL, 'index.d.ts'), join(DIST_RELEASE, 'material.d.ts'));
4843
copySync(join(DIST_MATERIAL, 'index.metadata.json'),
4944
join(DIST_RELEASE, 'material.metadata.json'));
5045
});
5146

5247
task(':package:assets', () => src(assetsGlob).pipe(dest(DIST_RELEASE)));
5348

5449
/** Copy all d.ts except the special flat typings from ngc to typings/ in the release package. */
55-
task(':package:typings', () => src(typingsGlob).pipe(dest(join(DIST_RELEASE, 'typings'))));
50+
task(':package:typings', () => {
51+
return src(typingsGlob)
52+
.pipe(dest(join(DIST_RELEASE, 'typings')))
53+
.on('end', () => createTypingFile());
54+
});
5655

5756
/** Copy umd bundles to the root of the release package. */
5857
task(':package:umd', () => src(umdGlob).pipe((dest(join(DIST_RELEASE, 'bundles')))));
5958

60-
/** Copy fesm bundles to @angular/material in the release package */
61-
task(':package:fesm', () => src(fesmGlob).pipe(dest(join(DIST_RELEASE, '@angular', 'material'))));
59+
/** Copy primary entry-point FESM bundles to the @angular/ directory. */
60+
task(':package:fesm', () => src(fesmGlob).pipe(dest(join(DIST_RELEASE, '@angular'))));
6261

6362
/** Make sure we're logged in. */
6463
task(':publish:whoami', execTask('npm', ['whoami'], {
6564
silent: true,
6665
errMessage: 'You must be logged in to publish.'
6766
}));
6867

68+
/** Create a typing file that links to the bundled definitions of NGC. */
69+
function createTypingFile() {
70+
writeFileSync(join(DIST_RELEASE, 'material.d.ts'),
71+
LICENSE_BANNER + '\nexport * from "./typings/index";'
72+
);
73+
}
74+
6975
task(':publish:logout', execTask('npm', ['logout']));
7076

7177

0 commit comments

Comments
 (0)