fix(publish): emit type declarations with CJS build

Closes #4706
Closes #4708
This commit is contained in:
Jeff Cross 2015-10-13 14:35:31 -07:00
parent e82a35d1fd
commit 57649d1839
2 changed files with 23 additions and 3 deletions

View File

@ -831,7 +831,7 @@ gulp.task('test.typings', ['!pre.test.typings'], function() {
var tmpdir = path.join(os.tmpdir(), 'test.typings', new Date().getTime().toString());
gulp.task('!pre.test.typings.layoutNodeModule', function() {
return gulp
.src(['dist/js/dev/es5/angular2/**/*'], {base: 'dist/js/dev/es5'})
.src(['dist/js/cjs/angular2/**/*'], {base: 'dist/js/cjs'})
.pipe(gulp.dest(path.join(tmpdir, 'node_modules')));
});
gulp.task('!pre.test.typings.copyTypingsSpec', function() {

View File

@ -36,7 +36,8 @@ module.exports = function makeNodeTree(destinationPath) {
allowNonTsExtensions: false,
emitDecoratorMetadata: true,
experimentalDecorators: true,
declaration: false,
declaration: true,
stripInternal: true,
mapRoot: '', /* force sourcemaps to use relative path */
module: 'CommonJS',
moduleResolution: 1 /* classic */,
@ -77,7 +78,10 @@ module.exports = function makeNodeTree(destinationPath) {
packageJsons =
renderLodashTemplate(packageJsons, {context: {'packageJson': COMMON_PACKAGE_JSON}});
var nodeTree = mergeTrees([typescriptTree, docs, packageJsons]);
var typingsTree = new Funnel(
'modules',
{include: ['angular2/typings/**/*.d.ts', 'angular2/manual_typings/*.d.ts'], destDir: '/'});
var nodeTree = mergeTrees([typescriptTree, docs, packageJsons, typingsTree]);
// Transform all tests to make them runnable in node
nodeTree = replace(nodeTree, {
@ -101,5 +105,21 @@ module.exports = function makeNodeTree(destinationPath) {
patterns: [{match: /^/, replacement: function() { return `'use strict';` }}]
});
// Add a line to the end of our top-level .d.ts file.
// This HACK for transitive typings is a workaround for
// https://github.com/Microsoft/TypeScript/issues/5097
//
// This allows users to get our top-level dependencies like es6-shim.d.ts
// to appear when they compile against angular2.
//
// This carries the risk that the user brings their own copy of that file
// (or any other symbols exported here) and they will get a compiler error
// because of the duplicate definitions.
// TODO(alexeagle): remove this when typescript releases a fix
nodeTree = replace(nodeTree, {
files: ['angular2/angular2.d.ts'],
patterns: [{match: /$/, replacement: 'import "./manual_typings/globals.d.ts";\n'}]
});
return destCopy(nodeTree, destinationPath);
};