Skip to content

Commit a7ca7c1

Browse files
devversionjelbourn
authored andcommitted
build: build cdk package (#4111)
* Introduces another package called `@angular/cdk`. This package is currently empty but all the logic for SASS, HTML, TypeScript and tests is ready.
1 parent b2ca0f5 commit a7ca7c1

23 files changed

+253
-113
lines changed

src/cdk/package.json

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

src/cdk/public_api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const __TEMP__ = -1;

src/cdk/tsconfig-build.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// TypeScript config file that is used to compile the cdk package. 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/cdk",
12+
"paths": {},
13+
"rootDir": ".",
14+
"sourceMap": true,
15+
"inlineSources": true,
16+
"target": "es2015",
17+
"lib": ["es2015", "dom"],
18+
"skipLibCheck": true,
19+
"types": []
20+
},
21+
"files": [
22+
"public_api.ts"
23+
],
24+
"angularCompilerOptions": {
25+
"annotateForClosureCompiler": true,
26+
"strictMetadataEmit": true,
27+
"flatModuleOutFile": "index.js",
28+
"flatModuleId": "@angular/cdk",
29+
"skipTemplateCodegen": true
30+
}
31+
}

src/cdk/tsconfig-tests.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// TypeScript config file that extends the default tsconfig file for the cdk. This config is
2+
// used to compile the tests for Karma. Since the code will run inside of the browser, the target
3+
// needs to be ES5. The format needs to be CommonJS since Karma only supports that module format.
4+
{
5+
"extends": "./tsconfig-build",
6+
"compilerOptions": {
7+
"module": "commonjs",
8+
"target": "es5",
9+
"types": ["jasmine"],
10+
"experimentalDecorators": true
11+
},
12+
"include": [
13+
"**/*.spec.ts"
14+
],
15+
"files": null
16+
}

