diff --git a/src/material-moment-adapter/index.spec.ts b/src/material-moment-adapter/index.spec.ts new file mode 100644 index 00000000000..a1ef3b6c170 --- /dev/null +++ b/src/material-moment-adapter/index.spec.ts @@ -0,0 +1,9 @@ +import {_momentAdapter} from './public_api'; + +describe('moment-adapter', () => { + + it('should be tested when running the tests', () => { + expect(_momentAdapter).toBe(0); + }); + +}); diff --git a/src/material-moment-adapter/index.ts b/src/material-moment-adapter/index.ts new file mode 100644 index 00000000000..f93e7c31d56 --- /dev/null +++ b/src/material-moment-adapter/index.ts @@ -0,0 +1,9 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +export * from './public_api'; diff --git a/src/material-moment-adapter/package.json b/src/material-moment-adapter/package.json new file mode 100644 index 00000000000..116617becbc --- /dev/null +++ b/src/material-moment-adapter/package.json @@ -0,0 +1,25 @@ +{ + "name": "@angular/material-moment-adapter", + "version": "0.0.0-PLACEHOLDER", + "description": "Angular Material Moment Adapter", + "main": "./bundles/material-moment-adapter.umd.js", + "module": "./@angular/material-moment-adapter.es5.js", + "es2015": "./@angular/material-moment-adapter.js", + "typings": "./material-moment-adapter.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/angular/material2.git" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/angular/material2/issues" + }, + "homepage": "https://github.com/angular/material2#readme", + "peerDependencies": { + "@angular/material": "0.0.0-PLACEHOLDER", + "@angular/core": "^4.0.0" + }, + "dependencies": { + "tslib": "^1.7.1" + } +} diff --git a/src/material-moment-adapter/public_api.ts b/src/material-moment-adapter/public_api.ts new file mode 100644 index 00000000000..5f61ef654dc --- /dev/null +++ b/src/material-moment-adapter/public_api.ts @@ -0,0 +1,9 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +export const _momentAdapter = 0; diff --git a/src/material-moment-adapter/tsconfig-build.json b/src/material-moment-adapter/tsconfig-build.json new file mode 100644 index 00000000000..de8b8dab6d0 --- /dev/null +++ b/src/material-moment-adapter/tsconfig-build.json @@ -0,0 +1,37 @@ +// TypeScript config file that is used to compile the moment-adapter package. Target environment +// needs to be ES2015 since the build process will create FESM bundles using rollup. +{ + "compilerOptions": { + "baseUrl": ".", + "declaration": true, + "stripInternal": false, + "experimentalDecorators": true, + "noUnusedParameters": true, + "strictNullChecks": true, + "importHelpers": true, + "newLine": "lf", + "module": "es2015", + "moduleResolution": "node", + "outDir": "../../dist/packages/material-moment-adapter", + "rootDir": ".", + "sourceMap": true, + "inlineSources": true, + "target": "es2015", + "lib": ["es2015", "dom"], + "skipLibCheck": true, + "types": [], + "paths": { + "@angular/material": ["../../dist/packages/material/public_api"] + } + }, + "files": [ + "public_api.ts" + ], + "angularCompilerOptions": { + "annotateForClosureCompiler": true, + "strictMetadataEmit": true, + "flatModuleOutFile": "index.js", + "flatModuleId": "@angular/material-moment-adapter", + "skipTemplateCodegen": true + } +} diff --git a/src/material-moment-adapter/tsconfig-tests.json b/src/material-moment-adapter/tsconfig-tests.json new file mode 100644 index 00000000000..4369cb530a2 --- /dev/null +++ b/src/material-moment-adapter/tsconfig-tests.json @@ -0,0 +1,16 @@ +// TypeScript config file that extends the default tsconfig file for the moment-adapter. +// This config is used to compile the tests for Karma. Since the code will run inside of the +// browser, the target needs to be ES5. The format needs to be CommonJS for Karma. +{ + "extends": "./tsconfig-build", + "compilerOptions": { + "importHelpers": false, + "module": "commonjs", + "target": "es5", + "types": ["jasmine"] + }, + "include": [ + "**/*.spec.ts", + "index.ts" + ] +} diff --git a/tools/gulp/gulpfile.ts b/tools/gulp/gulpfile.ts index 020c7ef31c2..37076dc312f 100644 --- a/tools/gulp/gulpfile.ts +++ b/tools/gulp/gulpfile.ts @@ -1,9 +1,10 @@ import {createPackageBuildTasks} from 'material2-build-tools'; -import {cdkPackage, examplesPackage, materialPackage} from './packages'; +import {cdkPackage, examplesPackage, materialPackage, momentAdapterPackage} from './packages'; createPackageBuildTasks(cdkPackage); createPackageBuildTasks(materialPackage); createPackageBuildTasks(examplesPackage); +createPackageBuildTasks(momentAdapterPackage); import './tasks/ci'; import './tasks/clean'; diff --git a/tools/gulp/packages.ts b/tools/gulp/packages.ts index 5a31abab8f4..40ce3463fd9 100644 --- a/tools/gulp/packages.ts +++ b/tools/gulp/packages.ts @@ -4,6 +4,8 @@ import {join} from 'path'; export const cdkPackage = new BuildPackage('cdk'); export const materialPackage = new BuildPackage('material', [cdkPackage]); export const examplesPackage = new BuildPackage('material-examples', [materialPackage, cdkPackage]); +export const momentAdapterPackage = new BuildPackage('material-moment-adapter', + [materialPackage, cdkPackage]); // To avoid refactoring of the project the material package will map to the source path `lib/`. materialPackage.packageRoot = join(buildConfig.packagesDir, 'lib'); diff --git a/tools/gulp/tasks/examples.ts b/tools/gulp/tasks/examples.ts index 2a2a592610b..716292abe99 100644 --- a/tools/gulp/tasks/examples.ts +++ b/tools/gulp/tasks/examples.ts @@ -34,7 +34,7 @@ const examplesPath = path.join(packagesDir, 'material-examples'); /** Output path of the module that is being created */ const outputModuleFilename = path.join(examplesPath, 'example-module.ts'); -/** Build ecmascript module import statements */ +/** Build ES module import statements */ function buildImportsTemplate(metadata: ExampleMetadata): string { const components = metadata.additionalComponents.concat(metadata.component); diff --git a/tools/gulp/tasks/publish.ts b/tools/gulp/tasks/publish.ts index a0614e3056a..0b8a52879d6 100644 --- a/tools/gulp/tasks/publish.ts +++ b/tools/gulp/tasks/publish.ts @@ -11,6 +11,7 @@ import * as minimist from 'minimist'; export const releasePackages = [ 'cdk', 'material', + 'material-moment-adapter' ]; /** Parse command-line arguments for release task. */ diff --git a/tools/gulp/tasks/unit-test.ts b/tools/gulp/tasks/unit-test.ts index 642a03b37fc..210f0f8b092 100644 --- a/tools/gulp/tasks/unit-test.ts +++ b/tools/gulp/tasks/unit-test.ts @@ -10,8 +10,9 @@ const {packagesDir, projectDir} = buildConfig; /** Builds everything that is necessary for karma. */ task(':test:build', sequenceTask( 'clean', - // Build ESM output of Material that also includes all test files. - 'material:build-tests', + // Build tests for all different packages by just building the tests of the moment-adapter + // package. All dependencies of that package (material, cdk) will be built as well. + 'material-moment-adapter:build-tests' )); /** @@ -20,7 +21,7 @@ task(':test:build', sequenceTask( */ task('test:single-run', [':test:build'], (done: () => void) => { // Load karma not outside. Karma pollutes Promise with a different implementation. - let karma = require('karma'); + const karma = require('karma'); new karma.Server({ configFile: join(projectDir, 'test/karma.conf.js'), @@ -44,12 +45,12 @@ task('test:single-run', [':test:build'], (done: () => void) => { * This task should be used when running unit tests locally. */ task('test', [':test:build'], () => { - let patternRoot = join(packagesDir, '**/*'); + const patternRoot = join(packagesDir, '**/*'); // Load karma not outside. Karma pollutes Promise with a different implementation. - let karma = require('karma'); + const karma = require('karma'); // Configure the Karma server and override the autoWatch and singleRun just in case. - let server = new karma.Server({ + const server = new karma.Server({ configFile: join(projectDir, 'test/karma.conf.js'), autoWatch: false, singleRun: false @@ -57,7 +58,7 @@ task('test', [':test:build'], () => { // Refreshes Karma's file list and schedules a test run. // Tests will only run if TypeScript compilation was successful. - let runTests = (err?: Error) => { + const runTests = (err?: Error) => { if (!err) { server.refreshFiles().then(() => server._injector.get('executor').schedule()); }