From 1c533c913d8377dd124258b95c9c529b237479a6 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Mon, 16 Jul 2018 22:52:59 +0300 Subject: [PATCH] build(docs-infra): add support for examples of type `elements` (#24840) Examples using `@angular/elements` need to transpile to es2015 for Custom Elements to work (on browsers that natively support them). Alternatively, a polyfill would need to be loaded. For now, changing the transpilation target to es2015 is the simplest solution. PR Close #24840 --- .../examples/elements/example-config.json | 3 +++ aio/tools/examples/example-boilerplate.js | 13 ++++++++---- .../shared/boilerplate/elements/tsconfig.json | 20 +++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 aio/tools/examples/shared/boilerplate/elements/tsconfig.json diff --git a/aio/content/examples/elements/example-config.json b/aio/content/examples/elements/example-config.json index e69de29bb2..cc42921173 100644 --- a/aio/content/examples/elements/example-config.json +++ b/aio/content/examples/elements/example-config.json @@ -0,0 +1,3 @@ +{ + "projectType": "elements" +} diff --git a/aio/tools/examples/example-boilerplate.js b/aio/tools/examples/example-boilerplate.js index 4f4c7bedf3..773b37aea6 100644 --- a/aio/tools/examples/example-boilerplate.js +++ b/aio/tools/examples/example-boilerplate.js @@ -50,13 +50,12 @@ const BOILERPLATE_PATHS = { // This maps the CLI files that exists in a parent folder const cliRelativePath = BOILERPLATE_PATHS.cli.map(file => `../cli/${file}`); -BOILERPLATE_PATHS.i18n = [ +BOILERPLATE_PATHS.elements = [ ...cliRelativePath, - 'angular.json', - 'package.json' + 'tsconfig.json' ]; -BOILERPLATE_PATHS.universal = [ +BOILERPLATE_PATHS.i18n = [ ...cliRelativePath, 'angular.json', 'package.json' @@ -67,6 +66,12 @@ BOILERPLATE_PATHS.testing = [ 'angular.json' ]; +BOILERPLATE_PATHS.universal = [ + ...cliRelativePath, + 'angular.json', + 'package.json' +]; + const EXAMPLE_CONFIG_FILENAME = 'example-config.json'; class ExampleBoilerPlate { diff --git a/aio/tools/examples/shared/boilerplate/elements/tsconfig.json b/aio/tools/examples/shared/boilerplate/elements/tsconfig.json new file mode 100644 index 0000000000..1a4f29fa89 --- /dev/null +++ b/aio/tools/examples/shared/boilerplate/elements/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "es2015", // Custom Elements require ES2015 classes (or polyfill). + "skipLibCheck": true, + "typeRoots": [ + "node_modules/@types" + ], + "lib": [ + "es2017", + "dom" + ] + } +}