Skip to content

Commit abd2ac6

Browse files
devversionjelbourn
authored andcommitted
build: create material-examples package (#4046)
1 parent 3545df7 commit abd2ac6

File tree

164 files changed

+311
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+311
-182
lines changed

scripts/closure-compiler/build-devapp-bundle.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ OPTS=(
3939

4040
# List of path prefixes to be removed from ES6 & CommonJS modules.
4141
"--js_module_root=dist/packages"
42-
"--js_module_root=dist/release"
42+
"--js_module_root=dist/releases/material"
4343
"--js_module_root=node_modules/@angular/core"
4444
"--js_module_root=node_modules/@angular/common"
4545
"--js_module_root=node_modules/@angular/compiler"
@@ -57,7 +57,7 @@ OPTS=(
5757
"--debug"
5858

5959
# Include the Material FESM bundle
60-
dist/release/@angular/material.js
60+
dist/releases/material/@angular/material.js
6161

6262
# Include all Angular FESM bundles.
6363
node_modules/@angular/core/@angular/core.js

scripts/release/publish-build-artifacts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -e -o pipefail
88
# Go to the project root directory
99
cd $(dirname $0)/../..
1010

11-
buildDir="dist/release"
11+
buildDir="dist/releases/material"
1212
buildVersion=$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' package.json)
1313

1414
commitSha=$(git rev-parse --short HEAD)

src/lib/core/overlay/overlay-ref.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class OverlayRef implements PortalHost {
103103
}
104104
}
105105

106-
/** Updates the text direction of the overlay panel. **/
106+
/** Updates the text direction of the overlay panel. */
107107
private updateDirection() {
108108
this._pane.setAttribute('dir', this._state.direction);
109109
}

src/lib/core/overlay/overlay-state.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ export class OverlayState {
1313
/** Whether the overlay has a backdrop. */
1414
hasBackdrop: boolean = false;
1515

16-
/** Custom class to add to the backdrop **/
16+
/** Custom class to add to the backdrop */
1717
backdropClass: string = 'cdk-overlay-dark-backdrop';
1818

19-
/** The width of the overlay panel. If a number is provided, pixel units are assumed. **/
19+
/** The width of the overlay panel. If a number is provided, pixel units are assumed. */
2020
width: number | string;
2121

22-
/** The height of the overlay panel. If a number is provided, pixel units are assumed. **/
22+
/** The height of the overlay panel. If a number is provided, pixel units are assumed. */
2323
height: number | string;
2424

25-
/** The min-width of the overlay panel. If a number is provided, pixel units are assumed. **/
25+
/** The min-width of the overlay panel. If a number is provided, pixel units are assumed. */
2626
minWidth: number | string;
2727

28-
/** The min-height of the overlay panel. If a number is provided, pixel units are assumed. **/
28+
/** The min-height of the overlay panel. If a number is provided, pixel units are assumed. */
2929
minHeight: number | string;
3030

3131
/** The direction of the text in the overlay panel. */

src/examples/autocomplete-overview/autocomplete-overview-example.ts renamed to src/material-examples/autocomplete-overview/autocomplete-overview-example.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import {Component} from '@angular/core';
22
import {FormControl} from '@angular/forms';
3+
34
import 'rxjs/add/operator/startWith';
5+
import 'rxjs/add/operator/map';
46

57
@Component({
68
selector: 'autocomplete-overview-example',
File renamed without changes.

src/material-examples/package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "@angular/material-examples",
3+
"version": "2.0.0-beta.3",
4+
"description": "Angular Material Examples",
5+
"main": "./bundles/material-examples.umd.js",
6+
"module": "./@angular/material-examples.es5.js",
7+
"es2015": "./@angular/material-examples.js",
8+
"typings": "./material-examples.d.ts",
9+
"private": true,
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/angular/material2.git"
13+
},
14+
"keywords": [
15+
"angular",
16+
"material",
17+
"material design",
18+
"components"
19+
],
20+
"license": "MIT",
21+
"bugs": {
22+
"url": "https://github.com/angular/material2/issues"
23+
},
24+
"homepage": "https://github.com/angular/material2#readme",
25+
"peerDependencies": {
26+
"@angular/core": "^4.0.0",
27+
"@angular/common": "^4.0.0",
28+
"@angular/http": "^4.0.0"
29+
}
30+
}

src/material-examples/public_api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './example-data';
2+
export * from './example-module';
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// TypeScript config file that is used to compile the examples. Target environment needs to be
2+
// ES2015 since the build process will create FESM bundles using rollup.
3+
{
4+
"compilerOptions": {
5+
"baseUrl": ".",
6+
"declaration": true,
7+
"stripInternal": false,
8+
"experimentalDecorators": true,
9+
"module": "es2015",
10+
"moduleResolution": "node",
11+
"outDir": "../../dist/packages/examples",
12+
"paths": {
13+
"@angular/material": [
14+
"../../dist/packages/material"
15+
]
16+
},
17+
"rootDir": ".",
18+
"sourceMap": true,
19+
"inlineSources": true,
20+
"target": "es2015",
21+
"lib": ["es2015", "dom"],
22+
"skipLibCheck": true,
23+
"types": []
24+
},
25+
"files": [
26+
"public_api.ts"
27+
],
28+
"angularCompilerOptions": {
29+
"annotateForClosureCompiler": true,
30+
"strictMetadataEmit": true,
31+
"flatModuleOutFile": "index.js",
32+
"skipTemplateCodegen": true
33+
}
34+
}

src/tsconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
"inlineSources": true,
1111
"target": "es2015",
1212
"lib": ["es2015", "dom"],
13-
"types": ["jasmine"]
13+
"types": ["jasmine"],
14+
"paths": {
15+
"@angular/material": [
16+
"../../dist/packages/material"
17+
]
18+
}
1419
}
1520
}

tools/dgeni/processors/categorizer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = function categorizer() {
1818
* Decorates all class docs inside of the dgeni pipeline.
1919
* - Methods and properties of a class-doc will be extracted into separate variables.
2020
* - Identifies directives, services or NgModules and marks them them in class-doc.
21-
**/
21+
*/
2222
function decorateClassDoc(classDoc) {
2323
// Resolve all methods and properties from the classDoc. Includes inherited docs.
2424
classDoc.methods = resolveMethods(classDoc);
@@ -42,7 +42,7 @@ module.exports = function categorizer() {
4242
/**
4343
* Method that will be called for each method doc. The parameters for the method-docs
4444
* will be normalized, so that they can be easily used inside of dgeni templates.
45-
**/
45+
*/
4646
function decorateMethodDoc(methodDoc) {
4747
normalizeMethodParameters(methodDoc);
4848

@@ -53,7 +53,7 @@ module.exports = function categorizer() {
5353
/**
5454
* Method that will be called for each property doc. Properties that are Angular inputs or
5555
* outputs will be marked. Aliases for the inputs or outputs will be stored as well.
56-
**/
56+
*/
5757
function decoratePropertyDoc(propertyDoc) {
5858
propertyDoc.isDirectiveInput = isDirectiveInput(propertyDoc);
5959
propertyDoc.directiveInputAlias = getDirectiveInputAlias(propertyDoc);

tools/gulp/constants.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ export const DIST_BUNDLES = join(DIST_ROOT, 'bundles');
1313

1414
/** Output subdirectory where all library artifacts will be written (compiled JS, CSS, etc.) */
1515
export const DIST_MATERIAL = join(DIST_ROOT, 'packages', 'material');
16-
17-
/** Output subdirectory where the npm package will be staged for publish */
18-
export const DIST_RELEASE = join(DIST_ROOT, 'release');
19-
2016
export const DIST_DEMOAPP = join(DIST_ROOT, 'packages', 'demo-app');
2117
export const DIST_E2EAPP = join(DIST_ROOT, 'packages', 'e2e-app');
18+
export const DIST_EXAMPLES = join(DIST_ROOT, 'packages', 'examples');
19+
20+
export const DIST_RELEASES = join(DIST_ROOT, 'releases');
2221

2322
export const COVERAGE_RESULT_FILE = join(DIST_ROOT, 'coverage', 'coverage-summary.json');
2423

tools/gulp/gulpfile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ import './tasks/aot';
1212
import './tasks/payload';
1313
import './tasks/coverage';
1414
import './tasks/library';
15+
import './tasks/examples';

tools/gulp/tasks/aot.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {task} from 'gulp';
22
import {copySync} from 'fs-extra';
3-
import {DIST_DEMOAPP, DIST_RELEASE} from '../constants';
3+
import {DIST_DEMOAPP, DIST_RELEASES} from '../constants';
44
import {sequenceTask, execNodeTask} from '../util/task_helpers';
55
import {join} from 'path';
66

@@ -11,7 +11,9 @@ task('aot:deps', sequenceTask('build:devapp', ':package:release', 'aot:copy-rele
1111

1212
// As a workaround for https://github.com/angular/angular/issues/12249, we need to
1313
// copy the Material ESM output inside of the demo-app output.
14-
task('aot:copy-release', () => copySync(DIST_RELEASE, join(DIST_DEMOAPP, 'material')));
14+
task('aot:copy-release', () => {
15+
return copySync(join(DIST_RELEASES, 'material'), join(DIST_DEMOAPP, 'material'));
16+
});
1517

1618
/** Build the demo-app and a release to confirm that the library is AOT-compatible. */
1719
task('aot:build', sequenceTask('aot:deps', 'aot:compiler-cli'));

tools/gulp/tasks/docs.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ const MARKDOWN_TAGS_TO_CLASS_ALIAS = [
4848
'code',
4949
];
5050

51-
5251
/** Generate all docs content. */
5352
task('docs', [
5453
'markdown-docs',

tools/gulp/tasks/examples.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import {task} from 'gulp';
2+
import {join} from 'path';
3+
import {main as tsc} from '@angular/tsc-wrapped';
4+
import {SOURCE_ROOT, DIST_EXAMPLES} from '../constants';
5+
import {sequenceTask, copyTask} from '../util/task_helpers';
6+
import {buildModuleEntry, composeRelease} from '../util/package-build';
7+
8+
// There are no type definitions available for these imports.
9+
const inlineResources = require('../../../scripts/release/inline-resources');
10+
11+
const examplesRoot = join(SOURCE_ROOT, 'material-examples');
12+
const tsconfigPath = join(examplesRoot, 'tsconfig-build.json');
13+
14+
// Paths to the different output files and directories.
15+
const examplesOut = DIST_EXAMPLES;
16+
const examplesMain = join(examplesOut, 'public_api.js');
17+
18+
task('examples:clean-build', sequenceTask('clean', 'examples:build'));
19+
20+
task('examples:build', sequenceTask(
21+
// The examples depend on the library. Build the library first.
22+
'library:build',
23+
// Build ESM and copy HTML assets to the dist.
24+
['examples:build:esm', 'examples:assets:html'],
25+
// Inline assets into ESM output.
26+
'examples:assets:inline',
27+
// Build bundles on top of inlined ESM output.
28+
'examples:build:bundles',
29+
));
30+
31+
task('examples:release', ['examples:clean-build'], () => composeRelease('material-examples'));
32+
33+
/**
34+
* TypeScript compilation tasks. Tasks are creating ESM, FESM, UMD bundles for releases.
35+
*/
36+
37+
task('examples:build:esm', () => tsc(tsconfigPath, {basePath: examplesRoot}));
38+
task('examples:build:bundles', () => buildModuleEntry(examplesMain, 'material-examples'));
39+
40+
/**
41+
* Asset tasks. Copying and inlining CSS, HTML files into the ESM output.
42+
*/
43+
44+
task('examples:assets:html', copyTask(join(examplesRoot, '**/*.+(html|css)'), examplesOut));
45+
task('examples:assets:inline', () => inlineResources(examplesOut));

tools/gulp/tasks/library.ts

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
import {task, watch} from 'gulp';
22
import {join} from 'path';
33
import {main as tsc} from '@angular/tsc-wrapped';
4-
import {SOURCE_ROOT, DIST_BUNDLES, DIST_MATERIAL} from '../constants';
4+
import {SOURCE_ROOT, DIST_MATERIAL} from '../constants';
55
import {sequenceTask, sassBuildTask, copyTask, triggerLivereload} from '../util/task_helpers';
6-
import {createRollupBundle} from '../util/rollup-helper';
7-
import {transpileFile} from '../util/ts-compiler';
8-
import {ScriptTarget, ModuleKind} from 'typescript';
9-
import {writeFileSync} from 'fs';
6+
import {buildModuleEntry} from '../util/package-build';
107

118
// There are no type definitions available for these imports.
129
const inlineResources = require('../../../scripts/release/inline-resources');
13-
const uglify = require('uglify-js');
1410

1511
const libraryRoot = join(SOURCE_ROOT, 'lib');
1612
const tsconfigPath = join(libraryRoot, 'tsconfig-build.json');
1713

18-
// Paths to the different output directories.
14+
// Paths to the different output files and directories.
1915
const materialDir = DIST_MATERIAL;
20-
const bundlesDir = DIST_BUNDLES;
21-
2216
const esmMainFile = join(materialDir, 'index.js');
2317

2418
task('library:clean-build', sequenceTask('clean', 'library:build'));
@@ -40,52 +34,14 @@ task('library:watch', () => {
4034

4135
/**
4236
* TypeScript compilation tasks. Tasks are creating ESM, FESM, UMD bundles for releases.
43-
**/
37+
*/
4438

4539
task('library:build:esm', () => tsc(tsconfigPath, {basePath: libraryRoot}));
4640
task('library:build:bundles', () => buildModuleEntry(esmMainFile));
4741

48-
/** Builds a module entry-point. If no entry name is specified it builds the whole library. */
49-
async function buildModuleEntry(entryFile: string, entryName = '') {
50-
let baseFileName = entryName ? `material-${entryName}` : 'material';
51-
let moduleName = entryName ? `ng.material.${entryName}` : 'ng.material';
52-
53-
// List of paths for the specified entrypoint.
54-
let fesm2015File = join(bundlesDir, `${baseFileName}.js`);
55-
let fesm2014File = join(bundlesDir, `${baseFileName}.es5.js`);
56-
let umdFile = join(bundlesDir, `${baseFileName}.umd.js`);
57-
let umdMinFile = join(bundlesDir, `${baseFileName}.umd.min.js`);
58-
59-
// Build FESM-2015 bundle file.
60-
await createRollupBundle({
61-
moduleName: moduleName,
62-
entry: entryFile,
63-
dest: fesm2015File,
64-
format: 'es',
65-
});
66-
67-
// Downlevel FESM-2015 file to ES5.
68-
transpileFile(fesm2015File, fesm2014File, {
69-
target: ScriptTarget.ES5,
70-
module: ModuleKind.ES2015,
71-
allowJs: true
72-
});
73-
74-
// Create UMD bundle of FESM-2014 output.
75-
await createRollupBundle({
76-
moduleName: moduleName,
77-
entry: fesm2014File,
78-
dest: umdFile,
79-
format: 'umd'
80-
});
81-
82-
// Output a minified version of the UMD bundle
83-
writeFileSync(umdMinFile, uglify.minify(umdFile, { preserveComments: 'license' }).code);
84-
}
85-
8642
/**
8743
* Asset tasks. Building SaSS files and inlining CSS, HTML files into the ESM output.
88-
**/
44+
*/
8945

9046
task('library:assets', ['library:assets:scss', 'library:assets:html']);
9147

0 commit comments

Comments
 (0)