fix(publish): emit type declarations with CJS build
Closes #4706 Closes #4708
This commit is contained in:
parent
e82a35d1fd
commit
57649d1839
@ -831,7 +831,7 @@ gulp.task('test.typings', ['!pre.test.typings'], function() {
|
|||||||
var tmpdir = path.join(os.tmpdir(), 'test.typings', new Date().getTime().toString());
|
var tmpdir = path.join(os.tmpdir(), 'test.typings', new Date().getTime().toString());
|
||||||
gulp.task('!pre.test.typings.layoutNodeModule', function() {
|
gulp.task('!pre.test.typings.layoutNodeModule', function() {
|
||||||
return gulp
|
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')));
|
.pipe(gulp.dest(path.join(tmpdir, 'node_modules')));
|
||||||
});
|
});
|
||||||
gulp.task('!pre.test.typings.copyTypingsSpec', function() {
|
gulp.task('!pre.test.typings.copyTypingsSpec', function() {
|
||||||
|
@ -36,7 +36,8 @@ module.exports = function makeNodeTree(destinationPath) {
|
|||||||
allowNonTsExtensions: false,
|
allowNonTsExtensions: false,
|
||||||
emitDecoratorMetadata: true,
|
emitDecoratorMetadata: true,
|
||||||
experimentalDecorators: true,
|
experimentalDecorators: true,
|
||||||
declaration: false,
|
declaration: true,
|
||||||
|
stripInternal: true,
|
||||||
mapRoot: '', /* force sourcemaps to use relative path */
|
mapRoot: '', /* force sourcemaps to use relative path */
|
||||||
module: 'CommonJS',
|
module: 'CommonJS',
|
||||||
moduleResolution: 1 /* classic */,
|
moduleResolution: 1 /* classic */,
|
||||||
@ -77,7 +78,10 @@ module.exports = function makeNodeTree(destinationPath) {
|
|||||||
packageJsons =
|
packageJsons =
|
||||||
renderLodashTemplate(packageJsons, {context: {'packageJson': COMMON_PACKAGE_JSON}});
|
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
|
// Transform all tests to make them runnable in node
|
||||||
nodeTree = replace(nodeTree, {
|
nodeTree = replace(nodeTree, {
|
||||||
@ -101,5 +105,21 @@ module.exports = function makeNodeTree(destinationPath) {
|
|||||||
patterns: [{match: /^/, replacement: function() { return `'use strict';` }}]
|
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);
|
return destCopy(nodeTree, destinationPath);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user