fix(typings): Don't expose typing dependencies to users.

This resolves Duplicate Identifier issues seen by many users,
at the expense of more typings installation required in some
cases.

Removes the quickstart hack of placing all needed dependencies
typings files in our distribution. Removes dependencies on
nodejs from angular2/core.

Fixes #5973
Fixes #5807
Fixes #6266

Angular now depends on es6-promise and es6-collections
(and a handful of manual typings) rather than all of es6-shim.

Fixes #5242

We previously had an undocumented breaking change, this is now
documented in this commit.

Fixes #6817

BREAKING CHANGE:

Transitive typings are no longer included in the distribution.
You may need to install typings in your project using
http://github.com/typings/typings

Users now must rely on getting typings from:
- one of the peerDependencies, such as rxjs, which exposes
  typings via the moduleResolution=node mechanism.
  (see https://github.com/Microsoft/TypeScript/wiki/Typings-for-npm-packages)
  This happens automatically.
- Using --target ES5 now requires manual installation of
  es6-promise and es6-collections typings.
- Using some angular APIs may introduce a dependency on eg. nodejs
  or jasmine, and those typings need manual installation as well.

Closes #6267
This commit is contained in:
Alex Eagle
2016-02-01 10:29:42 -08:00
committed by Alex Eagle
parent 2f31c4c1c5
commit 2a70f4e4c7
9 changed files with 125 additions and 96 deletions

View File

@ -171,6 +171,14 @@ module.exports = function makeBrowserTree(options, destinationPath) {
patterns: [{match: /\$SCRIPTS\$/, replacement: jsReplace('SCRIPTS')}]
});
let ambientTypings = [
'angular2/typings/hammerjs/hammerjs.d.ts',
'angular2/typings/node/node.d.ts',
'angular2/manual_typings/globals.d.ts',
'angular2/typings/es6-collections/es6-collections.d.ts',
'angular2/typings/es6-promise/es6-promise.d.ts'
];
// Use TypeScript to transpile the *.ts files to ES5
var es5Tree = compileWithTypescript(es5ModulesTree, {
declaration: false,
@ -180,7 +188,7 @@ module.exports = function makeBrowserTree(options, destinationPath) {
moduleResolution: 'classic',
noEmitOnError: !noTypeChecks,
rootDir: './',
rootFilePaths: ['angular2/manual_typings/globals.d.ts'],
rootFilePaths: ambientTypings,
inlineSourceMap: sourceMaps,
inlineSources: sourceMaps,
target: 'es5'
@ -311,7 +319,11 @@ module.exports = function makeBrowserTree(options, destinationPath) {
experimentalDecorators: true,
noEmitOnError: false,
rootDir: './',
rootFilePaths: ['angular2/manual_typings/globals-es6.d.ts'],
rootFilePaths: [
'angular2/typings/zone.js/zone.js.d.ts',
'angular2/typings/hammerjs/hammerjs.d.ts',
'angular2/typings/node/node.d.ts',
],
inlineSourceMap: sourceMaps,
inlineSources: sourceMaps,
target: 'es6'

View File

@ -32,9 +32,16 @@ module.exports = function makeNodeTree(projects, destinationPath) {
]
});
let ambientTypings = [
'angular2/typings/hammerjs/hammerjs.d.ts',
'angular2/typings/node/node.d.ts',
'angular2/manual_typings/globals.d.ts',
'angular2/typings/es6-collections/es6-collections.d.ts',
'angular2/typings/es6-promise/es6-promise.d.ts'
];
// Compile the sources and generate the @internal .d.ts
let compiledSrcTreeWithInternals =
compileTree(srcTree, true, ['angular2/manual_typings/globals.d.ts']);
let compiledSrcTreeWithInternals = compileTree(srcTree, true, ambientTypings);
var testTree = new Funnel('modules', {
include: [
@ -85,11 +92,10 @@ module.exports = function makeNodeTree(projects, destinationPath) {
testTree = mergeTrees([testTree, srcPrivateDeclarations]);
let compiledTestTree = compileTree(testTree, false, [
let compiledTestTree = compileTree(testTree, false, ambientTypings.concat([
'angular2/typings/jasmine/jasmine.d.ts',
'angular2/typings/angular-protractor/angular-protractor.d.ts',
'angular2/manual_typings/globals.d.ts'
]);
]));
// Merge the compiled sources and tests
let compiledSrcTree =
@ -112,12 +118,7 @@ module.exports = function makeNodeTree(projects, destinationPath) {
var srcPkgJsons = extractPkgJsons(srcTree, BASE_PACKAGE_JSON);
var testPkgJsons = extractPkgJsons(testTree, BASE_PACKAGE_JSON);
var typingsTree = new Funnel(
'modules',
{include: ['angular2/typings/**/*.d.ts', 'angular2/manual_typings/*.d.ts'], destDir: '/'});
var nodeTree =
mergeTrees([compiledTree, srcDocs, testDocs, srcPkgJsons, testPkgJsons, typingsTree]);
var nodeTree = mergeTrees([compiledTree, srcDocs, testDocs, srcPkgJsons, testPkgJsons]);
// Transform all tests to make them runnable in node
nodeTree = replace(nodeTree, {
@ -139,22 +140,6 @@ module.exports = function makeNodeTree(projects, destinationPath) {
nodeTree = replace(
nodeTree, {files: ['**/*.js'], patterns: [{match: /^/, replacement: () => `'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 zone.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/core.d.ts'],
patterns: [{match: /$/, replacement: 'import "./manual_typings/globals-es6.d.ts";\r\n'}]
});
return destCopy(nodeTree, destinationPath);
};