src/demo-app/system-config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ System.config({
2424
'node:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
2525
'@angular/platform-browser-dynamic':
2626
'node:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
27-
'@angular/material': 'dist/bundles/material.umd.js'
27+
28+
'@angular/material': 'dist/bundles/material.umd.js',
29+
// NGC always adds the `index` suffix. As a temporary workaround just map it with that.
30+
'@angular/cdk/index': 'dist/bundles/cdk.umd.js'
2831
},
2932
packages: {
3033
// Thirdparty barrels.

src/demo-app/tsconfig-build.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
"sourceMap": true,
1515
"target": "es5",
1616
"stripInternal": false,
17-
"baseUrl": "",
1817
"typeRoots": [
1918
"../../node_modules/@types/!(node)"
2019
],
20+
"baseUrl": ".",
2121
"paths": {
22-
"@angular/material": [
23-
"../../dist/packages/material"
24-
]
22+
"@angular/material": ["../../dist/packages/material"],
23+
"@angular/cdk": ["../../dist/packages/cdk"]
2524
}
2625
},
2726
"files": [

src/e2e-app/system-config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ System.config({
2424
'node:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
2525
'@angular/platform-browser-dynamic':
2626
'node:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
27-
'@angular/material': 'dist/bundles/material.umd.js'
27+
28+
'@angular/material': 'dist/bundles/material.umd.js',
29+
// NGC always adds the `index` suffix. As a temporary workaround just map it with that.
30+
'@angular/cdk/index': 'dist/bundles/cdk.umd.js'
2831
},
2932
packages: {
3033
// Thirdparty barrels.

src/lib/system-config-spec.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/lib/tsconfig-build.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
// ES2015 since the build process will create FESM bundles using rollup.
33
{
44
"compilerOptions": {
5-
"baseUrl": ".",
65
"declaration": true,
76
"stripInternal": false,
87
"experimentalDecorators": true,
98
"module": "es2015",
109
"moduleResolution": "node",
1110
"outDir": "../../dist/packages/material",
12-
"paths": {},
1311
"rootDir": ".",
1412
"sourceMap": true,
1513
"inlineSources": true,
1614
"target": "es2015",
1715
"lib": ["es2015", "dom"],
1816
"skipLibCheck": true,
19-
"types": []
17+
"types": [],
18+
"baseUrl": ".",
19+
"paths": {
20+
"@angular/cdk": ["../../dist/packages/cdk"]
21+
}
2022
},
2123
"files": [
2224
"public_api.ts",
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// TypeScript config file that extends the default tsconfig file for the library. This config is
2-
// used to compile the specs for Karma. Since the code will run inside of the browser, the target
2+
// used to compile the tests for Karma. Since the code will run inside of the browser, the target
33
// needs to be ES5. The format needs to be CommonJS since Karma only supports that module format.
44
{
55
"extends": "./tsconfig-build",
@@ -10,7 +10,7 @@
1010
"experimentalDecorators": true
1111
},
1212
"include": [
13-
"system-config-spec.ts",
1413
"**/*.spec.ts"
15-
]
14+
],
15+
"files": null
1616
}

src/lib/typings.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
declare const module: {id: string};
1+
declare var module: {id: string};

src/material-examples/tsconfig-build.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,23 @@
22
// ES2015 since the build process will create FESM bundles using rollup.
33
{
44
"compilerOptions": {
5-
"baseUrl": ".",
65
"declaration": true,
76
"stripInternal": false,
87
"experimentalDecorators": true,
98
"module": "es2015",
109
"moduleResolution": "node",
1110
"outDir": "../../dist/packages/examples",
12-
"paths": {
13-
"@angular/material": [
14-
"../../dist/packages/material"
15-
]
16-
},
1711
"rootDir": ".",
1812
"sourceMap": true,
1913
"inlineSources": true,
2014
"target": "es2015",
2115
"lib": ["es2015", "dom"],
2216
"skipLibCheck": true,
23-
"types": []
17+
"types": [],
18+
"baseUrl": ".",
19+
"paths": {
20+
"@angular/material": ["../../dist/packages/material"]
21+
}
2422
},
2523
"files": [
2624
"public_api.ts"

src/tsconfig.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
"experimentalDecorators": true,
66
"module": "es2015",
77
"moduleResolution": "node",
8-
"outDir": "../../dist/packages/all",
8+
"outDir": "../dist/packages/all",
99
"sourceMap": true,
1010
"inlineSources": true,
1111
"target": "es2015",
1212
"lib": ["es2015", "dom"],
1313
"types": ["jasmine"],
14+
"baseUrl": ".",
1415
"paths": {
15-
"@angular/material": [
16-
"../../dist/packages/material"
17-
]
16+
"@angular/material": ["./lib/public_api.ts"],
17+
"@angular/cdk": ["./cdk/public_api.ts"]
1818
}
1919
}
2020
}

test/karma-test-shim.js

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,60 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 3000;
55
__karma__.loaded = function () {};
66

77
var baseDir = '/base';
8-
var configFile = baseDir + '/dist/packages/material/system-config-spec.js';
98
var specFiles = Object.keys(window.__karma__.files).filter(isMaterialSpecFile);
109

11-
// Configure the base path for dist/
12-
System.config({ baseURL: baseDir });
10+
// Configure the base path and map the different node packages.
11+
System.config({
12+
baseURL: baseDir,
13+
paths: {
14+
'node:*': 'node_modules/*'
15+
},
16+
map: {
17+
'rxjs': 'node:rxjs',
18+
'main': 'main.js',
1319

14-
// Load the spec SystemJS configuration file.
15-
System.import(configFile)
16-
.then(configureTestBed)
20+
// Angular specific mappings.
21+
'@angular/core': 'node:@angular/core/bundles/core.umd.js',
22+
'@angular/core/testing': 'node:@angular/core/bundles/core-testing.umd.js',
23+
'@angular/common': 'node:@angular/common/bundles/common.umd.js',
24+
'@angular/common/testing': 'node:@angular/common/bundles/common-testing.umd.js',
25+
'@angular/compiler': 'node:@angular/compiler/bundles/compiler.umd.js',
26+
'@angular/compiler/testing': 'node:@angular/compiler/bundles/compiler-testing.umd.js',
27+
'@angular/http': 'node:@angular/http/bundles/http.umd.js',
28+
'@angular/http/testing': 'node:@angular/http/bundles/http-testing.umd.js',
29+
'@angular/forms': 'node:@angular/forms/bundles/forms.umd.js',
30+
'@angular/forms/testing': 'node:@angular/forms/bundles/forms-testing.umd.js',
31+
'@angular/animations': 'node:@angular/animations/bundles/animations.umd.js',
32+
'@angular/animations/browser': 'node:@angular/animations/bundles/animations-browser.umd.js',
33+
'@angular/platform-browser/animations':
34+
'node:@angular/platform-browser/bundles/platform-browser-animations.umd',
35+
'@angular/platform-browser':
36+
'node:@angular/platform-browser/bundles/platform-browser.umd.js',
37+
'@angular/platform-browser/testing':
38+
'node:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
39+
'@angular/platform-browser-dynamic':
40+
'node:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
41+
'@angular/platform-browser-dynamic/testing':
42+
'node:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
43+
44+
// Path mappings for local packages that can be imported inside of tests.
45+
'@angular/material': 'dist/bundles/material.umd.js',
46+
'@angular/cdk': 'dist/bundles/cdk.umd.js',
47+
},
48+
packages: {
49+
// Thirdparty barrels.
50+
'rxjs': {main: 'index'},
51+
52+
// Set the default extension for the root package, because otherwise the demo-app can't
53+
// be built within the production mode. Due to missing file extensions.
54+
'.': {
55+
defaultExtension: 'js'
56+
}
57+
}
58+
});
59+
60+
// Configure the Angular test bed and run all specs once configured.
61+
configureTestBed()
1762
.then(runMaterialSpecs)
1863
.then(__karma__.start, __karma__.error);
1964

@@ -47,4 +92,4 @@ function configureTestBed() {
4792
testingBrowser.platformBrowserDynamicTesting()
4893
);
4994
});
50-
}
95+
}

