X Tutup
Skip to content

Commit 57649d1

Browse files
committed
fix(publish): emit type declarations with CJS build
Closes #4706 Closes #4708
1 parent e82a35d commit 57649d1

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ gulp.task('test.typings', ['!pre.test.typings'], function() {
831831
var tmpdir = path.join(os.tmpdir(), 'test.typings', new Date().getTime().toString());
832832
gulp.task('!pre.test.typings.layoutNodeModule', function() {
833833
return gulp
834-
.src(['dist/js/dev/es5/angular2/**/*'], {base: 'dist/js/dev/es5'})
834+
.src(['dist/js/cjs/angular2/**/*'], {base: 'dist/js/cjs'})
835835
.pipe(gulp.dest(path.join(tmpdir, 'node_modules')));
836836
});
837837
gulp.task('!pre.test.typings.copyTypingsSpec', function() {

tools/broccoli/trees/node_tree.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ module.exports = function makeNodeTree(destinationPath) {
3636
allowNonTsExtensions: false,
3737
emitDecoratorMetadata: true,
3838
experimentalDecorators: true,
39-
declaration: false,
39+
declaration: true,
40+
stripInternal: true,
4041
mapRoot: '', /* force sourcemaps to use relative path */
4142
module: 'CommonJS',
4243
moduleResolution: 1 /* classic */,
@@ -77,7 +78,10 @@ module.exports = function makeNodeTree(destinationPath) {
7778
packageJsons =
7879
renderLodashTemplate(packageJsons, {context: {'packageJson': COMMON_PACKAGE_JSON}});
7980

80-
var nodeTree = mergeTrees([typescriptTree, docs, packageJsons]);
81+
var typingsTree = new Funnel(
82+
'modules',
83+
{include: ['angular2/typings/**/*.d.ts', 'angular2/manual_typings/*.d.ts'], destDir: '/'});
84+
var nodeTree = mergeTrees([typescriptTree, docs, packageJsons, typingsTree]);
8185

8286
// Transform all tests to make them runnable in node
8387
nodeTree = replace(nodeTree, {
@@ -101,5 +105,21 @@ module.exports = function makeNodeTree(destinationPath) {
101105
patterns: [{match: /^/, replacement: function() { return `'use strict';` }}]
102106
});
103107

108+
// Add a line to the end of our top-level .d.ts file.
109+
// This HACK for transitive typings is a workaround for
110+
// https://github.com/Microsoft/TypeScript/issues/5097
111+
//
112+
// This allows users to get our top-level dependencies like es6-shim.d.ts
113+
// to appear when they compile against angular2.
114+
//
115+
// This carries the risk that the user brings their own copy of that file
116+
// (or any other symbols exported here) and they will get a compiler error
117+
// because of the duplicate definitions.
118+
// TODO(alexeagle): remove this when typescript releases a fix
119+
nodeTree = replace(nodeTree, {
120+
files: ['angular2/angular2.d.ts'],
121+
patterns: [{match: /$/, replacement: 'import "./manual_typings/globals.d.ts";\n'}]
122+
});
123+
104124
return destCopy(nodeTree, destinationPath);
105125
};

0 commit comments

Comments
 (0)
X Tutup