test/karma.conf.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,18 @@ module.exports = (config) => {
3333
{pattern: 'test/karma-test-shim.js', included: true, watched: false},
3434

3535
// Include a Material theme in the test suite.
36-
{pattern: 'dist/**/core/theming/prebuilt/indigo-pink.css', included: true, watched: true},
36+
{pattern: 'dist/packages/**/core/theming/prebuilt/indigo-pink.css', included: true, watched: true},
3737

38-
// Includes Material spec and source files into karma. Those files will be watched.
39-
{pattern: 'dist/packages/material/**/*.js', included: false, watched: true},
40-
41-
// Paths to support debugging with source maps in dev tools
42-
{pattern: 'dist/**/*.ts', included: false, watched: false},
43-
{pattern: 'dist/**/*.js.map', included: false, watched: false}
38+
// Includes all package tests and source files into karma. Those files will be watched.
39+
// This pattern also matches all all sourcemap files and TypeScript files for debugging.
40+
{pattern: 'dist/packages/**/*', included: false, watched: true},
41+
{pattern: 'dist/bundles/*.umd.js', included: false, watched: true},
4442
],
4543

4644
customLaunchers: customLaunchers,
4745

4846
preprocessors: {
49-
'dist/**/*.js': ['sourcemap']
47+
'dist/packages/**/*.js': ['sourcemap']
5048
},
5149

5250
reporters: ['dots'],
@@ -103,7 +101,7 @@ module.exports = (config) => {
103101
if (process.env['TRAVIS_PULL_REQUEST'] === 'false' &&
104102
process.env['MODE'] === "browserstack_required") {
105103

106-
config.preprocessors['dist/@angular/material/**/!(*+(.|-)spec).js'] = ['coverage'];
104+
config.preprocessors['dist/packages/**/!(*+(.|-)spec).js'] = ['coverage'];
107105
config.reporters.push('coverage');
108106
}
109107

tools/gulp/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ 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+
export const DIST_CDK = join(DIST_ROOT, 'packages', 'cdk');
1617
export const DIST_DEMOAPP = join(DIST_ROOT, 'packages', 'demo-app');
1718
export const DIST_E2EAPP = join(DIST_ROOT, 'packages', 'e2e-app');
1819
export const DIST_EXAMPLES = join(DIST_ROOT, 'packages', 'examples');

tools/gulp/gulpfile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ import './tasks/payload';
1313
import './tasks/coverage';
1414
import './tasks/library';
1515
import './tasks/examples';
16+
import './tasks/cdk';

0 commit comments

Comments
 (0)