From 986613639114a3dd672574ca18b0bb509812747d Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Wed, 22 Aug 2018 13:06:27 -0700 Subject: [PATCH] feat: enable support for typescript references - add script to build typescript project references - reorg project layout for better typescript refs - switch to tsconfig.json - add copy-resources script --- benchmark/index.ts | 6 - benchmark/package.json | 3 +- benchmark/tsconfig.build.json | 8 -- benchmark/tsconfig.json | 28 ++++ bin/update-project-refs.js | 122 ++++++++++++++++++ docs/package.json | 3 - docs/site/Testing-your-application.md | 19 ++- .../express-composition/tsconfig.build.json | 8 -- examples/hello-world/index.d.ts | 6 - examples/hello-world/index.ts | 8 -- examples/hello-world/package.json | 4 +- examples/hello-world/tsconfig.build.json | 8 -- examples/hello-world/tsconfig.json | 25 ++++ examples/log-extension/index.d.ts | 6 - examples/log-extension/index.ts | 6 - examples/log-extension/package.json | 4 +- examples/log-extension/tsconfig.build.json | 8 -- examples/log-extension/tsconfig.json | 31 +++++ examples/rpc-server/index.d.ts | 6 - examples/rpc-server/index.ts | 11 -- examples/rpc-server/package.json | 4 +- examples/rpc-server/tsconfig.json | 28 ++-- examples/soap-calculator/index.d.ts | 5 - examples/soap-calculator/index.ts | 1 - examples/soap-calculator/package.json | 6 +- examples/soap-calculator/tsconfig.build.json | 8 -- examples/soap-calculator/tsconfig.json | 43 ++++++ examples/todo-list/index.d.ts | 6 - examples/todo-list/index.ts | 8 -- examples/todo-list/package.json | 4 +- examples/todo-list/tsconfig.build.json | 8 -- examples/todo-list/tsconfig.json | 49 +++++++ examples/todo/index.d.ts | 6 - examples/todo/index.ts | 8 -- examples/todo/package.json | 4 +- examples/todo/src/index.ts | 3 +- examples/todo/tsconfig.build.json | 8 -- examples/todo/tsconfig.json | 49 +++++++ lerna.json | 2 +- package.json | 6 +- packages/authentication/index.d.ts | 6 - packages/authentication/index.ts | 8 -- packages/authentication/package.json | 2 + packages/authentication/tsconfig.build.json | 8 -- packages/authentication/tsconfig.json | 37 ++++++ packages/boot/index.d.ts | 6 - packages/boot/index.ts | 6 - packages/boot/package.json | 2 + packages/boot/tsconfig.build.json | 8 -- packages/boot/tsconfig.json | 37 ++++++ packages/build/README.md | 2 +- packages/build/bin/compile-package.js | 61 +++++---- packages/build/bin/copy-resources.js | 80 ++++++++++++ packages/build/bin/run-mocha.js | 2 +- packages/build/bin/utils.js | 41 +++++- packages/build/config/tsconfig.build.json | 7 +- packages/build/config/tsconfig.common.json | 8 +- .../{src => lib}/fail-on-console-logs.js | 0 packages/build/package.json | 1 + .../test/integration/scripts.integration.js | 24 ++++ packages/cli/bin/download-connector-list.js | 2 +- .../extension/templates/index.d.ts.ejs | 1 - .../generators/project/templates/index.ts.ejs | 1 - .../project/templates/package.json.ejs | 3 +- .../project/templates/tsconfig.json.ejs | 8 +- packages/cli/package.json | 7 +- .../cli/test/acceptance/app-run.acceptance.js | 2 +- packages/context/index.d.ts | 6 - packages/context/index.ts | 8 -- packages/context/package.json | 2 + packages/context/src/inject.ts | 2 +- packages/context/tsconfig.build.json | 8 -- packages/context/tsconfig.json | 22 ++++ packages/core/index.d.ts | 6 - packages/core/index.ts | 8 -- packages/core/package.json | 2 + packages/core/tsconfig.build.json | 8 -- packages/core/tsconfig.json | 22 ++++ packages/http-caching-proxy/index.d.ts | 6 - packages/http-caching-proxy/index.ts | 8 -- packages/http-caching-proxy/package.json | 2 + .../http-caching-proxy/tsconfig.build.json | 8 -- packages/http-caching-proxy/tsconfig.json | 19 +++ packages/http-server/index.d.ts | 1 - packages/http-server/index.ts | 6 - packages/http-server/package.json | 2 + packages/http-server/tsconfig.build.json | 8 -- packages/http-server/tsconfig.json | 22 ++++ packages/metadata/index.d.ts | 6 - packages/metadata/index.ts | 8 -- packages/metadata/package.json | 2 + packages/metadata/tsconfig.build.json | 8 -- packages/metadata/tsconfig.json | 19 +++ packages/openapi-spec-builder/index.d.ts | 6 - packages/openapi-spec-builder/index.ts | 8 -- packages/openapi-spec-builder/package.json | 2 + .../openapi-spec-builder/tsconfig.build.json | 8 -- packages/openapi-spec-builder/tsconfig.json | 19 +++ packages/openapi-v3-types/index.d.ts | 6 - packages/openapi-v3-types/index.ts | 8 -- packages/openapi-v3-types/package.json | 2 + packages/openapi-v3-types/tsconfig.build.json | 8 -- packages/openapi-v3-types/tsconfig.json | 19 +++ packages/openapi-v3/index.d.ts | 6 - packages/openapi-v3/index.ts | 8 -- packages/openapi-v3/package.json | 2 + packages/openapi-v3/tsconfig.build.json | 8 -- packages/openapi-v3/tsconfig.json | 34 +++++ packages/repository-json-schema/index.d.ts | 6 - packages/repository-json-schema/index.ts | 8 -- packages/repository-json-schema/package.json | 2 + .../tsconfig.build.json | 8 -- packages/repository-json-schema/tsconfig.json | 28 ++++ packages/repository/index.d.ts | 6 - packages/repository/index.ts | 8 -- packages/repository/package.json | 2 + .../customer-with-class-di.controller.ts | 0 ...customer-with-constructor-di.controller.ts | 0 .../customer-with-property-di.controller.ts | 0 .../juggler-bridge/note-with-repo-class.ts | 0 .../juggler-bridge/note-with-repo-instance.ts | 0 .../__examples__}/models/address.model.ts | 0 .../models/customer.definition.js | 0 .../__examples__}/models/customer.model.ts | 0 .../__examples__}/models/order.model.ts | 0 .../repositories/customer.repository.ts | 0 packages/repository/tsconfig.build.json | 8 -- packages/repository/tsconfig.json | 25 ++++ packages/rest-explorer/index.d.ts | 6 - packages/rest-explorer/index.ts | 8 -- packages/rest-explorer/package.json | 1 + packages/rest-explorer/tsconfig.build.json | 8 -- packages/rest-explorer/tsconfig.json | 28 ++++ packages/rest/index.d.ts | 6 - packages/rest/index.ts | 8 -- packages/rest/package.json | 2 + packages/rest/tsconfig.build.json | 8 -- packages/rest/tsconfig.json | 40 ++++++ packages/service-proxy/index.d.ts | 6 - packages/service-proxy/index.ts | 8 -- packages/service-proxy/package.json | 3 +- packages/service-proxy/tsconfig.build.json | 8 -- packages/service-proxy/tsconfig.json | 25 ++++ packages/testlab/index.d.ts | 6 - packages/testlab/index.ts | 8 -- packages/testlab/package.json | 2 + packages/testlab/tsconfig.build.json | 8 -- packages/testlab/tsconfig.json | 15 +++ tsconfig.json | 85 ++++++++++-- 149 files changed, 1118 insertions(+), 581 deletions(-) delete mode 100644 benchmark/index.ts delete mode 100644 benchmark/tsconfig.build.json create mode 100644 benchmark/tsconfig.json create mode 100755 bin/update-project-refs.js delete mode 100644 examples/express-composition/tsconfig.build.json delete mode 100644 examples/hello-world/index.d.ts delete mode 100644 examples/hello-world/index.ts delete mode 100644 examples/hello-world/tsconfig.build.json create mode 100644 examples/hello-world/tsconfig.json delete mode 100644 examples/log-extension/index.d.ts delete mode 100644 examples/log-extension/index.ts delete mode 100644 examples/log-extension/tsconfig.build.json create mode 100644 examples/log-extension/tsconfig.json delete mode 100644 examples/rpc-server/index.d.ts delete mode 100644 examples/rpc-server/index.ts delete mode 100644 examples/soap-calculator/index.d.ts delete mode 100644 examples/soap-calculator/index.ts delete mode 100644 examples/soap-calculator/tsconfig.build.json create mode 100644 examples/soap-calculator/tsconfig.json delete mode 100644 examples/todo-list/index.d.ts delete mode 100644 examples/todo-list/index.ts delete mode 100644 examples/todo-list/tsconfig.build.json create mode 100644 examples/todo-list/tsconfig.json delete mode 100644 examples/todo/index.d.ts delete mode 100644 examples/todo/index.ts delete mode 100644 examples/todo/tsconfig.build.json create mode 100644 examples/todo/tsconfig.json delete mode 100644 packages/authentication/index.d.ts delete mode 100644 packages/authentication/index.ts delete mode 100644 packages/authentication/tsconfig.build.json create mode 100644 packages/authentication/tsconfig.json delete mode 100644 packages/boot/index.d.ts delete mode 100644 packages/boot/index.ts delete mode 100644 packages/boot/tsconfig.build.json create mode 100644 packages/boot/tsconfig.json create mode 100755 packages/build/bin/copy-resources.js rename packages/build/{src => lib}/fail-on-console-logs.js (100%) delete mode 100644 packages/cli/generators/extension/templates/index.d.ts.ejs delete mode 100644 packages/cli/generators/project/templates/index.ts.ejs delete mode 100644 packages/context/index.d.ts delete mode 100644 packages/context/index.ts delete mode 100644 packages/context/tsconfig.build.json create mode 100644 packages/context/tsconfig.json delete mode 100644 packages/core/index.d.ts delete mode 100644 packages/core/index.ts delete mode 100644 packages/core/tsconfig.build.json create mode 100644 packages/core/tsconfig.json delete mode 100644 packages/http-caching-proxy/index.d.ts delete mode 100644 packages/http-caching-proxy/index.ts delete mode 100644 packages/http-caching-proxy/tsconfig.build.json create mode 100644 packages/http-caching-proxy/tsconfig.json delete mode 100644 packages/http-server/index.d.ts delete mode 100644 packages/http-server/index.ts delete mode 100644 packages/http-server/tsconfig.build.json create mode 100644 packages/http-server/tsconfig.json delete mode 100644 packages/metadata/index.d.ts delete mode 100644 packages/metadata/index.ts delete mode 100644 packages/metadata/tsconfig.build.json create mode 100644 packages/metadata/tsconfig.json delete mode 100644 packages/openapi-spec-builder/index.d.ts delete mode 100644 packages/openapi-spec-builder/index.ts delete mode 100644 packages/openapi-spec-builder/tsconfig.build.json create mode 100644 packages/openapi-spec-builder/tsconfig.json delete mode 100644 packages/openapi-v3-types/index.d.ts delete mode 100644 packages/openapi-v3-types/index.ts delete mode 100644 packages/openapi-v3-types/tsconfig.build.json create mode 100644 packages/openapi-v3-types/tsconfig.json delete mode 100644 packages/openapi-v3/index.d.ts delete mode 100644 packages/openapi-v3/index.ts delete mode 100644 packages/openapi-v3/tsconfig.build.json create mode 100644 packages/openapi-v3/tsconfig.json delete mode 100644 packages/repository-json-schema/index.d.ts delete mode 100644 packages/repository-json-schema/index.ts delete mode 100644 packages/repository-json-schema/tsconfig.build.json create mode 100644 packages/repository-json-schema/tsconfig.json delete mode 100644 packages/repository/index.d.ts delete mode 100644 packages/repository/index.ts rename packages/repository/{examples => src/__examples__}/controllers/customer-with-class-di.controller.ts (100%) rename packages/repository/{examples => src/__examples__}/controllers/customer-with-constructor-di.controller.ts (100%) rename packages/repository/{examples => src/__examples__}/controllers/customer-with-property-di.controller.ts (100%) rename packages/repository/{examples => src/__examples__}/juggler-bridge/note-with-repo-class.ts (100%) rename packages/repository/{examples => src/__examples__}/juggler-bridge/note-with-repo-instance.ts (100%) rename packages/repository/{examples => src/__examples__}/models/address.model.ts (100%) rename packages/repository/{examples => src/__examples__}/models/customer.definition.js (100%) rename packages/repository/{examples => src/__examples__}/models/customer.model.ts (100%) rename packages/repository/{examples => src/__examples__}/models/order.model.ts (100%) rename packages/repository/{examples => src/__examples__}/repositories/customer.repository.ts (100%) delete mode 100644 packages/repository/tsconfig.build.json create mode 100644 packages/repository/tsconfig.json delete mode 100644 packages/rest-explorer/index.d.ts delete mode 100644 packages/rest-explorer/index.ts delete mode 100644 packages/rest-explorer/tsconfig.build.json create mode 100644 packages/rest-explorer/tsconfig.json delete mode 100644 packages/rest/index.d.ts delete mode 100644 packages/rest/index.ts delete mode 100644 packages/rest/tsconfig.build.json create mode 100644 packages/rest/tsconfig.json delete mode 100644 packages/service-proxy/index.d.ts delete mode 100644 packages/service-proxy/index.ts delete mode 100644 packages/service-proxy/tsconfig.build.json create mode 100644 packages/service-proxy/tsconfig.json delete mode 100644 packages/testlab/index.d.ts delete mode 100644 packages/testlab/index.ts delete mode 100644 packages/testlab/tsconfig.build.json create mode 100644 packages/testlab/tsconfig.json diff --git a/benchmark/index.ts b/benchmark/index.ts deleted file mode 100644 index 33c09f9f05fa..000000000000 --- a/benchmark/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/benchmark -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/benchmark/package.json b/benchmark/package.json index 656dbff60dfe..97ae84c0beba 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -8,12 +8,13 @@ "performance", "benchmark" ], - "main": "index.js", + "types": "./dist/index.d.ts", "engines": { "node": ">=8.9" }, "scripts": { "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean dist", "pretest": "npm run clean && npm run build", "test": "lb-mocha \"dist/__tests__\"", diff --git a/benchmark/tsconfig.build.json b/benchmark/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/benchmark/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/benchmark/tsconfig.json b/benchmark/tsconfig.json new file mode 100644 index 000000000000..e505519420f8 --- /dev/null +++ b/benchmark/tsconfig.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../packages/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../packages/testlab/tsconfig.json" + }, + { + "path": "../examples/todo/tsconfig.json" + }, + { + "path": "../packages/openapi-spec-builder/tsconfig.json" + }, + { + "path": "../packages/rest/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/bin/update-project-refs.js b/bin/update-project-refs.js new file mode 100755 index 000000000000..58e51c781bfc --- /dev/null +++ b/bin/update-project-refs.js @@ -0,0 +1,122 @@ +#!/usr/bin/env node +// Copyright IBM Corp. 2017,2018. All Rights Reserved. +// Node module: loopback-next +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + +/** + * This is an internal script to update TypeScript project references based on + * lerna's local package dependencies. + * + * See https://www.typescriptlang.org/docs/handbook/project-references.html + */ +'use strict'; + +const path = require('path'); +const fs = require('fs'); +const util = require('util'); +const debug = require('debug')('loopback:build'); +const buildUtils = require('../packages/build/bin/utils'); + +const Project = require('@lerna/project'); +const PackageGraph = require('@lerna/package-graph'); + +const TSCONFIG = 'tsconfig.json'; + +async function updateReferences(options) { + options = options || {}; + const dryRun = options.dryRun; + const project = new Project(process.cwd()); + const packages = await project.getPackages(); + + const rootRefs = []; + const graph = new PackageGraph(packages); + + for (const p of graph.values()) { + debug('Package %s', p.pkg.name); + const pkgLocation = p.pkg.location; + const tsconfigFile = path.join(pkgLocation, TSCONFIG); + // Skip non-typescript packages + if (!fs.existsSync(tsconfigFile)) { + debug('Skipping non-TS package: %s', p.pkg.name); + continue; + } + rootRefs.push({ + path: path.join(path.relative(project.rootPath, pkgLocation), TSCONFIG), + }); + const tsconfig = require(tsconfigFile); + const refs = []; + for (const d of p.localDependencies.keys()) { + const depPkg = graph.get(d); + // Skip non-typescript packages + if (!fs.existsSync(path.join(depPkg.pkg.location, TSCONFIG))) { + debug('Skipping non-TS dependency: %s', depPkg.pkg.name); + continue; + } + const relativePath = path.relative(pkgLocation, depPkg.pkg.location); + refs.push({path: path.join(relativePath, TSCONFIG)}); + } + tsconfig.compilerOptions = tsconfig.compilerOptions || {}; + // composite must be true for project refs + tsconfig.compilerOptions.composite = true; + // outDir & target have to be set in tsconfig instead of CLI for tsc -b + tsconfig.compilerOptions.target = + tsconfig.compilerOptions.target || buildUtils.getCompilationTarget(); + tsconfig.compilerOptions.outDir = + tsconfig.compilerOptions.outDir || + buildUtils.getDistribution(tsconfig.compilerOptions.target); + if (!tsconfig.include) { + // To include ts/json files + tsconfig.include = ['src/**/*', 'src/**/*.json']; + } + tsconfig.references = refs; + + // Convert to JSON + const tsconfigJson = JSON.stringify(tsconfig, null, 2); + + if (!dryRun) { + // Using `-f` to overwrite tsconfig.json + fs.writeFileSync(tsconfigFile, tsconfigJson + '\n', {encoding: 'utf-8'}); + debug('%s has been updated.', tsconfigFile); + } else { + // Otherwise write to console + debug(tsconfigJson); + console.log('%s', p.pkg.name); + refs.forEach(r => console.log(' %s', r.path)); + } + } + + const rootTsconfigFile = path.join(project.rootPath, 'tsconfig.json'); + const rootTsconfig = require(rootTsconfigFile); + rootTsconfig.compilerOptions = rootTsconfig.compilerOptions || {}; + rootTsconfig.compilerOptions.composite = true; + rootTsconfig.references = rootRefs; + + // Reset files/include/exclude. The root should use project references now. + rootTsconfig.files = []; + delete rootTsconfig.include; + delete rootTsconfig.exclude; + + // Convert to JSON + const rootTsconfigJson = JSON.stringify(rootTsconfig, null, 2); + if (!dryRun) { + // Using `-f` to overwrite tsconfig.json + fs.writeFileSync(rootTsconfigFile, rootTsconfigJson + '\n', { + encoding: 'utf-8', + }); + debug('%s has been updated.', rootTsconfigFile); + console.log('TypeScript project references have been updated.'); + } else { + debug(rootTsconfigJson); + console.log('\n%s', path.relative(project.rootPath, rootTsconfigFile)); + rootRefs.forEach(r => console.log(' %s', r.path)); + console.log( + '\nThis is a dry-run. Please use -f option to update tsconfig files.', + ); + } +} + +if (require.main === module) { + const dryRun = process.argv[2] !== '-f'; + updateReferences({dryRun}); +} diff --git a/docs/package.json b/docs/package.json index e1790bf58f69..81a489624e0e 100644 --- a/docs/package.json +++ b/docs/package.json @@ -7,9 +7,6 @@ "engines": { "node": ">=8.9" }, - "files": [ - "**/*" - ], "keywords": [ "LoopBack", "docs" diff --git a/docs/site/Testing-your-application.md b/docs/site/Testing-your-application.md index 7027a1236bbc..a066122e3e64 100644 --- a/docs/site/Testing-your-application.md +++ b/docs/site/Testing-your-application.md @@ -129,7 +129,7 @@ helper method; for example: {% include code-caption.html content="src/__tests__/helpers/database.helpers.ts" %} ```ts -import {ProductRepository, CategoryRepository} from '../../src/repositories'; +import {ProductRepository, CategoryRepository} from '../../repositories'; import {testdb} from '../fixtures/datasources/testdb.datasource'; export async function givenEmptyDatabase() { @@ -485,7 +485,7 @@ valid data to create a new model instance. {% include code-caption.html content="src/__tests__/unit/models/person.model.unit.ts" %} ```ts -import {Person} from '../../../src/models'; +import {Person} from '../../../models'; import {givenPersonData} from '../../helpers/database.helpers'; import {expect} from '@loopback/testlab'; @@ -576,7 +576,7 @@ import { givenEmptyDatabase, givenCategory, } from '../../helpers/database.helpers'; -import {CategoryRepository} from '../../../src/repositories'; +import {CategoryRepository} from '../../../repositories'; import {expect} from '@loopback/testlab'; import {testdb} from '../../fixtures/datasources/testdb.datasource'; @@ -609,8 +609,8 @@ ingredient. ```ts import {expect} from '@loopback/testlab'; import {givenEmptyDatabase, givenProduct} from '../../helpers/database.helpers'; -import {ProductController} from '../../../src/controllers'; -import {ProductRepository} from '../../../src/repositories'; +import {ProductController} from '../../../controllers'; +import {ProductRepository} from '../../../repositories'; import {testdb} from '../../fixtures/datasources/testdb.datasource'; describe('ProductController (integration)', () => { @@ -657,11 +657,8 @@ of the service proxy by invoking the provider. This helper should be typically invoked once before the integration test suite begins. ```ts -import { - GeoService, - GeoServiceProvider, -} from '../../src/services/geo.service.ts'; -import {GeoDataSource} from '../../src/datasources/geo.datasource.ts'; +import {GeoService, GeoServiceProvider} from '../../services/geo.service.ts'; +import {GeoDataSource} from '../../datasources/geo.datasource.ts'; describe('GeoService', () => { let service: GeoService; @@ -681,7 +678,7 @@ instance: ```ts import {merge} from 'lodash'; -import * as GEO_CODER_CONFIG from '../src/datasources/geo.datasource.json'; +import * as GEO_CODER_CONFIG from '../datasources/geo.datasource.json'; function givenGeoService() { const config = merge({}, GEO_CODER_CONFIG, { diff --git a/examples/express-composition/tsconfig.build.json b/examples/express-composition/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/examples/express-composition/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/examples/hello-world/index.d.ts b/examples/hello-world/index.d.ts deleted file mode 100644 index 5b23fa367144..000000000000 --- a/examples/hello-world/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/example-hello-world -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/hello-world/index.ts b/examples/hello-world/index.ts deleted file mode 100644 index c2a0bd622c11..000000000000 --- a/examples/hello-world/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/example-hello-world -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/examples/hello-world/package.json b/examples/hello-world/package.json index b0d123d6a256..22e61003ca9d 100644 --- a/examples/hello-world/package.json +++ b/examples/hello-world/package.json @@ -7,11 +7,13 @@ "node": ">=8.9" }, "author": "IBM Corp.", + "types": "./dist/index.d.ts", "scripts": { "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", - "build:watch": "lb-tsc es2017 --outDir dist --watch", + "build:resources": "lb-copy-resources", + "build:watch": "lb-tsc --watch", "clean": "lb-clean *example-hello-world*.tgz dist package api-docs", "verify": "npm pack && tar xf *example-hello-world*.tgz && tree package && npm run clean", "lint": "npm run prettier:check && npm run tslint", diff --git a/examples/hello-world/tsconfig.build.json b/examples/hello-world/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/examples/hello-world/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/examples/hello-world/tsconfig.json b/examples/hello-world/tsconfig.json new file mode 100644 index 000000000000..57664af2aa22 --- /dev/null +++ b/examples/hello-world/tsconfig.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../../packages/testlab/tsconfig.json" + }, + { + "path": "../../packages/core/tsconfig.json" + }, + { + "path": "../../packages/rest/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/examples/log-extension/index.d.ts b/examples/log-extension/index.d.ts deleted file mode 100644 index e31447d2ed98..000000000000 --- a/examples/log-extension/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/example-log-extension -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/log-extension/index.ts b/examples/log-extension/index.ts deleted file mode 100644 index a432cfe790e4..000000000000 --- a/examples/log-extension/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/example-log-extension -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/examples/log-extension/package.json b/examples/log-extension/package.json index 3777666438a4..29d4d2100560 100644 --- a/examples/log-extension/package.json +++ b/examples/log-extension/package.json @@ -7,10 +7,12 @@ "node": ">=8.9" }, "author": "IBM Corp.", + "types": "./dist/index.d.ts", "scripts": { "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", - "build:watch": "lb-tsc es2017 --outDir dist --watch", + "build:resources": "lb-copy-resources", + "build:watch": "lb-tsc --watch", "clean": "lb-clean *example-log-extension-*.tgz dist package api-docs", "lint": "npm run prettier:check && npm run tslint", "lint:fix": "npm run tslint:fix && npm run prettier:fix", diff --git a/examples/log-extension/tsconfig.build.json b/examples/log-extension/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/examples/log-extension/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/examples/log-extension/tsconfig.json b/examples/log-extension/tsconfig.json new file mode 100644 index 000000000000..f4b252e8c1ef --- /dev/null +++ b/examples/log-extension/tsconfig.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../../packages/testlab/tsconfig.json" + }, + { + "path": "../../packages/context/tsconfig.json" + }, + { + "path": "../../packages/core/tsconfig.json" + }, + { + "path": "../../packages/openapi-v3/tsconfig.json" + }, + { + "path": "../../packages/rest/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/examples/rpc-server/index.d.ts b/examples/rpc-server/index.d.ts deleted file mode 100644 index 7186fd6eda1a..000000000000 --- a/examples/rpc-server/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/example-rpc-server -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/rpc-server/index.ts b/examples/rpc-server/index.ts deleted file mode 100644 index 3e1026e0d517..000000000000 --- a/examples/rpc-server/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/example-rpc-server -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// NOTE(bajtos) This file is used by TypeScript compiler to resolve imports -// from "test" files against original TypeScript sources in "src" directory. -// As a side effect, `tsc` also produces "dist/index.{js,d.ts,map} files -// that allow test files to import paths pointing to {src,test} root directory, -// which is project root for TS sources but "dist" for transpiled sources. -export * from './src'; diff --git a/examples/rpc-server/package.json b/examples/rpc-server/package.json index 6ed43a85aff2..cb5c8e8a4e98 100644 --- a/examples/rpc-server/package.json +++ b/examples/rpc-server/package.json @@ -9,10 +9,12 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "scripts": { "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", - "build:watch": "lb-tsc es2017 --outDir dist --watch", + "build:resources": "lb-copy-resources", + "build:watch": "lb-tsc --watch", "clean": "lb-clean dist", "lint": "npm run prettier:check && npm run tslint", "lint:fix": "npm run tslint:fix && npm run prettier:fix", diff --git a/examples/rpc-server/tsconfig.json b/examples/rpc-server/tsconfig.json index bc113b3ba923..81c1f70c7461 100644 --- a/examples/rpc-server/tsconfig.json +++ b/examples/rpc-server/tsconfig.json @@ -1,14 +1,24 @@ { "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "include": [ - "src", - "test", - "index.ts" + "extends": "@loopback/build/config/tsconfig.common.json", + "include": [ + "src/**/*", + "src/**/*.json" ], - "exclude": [ - "node_modules/**", - "packages/*/node_modules/**", - "**/*.d.ts" + "compilerOptions": { + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../../packages/testlab/tsconfig.json" + }, + { + "path": "../../packages/context/tsconfig.json" + }, + { + "path": "../../packages/core/tsconfig.json" + } ] } diff --git a/examples/soap-calculator/index.d.ts b/examples/soap-calculator/index.d.ts deleted file mode 100644 index 8a708ab9235e..000000000000 --- a/examples/soap-calculator/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/example-soap-calculator -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT -export * from './dist'; diff --git a/examples/soap-calculator/index.ts b/examples/soap-calculator/index.ts deleted file mode 100644 index 8420b1093fdb..000000000000 --- a/examples/soap-calculator/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './src'; diff --git a/examples/soap-calculator/package.json b/examples/soap-calculator/package.json index 88911d43e244..2dbff3c933a1 100644 --- a/examples/soap-calculator/package.json +++ b/examples/soap-calculator/package.json @@ -10,14 +10,16 @@ "soap" ], "main": "index.js", + "types": "./dist/index.d.ts", "engines": { - "node": ">=8" + "node": ">=8.9" }, "author": "IBM Corp.", "scripts": { "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", - "build:watch": "lb-tsc es2017 --outDir dist --watch", + "build:resources": "lb-copy-resources", + "build:watch": "lb-tsc --watch", "clean": "lb-clean *example-soap*.tgz dist package api-docs dist", "lint": "npm run prettier:check && npm run tslint", "lint:fix": "npm run tslint:fix && npm run prettier:fix", diff --git a/examples/soap-calculator/tsconfig.build.json b/examples/soap-calculator/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/examples/soap-calculator/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/examples/soap-calculator/tsconfig.json b/examples/soap-calculator/tsconfig.json new file mode 100644 index 000000000000..d13b82c1f559 --- /dev/null +++ b/examples/soap-calculator/tsconfig.json @@ -0,0 +1,43 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../../packages/testlab/tsconfig.json" + }, + { + "path": "../../packages/boot/tsconfig.json" + }, + { + "path": "../../packages/context/tsconfig.json" + }, + { + "path": "../../packages/core/tsconfig.json" + }, + { + "path": "../../packages/openapi-v3/tsconfig.json" + }, + { + "path": "../../packages/repository/tsconfig.json" + }, + { + "path": "../../packages/rest/tsconfig.json" + }, + { + "path": "../../packages/rest-explorer/tsconfig.json" + }, + { + "path": "../../packages/service-proxy/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/examples/todo-list/index.d.ts b/examples/todo-list/index.d.ts deleted file mode 100644 index 32b8c39950d7..000000000000 --- a/examples/todo-list/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/example-todo-list -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/todo-list/index.ts b/examples/todo-list/index.ts deleted file mode 100644 index 470092e3090d..000000000000 --- a/examples/todo-list/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/example-todo-list -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/examples/todo-list/package.json b/examples/todo-list/package.json index 01550f463dee..847b1bd83bf4 100644 --- a/examples/todo-list/package.json +++ b/examples/todo-list/package.json @@ -7,10 +7,12 @@ "node": ">=8.9" }, "author": "IBM Corp.", + "types": "./dist/index.d.ts", "scripts": { "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", - "build:watch": "lb-tsc es2017 --outDir dist --watch", + "build:resources": "lb-copy-resources", + "build:watch": "lb-tsc --watch", "clean": "lb-clean *example-todo-list*.tgz dist package api-docs", "lint": "npm run prettier:check && npm run tslint", "lint:fix": "npm run tslint:fix && npm run prettier:fix", diff --git a/examples/todo-list/tsconfig.build.json b/examples/todo-list/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/examples/todo-list/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/examples/todo-list/tsconfig.json b/examples/todo-list/tsconfig.json new file mode 100644 index 000000000000..76f5b7a9cfb4 --- /dev/null +++ b/examples/todo-list/tsconfig.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../../packages/http-caching-proxy/tsconfig.json" + }, + { + "path": "../../packages/testlab/tsconfig.json" + }, + { + "path": "../../packages/boot/tsconfig.json" + }, + { + "path": "../../packages/context/tsconfig.json" + }, + { + "path": "../../packages/core/tsconfig.json" + }, + { + "path": "../../packages/openapi-v3/tsconfig.json" + }, + { + "path": "../../packages/openapi-v3-types/tsconfig.json" + }, + { + "path": "../../packages/repository/tsconfig.json" + }, + { + "path": "../../packages/rest/tsconfig.json" + }, + { + "path": "../../packages/rest-explorer/tsconfig.json" + }, + { + "path": "../../packages/service-proxy/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/examples/todo/index.d.ts b/examples/todo/index.d.ts deleted file mode 100644 index e6b3921eb310..000000000000 --- a/examples/todo/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/example-todo -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/todo/index.ts b/examples/todo/index.ts deleted file mode 100644 index 81b598876805..000000000000 --- a/examples/todo/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/example-todo -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/examples/todo/package.json b/examples/todo/package.json index 553dcb984151..9a5897425fce 100644 --- a/examples/todo/package.json +++ b/examples/todo/package.json @@ -7,10 +7,12 @@ "node": ">=8.9" }, "author": "IBM Corp.", + "types": "./dist/index.d.ts", "scripts": { "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", - "build:watch": "lb-tsc es2017 --outDir dist --watch", + "build:resources": "lb-copy-resources", + "build:watch": "lb-tsc --watch", "clean": "lb-clean *example-todo*.tgz dist package api-docs", "lint": "npm run prettier:check && npm run tslint", "lint:fix": "npm run tslint:fix && npm run prettier:fix", diff --git a/examples/todo/src/index.ts b/examples/todo/src/index.ts index b9aa29212ff7..02edea01c503 100644 --- a/examples/todo/src/index.ts +++ b/examples/todo/src/index.ts @@ -17,8 +17,7 @@ export async function main(options: ApplicationConfig = {}) { } // re-exports for our benchmark, not needed for the tutorial itself -export {TodoListApplication}; +export * from './application'; export * from './models'; export * from './repositories'; -export * from '@loopback/rest'; diff --git a/examples/todo/tsconfig.build.json b/examples/todo/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/examples/todo/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/examples/todo/tsconfig.json b/examples/todo/tsconfig.json new file mode 100644 index 000000000000..76f5b7a9cfb4 --- /dev/null +++ b/examples/todo/tsconfig.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../../packages/http-caching-proxy/tsconfig.json" + }, + { + "path": "../../packages/testlab/tsconfig.json" + }, + { + "path": "../../packages/boot/tsconfig.json" + }, + { + "path": "../../packages/context/tsconfig.json" + }, + { + "path": "../../packages/core/tsconfig.json" + }, + { + "path": "../../packages/openapi-v3/tsconfig.json" + }, + { + "path": "../../packages/openapi-v3-types/tsconfig.json" + }, + { + "path": "../../packages/repository/tsconfig.json" + }, + { + "path": "../../packages/rest/tsconfig.json" + }, + { + "path": "../../packages/rest-explorer/tsconfig.json" + }, + { + "path": "../../packages/service-proxy/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/lerna.json b/lerna.json index 8c8b9ef7efa5..ed5e0d3f3d14 100644 --- a/lerna.json +++ b/lerna.json @@ -23,7 +23,7 @@ "loglevel": "silent", "stream": true, "concurrency": 8, - "sort": false + "sort": true }, "clean": { "loglevel": "silent", diff --git a/package.json b/package.json index b12aada2bf50..15d84474f4ff 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "typescript": "^3.3.1" }, "scripts": { - "postinstall": "lerna bootstrap && npm run -s update-greenkeeper-json", + "postinstall": "lerna bootstrap && node bin/update-project-refs -f && npm run -s update-greenkeeper-json", "prerelease": "npm run build:full && npm run mocha && npm run lint", "release": "lerna version && lerna publish from-git --yes", "update-template-deps": "node bin/update-template-deps -f", @@ -44,7 +44,9 @@ "prettier:fix": "npm run prettier:cli -- --write", "clean": "lerna run clean && node packages/build/bin/run-clean \"packages/*/dist\" \"examples/*/dist\" \"benchmark/dist\"", "clean:lerna": "lerna clean", - "build": "node bin/run-lerna run build", + "build": "node packages/build/bin/compile-package -b --force && npm run build:resources", + "build:resources": "node bin/run-lerna run build:resources -- -s", + "build:dev": "node packages/build/bin/compile-package -b && npm run build:resources", "build:full": "npm run clean:lerna && npm install && npm run clean && npm run build", "pretest": "npm run clean && npm run build", "test": "node packages/build/bin/run-nyc npm run mocha --scripts-prepend-node-path", diff --git a/packages/authentication/index.d.ts b/packages/authentication/index.d.ts deleted file mode 100644 index daf48757e0b0..000000000000 --- a/packages/authentication/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/authentication -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/authentication/index.ts b/packages/authentication/index.ts deleted file mode 100644 index cfa02be87a2f..000000000000 --- a/packages/authentication/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/authentication -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/authentication/package.json b/packages/authentication/package.json index 826c28d156b8..e5c8bbdc90af 100644 --- a/packages/authentication/package.json +++ b/packages/authentication/package.json @@ -5,10 +5,12 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "scripts": { "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-authentication*.tgz dist package api-docs", "integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"", "pretest": "npm run build", diff --git a/packages/authentication/tsconfig.build.json b/packages/authentication/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/authentication/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/authentication/tsconfig.json b/packages/authentication/tsconfig.json new file mode 100644 index 000000000000..ea4ef9325dbe --- /dev/null +++ b/packages/authentication/tsconfig.json @@ -0,0 +1,37 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../openapi-spec-builder/tsconfig.json" + }, + { + "path": "../testlab/tsconfig.json" + }, + { + "path": "../context/tsconfig.json" + }, + { + "path": "../core/tsconfig.json" + }, + { + "path": "../metadata/tsconfig.json" + }, + { + "path": "../openapi-v3/tsconfig.json" + }, + { + "path": "../rest/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/boot/index.d.ts b/packages/boot/index.d.ts deleted file mode 100644 index a298c01feb0e..000000000000 --- a/packages/boot/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/boot -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/boot/index.ts b/packages/boot/index.ts deleted file mode 100644 index e1819c75d561..000000000000 --- a/packages/boot/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/boot -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/packages/boot/package.json b/packages/boot/package.json index 246f4712faf8..9e932814516e 100644 --- a/packages/boot/package.json +++ b/packages/boot/package.json @@ -5,6 +5,7 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "publishConfig": { "access": "public" }, @@ -12,6 +13,7 @@ "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-boot*.tgz dist package api-docs", "pretest": "npm run build", "integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"", diff --git a/packages/boot/tsconfig.build.json b/packages/boot/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/boot/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/boot/tsconfig.json b/packages/boot/tsconfig.json new file mode 100644 index 000000000000..e492ec42754b --- /dev/null +++ b/packages/boot/tsconfig.json @@ -0,0 +1,37 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../openapi-v3/tsconfig.json" + }, + { + "path": "../rest/tsconfig.json" + }, + { + "path": "../testlab/tsconfig.json" + }, + { + "path": "../context/tsconfig.json" + }, + { + "path": "../core/tsconfig.json" + }, + { + "path": "../repository/tsconfig.json" + }, + { + "path": "../service-proxy/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/build/README.md b/packages/build/README.md index 5b9b97ec0ab9..5ec461992ffb 100644 --- a/packages/build/README.md +++ b/packages/build/README.md @@ -81,7 +81,7 @@ Now you run the scripts, such as: } ``` - - Set options explicity for the script + - Set options explicitly for the script ```sh lb-tsc -p tsconfig.json --target es2017 --outDir dist diff --git a/packages/build/bin/compile-package.js b/packages/build/bin/compile-package.js index 1152b0beef6b..7e1eac0f224d 100755 --- a/packages/build/bin/compile-package.js +++ b/packages/build/bin/compile-package.js @@ -10,7 +10,7 @@ Usage: node ./bin/compile-package -Where is one of es2015, es2017 or es2018. +Where is one of es2015, es2017 or es2017. ======== */ @@ -21,8 +21,13 @@ function run(argv, options) { const utils = require('./utils'); const path = require('path'); const fs = require('fs'); - const glob = require('glob'); - const fse = require('fs-extra'); + const copyResources = require('./copy-resources'); + + if (options === true) { + options = {dryRun: true}; + } else { + options = options || {}; + } const packageDir = utils.getPackageDir(); @@ -36,6 +41,11 @@ function run(argv, options) { '--copy-resources', ); + // Honor --dry from tsc + if (utils.isOptionSet(compilerOpts, '--dry')) { + options.dryRun = true; + } + var target; // --copy-resources is not a TS Compiler option so we remove it from the @@ -101,13 +111,11 @@ function run(argv, options) { JSON.stringify( { extends: baseConfigFile, - include: ['src', 'test'], - exclude: [ - 'node_modules/**', - 'packages/*/node_modules/**', - 'examples/*/node_modules/**', - '**/*.d.ts', - ], + compilerOptions: { + target: 'es2017', + outDir: 'dist', + }, + exclude: ['**/*.d.ts'], }, null, ' ', @@ -132,15 +140,12 @@ function run(argv, options) { // to the same outDir as well. if (rootDir && tsConfigFile && isCopyResourcesSet) { const tsConfig = require(tsConfigFile); - const dirs = tsConfig.include - ? tsConfig.include.join('|') - : ['src', 'test'].join('|'); - - const pattern = `@(${dirs})/**/!(*.ts)`; - const files = glob.sync(pattern, {root: packageDir, nodir: true}); - for (const file of files) { - fse.copySync(path.join(packageDir, file), path.join(outDir, file)); - } + const rootDir = + (tsConfig.compilerOptions && tsConfig.compilerOptions.rootDir) || 'src'; + copyResources( + [argv[0], argv[1], '--rootDir', rootDir, '--outDir', outDir], + options, + ); } } @@ -150,11 +155,21 @@ function run(argv, options) { args.push(...compilerOpts); - if (options === true) { - options = {dryRun: true}; - } else { - options = options || {}; + // Move --build or -b as the 1st argument to avoid: + // error TS6369: Option '--build' must be the first command line argument. + const buildOptions = utils.removeOptions(args, '-b', '--build'); + if (buildOptions.length) { + let projectOptions = utils.removeOptions(args, '-p', '--project'); + projectOptions = projectOptions.filter(p => !p.startsWith('-')); + // Remove conflict options with '--build' + utils.removeOptions(args, '--outDir', '--target'); + if (buildOptions.length === 1) { + args.unshift(...buildOptions, ...projectOptions); + } else { + args.unshift(...buildOptions); + } } + return utils.runCLI('typescript/lib/tsc', args, {cwd, ...options}); } diff --git a/packages/build/bin/copy-resources.js b/packages/build/bin/copy-resources.js new file mode 100755 index 000000000000..d47c64219c74 --- /dev/null +++ b/packages/build/bin/copy-resources.js @@ -0,0 +1,80 @@ +#!/usr/bin/env node +// Copyright IBM Corp. 2017,2018. All Rights Reserved. +// Node module: @loopback/build +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + +/* +======== + +Usage: + node ./bin/copy-resources + +======== +*/ + +'use strict'; + +function run(argv, options) { + const utils = require('./utils'); + const path = require('path'); + const util = require('util'); + const glob = require('glob'); + const fse = require('fs-extra'); + const debug = require('debug')('loopback:build'); + + if (options === true) { + options = {dryRun: true}; + } else { + options = options || {}; + } + + const packageDir = utils.getPackageDir(); + + const copyOpts = argv.slice(2); + + // Honor --dry from tsc + if (utils.isOptionSet(copyOpts, '--dry')) { + options.dryRun = true; + } + + var outDir = utils.getOptionValue(copyOpts, 'outDir'); + var rootDir = utils.getOptionValue(copyOpts, 'rootDir'); + + if (!outDir || !rootDir) { + const tsConfigFile = utils.getConfigFile( + 'tsconfig.build.json', + 'tsconfig.json', + ); + if (tsConfigFile) { + debug('Loading tsconfig from %s', tsConfigFile); + const tsConfig = require(tsConfigFile); + const compilerOptions = tsConfig.compilerOptions || {}; + debug('tsconfig compilerOptions %j', compilerOptions); + outDir = outDir || compilerOptions.outDir; + rootDir = rootDir || compilerOptions.rootDir; + } + } + debug('rootDir: %s, outDir: %s', rootDir, outDir); + + const pattern = `${rootDir}/**/!(*.ts)`; + const files = glob.sync(pattern, { + root: packageDir, + nodir: true, + }); + + for (const file of files) { + // Trim leading `src/` + const target = file.substr(`${rootDir}/`.length); + const sourceFile = path.resolve(packageDir, file); + const targetFile = path.resolve(packageDir, outDir, target); + debug('Copying %s to %s', sourceFile, targetFile); + if (!options.dryRun) fse.copySync(sourceFile, targetFile); + } + if (options.dryRun) { + return util.format('%s %s %s', argv[0], argv[1], copyOpts.join(' ')); + } +} + +module.exports = run; +if (require.main === module) run(process.argv); diff --git a/packages/build/bin/run-mocha.js b/packages/build/bin/run-mocha.js index 7a026bdac1dc..76caea8c851f 100755 --- a/packages/build/bin/run-mocha.js +++ b/packages/build/bin/run-mocha.js @@ -47,7 +47,7 @@ function run(argv, options) { mochaOpts.unshift( '--no-warnings', // Disable node.js warnings '--require', - require.resolve('../src/fail-on-console-logs'), + require.resolve('../lib/fail-on-console-logs'), ); } else { // Allow tests to print to console, remove --allow-console-logs argument diff --git a/packages/build/bin/utils.js b/packages/build/bin/utils.js index 2aed68dbf403..8515c4601b1f 100644 --- a/packages/build/bin/utils.js +++ b/packages/build/bin/utils.js @@ -17,7 +17,7 @@ const debug = require('debug')('loopback:build'); function getCompilationTarget() { const nodeMajorVersion = +process.versions.node.split('.')[0]; return nodeMajorVersion >= 10 - ? 'es2018' + ? 'es2017' : nodeMajorVersion >= 7 ? 'es2017' : 'es2015'; @@ -37,7 +37,7 @@ function getDistribution(target) { dist = 'dist10'; break; case 'es2017': - dist = 'dist8'; + dist = 'dist'; break; case 'es2015': dist = 'dist6'; @@ -228,6 +228,41 @@ function mochaConfiguredForProject() { }); } +/** + * Get the value of an option + * @param {string[]} opts Arguments + * @param {string} optionName Option name + */ +function getOptionValue(opts, optionName) { + for (let i = 0; i < opts.length; i++) { + if (opts[i] === `--${optionName}`) return opts[i + 1]; + if (opts[i].startsWith(`--${optionName}=`)) { + return opts.substring(`--${optionName}=`.length); + } + } + return undefined; +} + +/** + * Remove options and their values from args + */ +function removeOptions(args, ...options) { + const removed = []; + for (const e of options) { + const index = args.indexOf(e); + if (index !== -1) { + const next = args[index + 1]; + if (typeof next === 'string' && !next.startsWith('-')) { + // The next element is the value of the option, remove it too + removed.push(...args.splice(index, 2)); + } else { + removed.push(...args.splice(index, 1)); + } + } + } + return removed; +} + exports.getCompilationTarget = getCompilationTarget; exports.getDistribution = getDistribution; exports.getRootDir = getRootDir; @@ -238,3 +273,5 @@ exports.runCLI = runCLI; exports.runShell = runShell; exports.isOptionSet = isOptionSet; exports.mochaConfiguredForProject = mochaConfiguredForProject; +exports.getOptionValue = getOptionValue; +exports.removeOptions = removeOptions; diff --git a/packages/build/config/tsconfig.build.json b/packages/build/config/tsconfig.build.json index 5ac79d53dbc7..4509b6a7f6df 100644 --- a/packages/build/config/tsconfig.build.json +++ b/packages/build/config/tsconfig.build.json @@ -1,11 +1,8 @@ { "extends": "./tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src", + "outDir": "dist" }, - "include": [ - "src", - "test" - ], "exclude": ["node_modules/**", "**/*.d.ts"] } diff --git a/packages/build/config/tsconfig.common.json b/packages/build/config/tsconfig.common.json index 306a2ebaac19..c7c505e7f421 100644 --- a/packages/build/config/tsconfig.common.json +++ b/packages/build/config/tsconfig.common.json @@ -7,12 +7,14 @@ "strictNullChecks": true, "resolveJsonModule": true, "strictBindCallApply": true, + "skipLibCheck": true, - "lib": ["es2018", "dom", "esnext.asynciterable"], + "lib": ["es2017", "dom", "esnext.asynciterable"], "module": "commonjs", "moduleResolution": "node", - "target": "es2017", "sourceMap": true, - "declaration": true + "declaration": true, + "target": "es2017", + "composite": true } } diff --git a/packages/build/src/fail-on-console-logs.js b/packages/build/lib/fail-on-console-logs.js similarity index 100% rename from packages/build/src/fail-on-console-logs.js rename to packages/build/lib/fail-on-console-logs.js diff --git a/packages/build/package.json b/packages/build/package.json index 1aa553692f62..f3f0947693f6 100644 --- a/packages/build/package.json +++ b/packages/build/package.json @@ -32,6 +32,7 @@ }, "bin": { "lb-tsc": "./bin/compile-package.js", + "lb-copy-resources": "./bin/copy-resources.js", "lb-tslint": "./bin/run-tslint.js", "lb-prettier": "./bin/run-prettier.js", "lb-mocha": "./bin/run-mocha.js", diff --git a/packages/build/test/integration/scripts.integration.js b/packages/build/test/integration/scripts.integration.js index aa37d3d9df69..35158e9187cc 100644 --- a/packages/build/test/integration/scripts.integration.js +++ b/packages/build/test/integration/scripts.integration.js @@ -161,6 +161,30 @@ describe('build', function() { ); }); + it('honors --outDir option for copy-resources', () => { + var run = require('../../bin/copy-resources'); + var command = run( + ['node', 'bin/copy-resources', '--outDir', 'dist10'], + true, + ); + assert( + command.indexOf('--outDir dist10') !== -1, + '--outDir should be honored', + ); + }); + + it('honors --rootDir option for copy-resources', () => { + var run = require('../../bin/copy-resources'); + var command = run( + ['node', 'bin/copy-resources', '--rootDir', 'my-src'], + true, + ); + assert( + command.indexOf('--rootDir my-src') !== -1, + '--rootDir should be honored', + ); + }); + it('generates apidocs', done => { var run = require('../../bin/generate-apidocs'); var childProcess = run(['node', 'bin/generate-apidocs'], { diff --git a/packages/cli/bin/download-connector-list.js b/packages/cli/bin/download-connector-list.js index 0708f48a0f12..bca4a6f258ea 100644 --- a/packages/cli/bin/download-connector-list.js +++ b/packages/cli/bin/download-connector-list.js @@ -11,7 +11,7 @@ const URL = 'https://raw.githubusercontent.com/strongloop/loopback-workspace/master/available-connectors.json'; /** - * Function to dowload the list of available connectors from loopback-workspace + * Function to download the list of available connectors from loopback-workspace * so the list only has to be maintained in one place. */ async function download() { diff --git a/packages/cli/generators/extension/templates/index.d.ts.ejs b/packages/cli/generators/extension/templates/index.d.ts.ejs deleted file mode 100644 index 5703fb5fd91d..000000000000 --- a/packages/cli/generators/extension/templates/index.d.ts.ejs +++ /dev/null @@ -1 +0,0 @@ -export * from './dist'; diff --git a/packages/cli/generators/project/templates/index.ts.ejs b/packages/cli/generators/project/templates/index.ts.ejs deleted file mode 100644 index 8420b1093fdb..000000000000 --- a/packages/cli/generators/project/templates/index.ts.ejs +++ /dev/null @@ -1 +0,0 @@ -export * from './src'; diff --git a/packages/cli/generators/project/templates/package.json.ejs b/packages/cli/generators/project/templates/package.json.ejs index 87caf18d348f..079fe19d1b41 100644 --- a/packages/cli/generators/project/templates/package.json.ejs +++ b/packages/cli/generators/project/templates/package.json.ejs @@ -12,7 +12,8 @@ }, "scripts": { "build:apidocs": "lb-apidocs", - "build": "lb-tsc es2017 --outDir dist", + "build": "lb-tsc", + "build:resources": "lb-copy-resources", "build:watch": "lb-tsc --watch", "clean": "lb-clean dist", <% if (project.prettier && project.tslint) { -%> diff --git a/packages/cli/generators/project/templates/tsconfig.json.ejs b/packages/cli/generators/project/templates/tsconfig.json.ejs index e89fc7f68e4f..fcc4f2ec53b3 100644 --- a/packages/cli/generators/project/templates/tsconfig.json.ejs +++ b/packages/cli/generators/project/templates/tsconfig.json.ejs @@ -16,17 +16,17 @@ "strictNullChecks": true, "resolveJsonModule": true, - "lib": ["es2018", "dom", "esnext.asynciterable"], + "lib": ["es2017", "dom", "esnext.asynciterable"], "module": "commonjs", "moduleResolution": "node", "target": "es2017", "sourceMap": true, - "declaration": true + "declaration": true, + "rootDir": "src", + "outDir": "dist" }, "include": ["src"], "exclude": [ - "node_modules/**", - "packages/*/node_modules/**", "**/*.d.ts" ] <% } -%> diff --git a/packages/cli/package.json b/packages/cli/package.json index fd61b2224008..240a61860b64 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -7,11 +7,6 @@ "engines": { "node": ">=8.9" }, - "files": [ - "bin", - "lib", - "generators" - ], "bin": { "lb4": "bin/cli-main.js" }, @@ -63,7 +58,7 @@ "yeoman-generator": "^3.1.1" }, "scripts": { - "build": "node ./bin/download-connector-list.js", + "postinstall": "node ./bin/download-connector-list.js", "test": "lb-mocha \"test/**/*.js\"", "smoke-test": "lb-mocha --allow-console-logs \"smoke-test/**/*.smoke.js\"" }, diff --git a/packages/cli/test/acceptance/app-run.acceptance.js b/packages/cli/test/acceptance/app-run.acceptance.js index dec69b287a0b..139caa7eddf3 100644 --- a/packages/cli/test/acceptance/app-run.acceptance.js +++ b/packages/cli/test/acceptance/app-run.acceptance.js @@ -39,7 +39,7 @@ describe('app-generator (SLOW)', function() { // WARNING: It takes a while to run `lerna bootstrap` this.timeout(15 * 60 * 1000); process.chdir(rootDir); - await lernaBootstrap(appName); + await lernaBootstrap([appName, '@loopback/build']); }); it('passes `npm test` for the generated project', function() { diff --git a/packages/context/index.d.ts b/packages/context/index.d.ts deleted file mode 100644 index 5002bc7a32ab..000000000000 --- a/packages/context/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017. All Rights Reserved. -// Node module: @loopback/context -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/context/index.ts b/packages/context/index.ts deleted file mode 100644 index 1f0a8b5379a8..000000000000 --- a/packages/context/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/context -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/context/package.json b/packages/context/package.json index 7378ec1fe628..f927f75784fb 100644 --- a/packages/context/package.json +++ b/packages/context/package.json @@ -5,10 +5,12 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "scripts": { "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-context*.tgz dist package api-docs", "pretest": "npm run build", "test": "lb-mocha \"dist/__tests__/**/*.js\"", diff --git a/packages/context/src/inject.ts b/packages/context/src/inject.ts index 14b209a5205f..61b98e9bf749 100644 --- a/packages/context/src/inject.ts +++ b/packages/context/src/inject.ts @@ -378,7 +378,7 @@ export function describeInjectedArguments( if (method === '') { // A hacky way to check if an explicit constructor exists // See https://github.com/strongloop/loopback-next/issues/1565 - if (target.toString().match(/\s+constructor\s*\([^\)]*\)\s+\{/m)) { + if (target.toString().match(/\{\s*constructor\s*\([^\)]*\)\s*\{/m)) { options.ownMetadataOnly = true; } } else if (target.hasOwnProperty(method)) { diff --git a/packages/context/tsconfig.build.json b/packages/context/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/context/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/context/tsconfig.json b/packages/context/tsconfig.json new file mode 100644 index 000000000000..1244984c152b --- /dev/null +++ b/packages/context/tsconfig.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../testlab/tsconfig.json" + }, + { + "path": "../metadata/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/core/index.d.ts b/packages/core/index.d.ts deleted file mode 100644 index d4e09365e55e..000000000000 --- a/packages/core/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017. All Rights Reserved. -// Node module: @loopback/core -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/core/index.ts b/packages/core/index.ts deleted file mode 100644 index 71bc99caa28b..000000000000 --- a/packages/core/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/core -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/core/package.json b/packages/core/package.json index a6a1f3fc4df2..b7577301f6c1 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -5,10 +5,12 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "scripts": { "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-core*.tgz dist package api-docs", "pretest": "npm run build", "integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"", diff --git a/packages/core/tsconfig.build.json b/packages/core/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/core/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json new file mode 100644 index 000000000000..b4381559b6ef --- /dev/null +++ b/packages/core/tsconfig.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../testlab/tsconfig.json" + }, + { + "path": "../context/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/http-caching-proxy/index.d.ts b/packages/http-caching-proxy/index.d.ts deleted file mode 100644 index bb4a4c7072d5..000000000000 --- a/packages/http-caching-proxy/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/http-caching-proxy -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/http-caching-proxy/index.ts b/packages/http-caching-proxy/index.ts deleted file mode 100644 index 9ebbfd4057ca..000000000000 --- a/packages/http-caching-proxy/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/http-caching-proxy -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/http-caching-proxy/package.json b/packages/http-caching-proxy/package.json index 550eb51a4312..215fee94a4b8 100644 --- a/packages/http-caching-proxy/package.json +++ b/packages/http-caching-proxy/package.json @@ -5,9 +5,11 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "scripts": { "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-caching-proxy*.tgz dist package api-docs", "pretest": "npm run build", "test": "lb-mocha \"dist/__tests__/integration/**/*.js\"", diff --git a/packages/http-caching-proxy/tsconfig.build.json b/packages/http-caching-proxy/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/http-caching-proxy/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/http-caching-proxy/tsconfig.json b/packages/http-caching-proxy/tsconfig.json new file mode 100644 index 000000000000..0022628a4af7 --- /dev/null +++ b/packages/http-caching-proxy/tsconfig.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../testlab/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/http-server/index.d.ts b/packages/http-server/index.d.ts deleted file mode 100644 index 5703fb5fd91d..000000000000 --- a/packages/http-server/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './dist'; diff --git a/packages/http-server/index.ts b/packages/http-server/index.ts deleted file mode 100644 index 7c630f3a5b05..000000000000 --- a/packages/http-server/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/http-server -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/packages/http-server/package.json b/packages/http-server/package.json index bdca22d00788..a9eb9e1af73e 100644 --- a/packages/http-server/package.json +++ b/packages/http-server/package.json @@ -5,9 +5,11 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "scripts": { "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-http-server*.tgz dist package api-docs", "pretest": "npm run build", "test": "lb-mocha \"dist/__tests__/**/*.js\"", diff --git a/packages/http-server/tsconfig.build.json b/packages/http-server/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/http-server/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/http-server/tsconfig.json b/packages/http-server/tsconfig.json new file mode 100644 index 000000000000..cf26b61f8f85 --- /dev/null +++ b/packages/http-server/tsconfig.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../core/tsconfig.json" + }, + { + "path": "../testlab/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/metadata/index.d.ts b/packages/metadata/index.d.ts deleted file mode 100644 index 5ad88365eb71..000000000000 --- a/packages/metadata/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017. All Rights Reserved. -// Node module: @loopback/metadata -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/metadata/index.ts b/packages/metadata/index.ts deleted file mode 100644 index 04733da75432..000000000000 --- a/packages/metadata/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/metadata -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/metadata/package.json b/packages/metadata/package.json index d3115f1a678a..a243d972f0c7 100644 --- a/packages/metadata/package.json +++ b/packages/metadata/package.json @@ -5,10 +5,12 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "scripts": { "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-metadata*.tgz dist package api-docs", "pretest": "npm run build", "test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"", diff --git a/packages/metadata/tsconfig.build.json b/packages/metadata/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/metadata/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/metadata/tsconfig.json b/packages/metadata/tsconfig.json new file mode 100644 index 000000000000..0022628a4af7 --- /dev/null +++ b/packages/metadata/tsconfig.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../testlab/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/openapi-spec-builder/index.d.ts b/packages/openapi-spec-builder/index.d.ts deleted file mode 100644 index e6c72e4498a7..000000000000 --- a/packages/openapi-spec-builder/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017. All Rights Reserved. -// Node module: @loopback/openapi-spec-builder -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/openapi-spec-builder/index.ts b/packages/openapi-spec-builder/index.ts deleted file mode 100644 index 5bba0677741e..000000000000 --- a/packages/openapi-spec-builder/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/openapi-spec-builder -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/openapi-spec-builder/package.json b/packages/openapi-spec-builder/package.json index 97f50126834a..f67f05250f8e 100644 --- a/packages/openapi-spec-builder/package.json +++ b/packages/openapi-spec-builder/package.json @@ -5,9 +5,11 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "scripts": { "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-openapi-spec-builder*.tgz dist package api-docs", "verify": "npm pack && tar xf loopback-openapi-spec-builder*.tgz && tree package && npm run clean" }, diff --git a/packages/openapi-spec-builder/tsconfig.build.json b/packages/openapi-spec-builder/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/openapi-spec-builder/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/openapi-spec-builder/tsconfig.json b/packages/openapi-spec-builder/tsconfig.json new file mode 100644 index 000000000000..2ad4fb7066f9 --- /dev/null +++ b/packages/openapi-spec-builder/tsconfig.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../openapi-v3-types/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/openapi-v3-types/index.d.ts b/packages/openapi-v3-types/index.d.ts deleted file mode 100644 index d49171a80f1a..000000000000 --- a/packages/openapi-v3-types/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/openapi-v3-types -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/openapi-v3-types/index.ts b/packages/openapi-v3-types/index.ts deleted file mode 100644 index df597bef4aff..000000000000 --- a/packages/openapi-v3-types/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/openapi-v3-types -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/openapi-v3-types/package.json b/packages/openapi-v3-types/package.json index b4810805f9c7..3b2e734b9a23 100644 --- a/packages/openapi-v3-types/package.json +++ b/packages/openapi-v3-types/package.json @@ -5,6 +5,7 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "dependencies": { "openapi3-ts": "^1.0.0" }, @@ -17,6 +18,7 @@ "scripts": { "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-openapi-v3-types*.tgz dist package api-docs", "verify": "npm pack && tar xf loopback-openapi-v3-types*.tgz && tree package && npm run clean", "pretest": "npm run build", diff --git a/packages/openapi-v3-types/tsconfig.build.json b/packages/openapi-v3-types/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/openapi-v3-types/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/openapi-v3-types/tsconfig.json b/packages/openapi-v3-types/tsconfig.json new file mode 100644 index 000000000000..0022628a4af7 --- /dev/null +++ b/packages/openapi-v3-types/tsconfig.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../testlab/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/openapi-v3/index.d.ts b/packages/openapi-v3/index.d.ts deleted file mode 100644 index d8870b6ebd1c..000000000000 --- a/packages/openapi-v3/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/openapi-v3 -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/openapi-v3/index.ts b/packages/openapi-v3/index.ts deleted file mode 100644 index 8e7f407231f9..000000000000 --- a/packages/openapi-v3/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/openapi-v3 -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/openapi-v3/package.json b/packages/openapi-v3/package.json index cdd98cf5b72d..d4671bb56e9f 100644 --- a/packages/openapi-v3/package.json +++ b/packages/openapi-v3/package.json @@ -5,6 +5,7 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "devDependencies": { "@loopback/build": "^1.3.1", "@loopback/openapi-spec-builder": "^1.0.7", @@ -18,6 +19,7 @@ "scripts": { "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-openapi-v3*.tgz dist package", "integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"", "pretest": "npm run build", diff --git a/packages/openapi-v3/tsconfig.build.json b/packages/openapi-v3/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/openapi-v3/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/openapi-v3/tsconfig.json b/packages/openapi-v3/tsconfig.json new file mode 100644 index 000000000000..a62c19e0f480 --- /dev/null +++ b/packages/openapi-v3/tsconfig.json @@ -0,0 +1,34 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../openapi-spec-builder/tsconfig.json" + }, + { + "path": "../repository/tsconfig.json" + }, + { + "path": "../testlab/tsconfig.json" + }, + { + "path": "../context/tsconfig.json" + }, + { + "path": "../openapi-v3-types/tsconfig.json" + }, + { + "path": "../repository-json-schema/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/repository-json-schema/index.d.ts b/packages/repository-json-schema/index.d.ts deleted file mode 100644 index 336c25da6d11..000000000000 --- a/packages/repository-json-schema/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/repository-json-schema -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/repository-json-schema/index.ts b/packages/repository-json-schema/index.ts deleted file mode 100644 index e8130fbc7297..000000000000 --- a/packages/repository-json-schema/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/repository-json-schema -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/repository-json-schema/package.json b/packages/repository-json-schema/package.json index 1467d26ba0db..9fa1a94f88a4 100644 --- a/packages/repository-json-schema/package.json +++ b/packages/repository-json-schema/package.json @@ -5,9 +5,11 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "scripts": { "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-json-schema*.tgz dist package api-docs", "pretest": "npm run build", "test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/integration/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"", diff --git a/packages/repository-json-schema/tsconfig.build.json b/packages/repository-json-schema/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/repository-json-schema/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/repository-json-schema/tsconfig.json b/packages/repository-json-schema/tsconfig.json new file mode 100644 index 000000000000..dda8d66e954c --- /dev/null +++ b/packages/repository-json-schema/tsconfig.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../testlab/tsconfig.json" + }, + { + "path": "../context/tsconfig.json" + }, + { + "path": "../metadata/tsconfig.json" + }, + { + "path": "../repository/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/repository/index.d.ts b/packages/repository/index.d.ts deleted file mode 100644 index c79fbf1f353c..000000000000 --- a/packages/repository/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017. All Rights Reserved. -// Node module: @loopback/repository -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/repository/index.ts b/packages/repository/index.ts deleted file mode 100644 index 30865642e119..000000000000 --- a/packages/repository/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/repository -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/repository/package.json b/packages/repository/package.json index 449de218c166..5170651d0ac2 100644 --- a/packages/repository/package.json +++ b/packages/repository/package.json @@ -5,11 +5,13 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "main": "index", "scripts": { "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-repository*.tgz dist package api-docs", "pretest": "npm run build", "test": "lb-mocha \"dist/__tests__/**/*.js\"", diff --git a/packages/repository/examples/controllers/customer-with-class-di.controller.ts b/packages/repository/src/__examples__/controllers/customer-with-class-di.controller.ts similarity index 100% rename from packages/repository/examples/controllers/customer-with-class-di.controller.ts rename to packages/repository/src/__examples__/controllers/customer-with-class-di.controller.ts diff --git a/packages/repository/examples/controllers/customer-with-constructor-di.controller.ts b/packages/repository/src/__examples__/controllers/customer-with-constructor-di.controller.ts similarity index 100% rename from packages/repository/examples/controllers/customer-with-constructor-di.controller.ts rename to packages/repository/src/__examples__/controllers/customer-with-constructor-di.controller.ts diff --git a/packages/repository/examples/controllers/customer-with-property-di.controller.ts b/packages/repository/src/__examples__/controllers/customer-with-property-di.controller.ts similarity index 100% rename from packages/repository/examples/controllers/customer-with-property-di.controller.ts rename to packages/repository/src/__examples__/controllers/customer-with-property-di.controller.ts diff --git a/packages/repository/examples/juggler-bridge/note-with-repo-class.ts b/packages/repository/src/__examples__/juggler-bridge/note-with-repo-class.ts similarity index 100% rename from packages/repository/examples/juggler-bridge/note-with-repo-class.ts rename to packages/repository/src/__examples__/juggler-bridge/note-with-repo-class.ts diff --git a/packages/repository/examples/juggler-bridge/note-with-repo-instance.ts b/packages/repository/src/__examples__/juggler-bridge/note-with-repo-instance.ts similarity index 100% rename from packages/repository/examples/juggler-bridge/note-with-repo-instance.ts rename to packages/repository/src/__examples__/juggler-bridge/note-with-repo-instance.ts diff --git a/packages/repository/examples/models/address.model.ts b/packages/repository/src/__examples__/models/address.model.ts similarity index 100% rename from packages/repository/examples/models/address.model.ts rename to packages/repository/src/__examples__/models/address.model.ts diff --git a/packages/repository/examples/models/customer.definition.js b/packages/repository/src/__examples__/models/customer.definition.js similarity index 100% rename from packages/repository/examples/models/customer.definition.js rename to packages/repository/src/__examples__/models/customer.definition.js diff --git a/packages/repository/examples/models/customer.model.ts b/packages/repository/src/__examples__/models/customer.model.ts similarity index 100% rename from packages/repository/examples/models/customer.model.ts rename to packages/repository/src/__examples__/models/customer.model.ts diff --git a/packages/repository/examples/models/order.model.ts b/packages/repository/src/__examples__/models/order.model.ts similarity index 100% rename from packages/repository/examples/models/order.model.ts rename to packages/repository/src/__examples__/models/order.model.ts diff --git a/packages/repository/examples/repositories/customer.repository.ts b/packages/repository/src/__examples__/repositories/customer.repository.ts similarity index 100% rename from packages/repository/examples/repositories/customer.repository.ts rename to packages/repository/src/__examples__/repositories/customer.repository.ts diff --git a/packages/repository/tsconfig.build.json b/packages/repository/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/repository/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/repository/tsconfig.json b/packages/repository/tsconfig.json new file mode 100644 index 000000000000..12d1347c5f2a --- /dev/null +++ b/packages/repository/tsconfig.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../testlab/tsconfig.json" + }, + { + "path": "../context/tsconfig.json" + }, + { + "path": "../core/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/rest-explorer/index.d.ts b/packages/rest-explorer/index.d.ts deleted file mode 100644 index e8663372d411..000000000000 --- a/packages/rest-explorer/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/rest-explorer -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/rest-explorer/index.ts b/packages/rest-explorer/index.ts deleted file mode 100644 index b6765730279e..000000000000 --- a/packages/rest-explorer/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/rest-explorer -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/rest-explorer/package.json b/packages/rest-explorer/package.json index c8484ffc9f66..ebebde0a3287 100644 --- a/packages/rest-explorer/package.json +++ b/packages/rest-explorer/package.json @@ -5,6 +5,7 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "scripts": { "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", diff --git a/packages/rest-explorer/tsconfig.build.json b/packages/rest-explorer/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/rest-explorer/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/rest-explorer/tsconfig.json b/packages/rest-explorer/tsconfig.json new file mode 100644 index 000000000000..795b535d9238 --- /dev/null +++ b/packages/rest-explorer/tsconfig.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "include": [ + "src/**/*", + "src/**/*.json" + ], + "references": [ + { + "path": "../testlab/tsconfig.json" + }, + { + "path": "../context/tsconfig.json" + }, + { + "path": "../core/tsconfig.json" + }, + { + "path": "../rest/tsconfig.json" + } + ] +} diff --git a/packages/rest/index.d.ts b/packages/rest/index.d.ts deleted file mode 100644 index 3e45f53534a9..000000000000 --- a/packages/rest/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017. All Rights Reserved. -// Node module: @loopback/rest -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/rest/index.ts b/packages/rest/index.ts deleted file mode 100644 index 106e0211fadd..000000000000 --- a/packages/rest/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/rest -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/rest/package.json b/packages/rest/package.json index d97ab94fac24..df8b549826f0 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -5,10 +5,12 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "scripts": { "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-rest*.tgz dist package api-docs", "pretest": "npm run build", "integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"", diff --git a/packages/rest/tsconfig.build.json b/packages/rest/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/rest/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/rest/tsconfig.json b/packages/rest/tsconfig.json new file mode 100644 index 000000000000..523877382a84 --- /dev/null +++ b/packages/rest/tsconfig.json @@ -0,0 +1,40 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../openapi-spec-builder/tsconfig.json" + }, + { + "path": "../repository/tsconfig.json" + }, + { + "path": "../testlab/tsconfig.json" + }, + { + "path": "../context/tsconfig.json" + }, + { + "path": "../core/tsconfig.json" + }, + { + "path": "../http-server/tsconfig.json" + }, + { + "path": "../openapi-v3/tsconfig.json" + }, + { + "path": "../openapi-v3-types/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/service-proxy/index.d.ts b/packages/service-proxy/index.d.ts deleted file mode 100644 index 5d1085bdecf4..000000000000 --- a/packages/service-proxy/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017. All Rights Reserved. -// Node module: @loopback/service-proxy -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/service-proxy/index.ts b/packages/service-proxy/index.ts deleted file mode 100644 index a26fd0532530..000000000000 --- a/packages/service-proxy/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/service-proxy -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/service-proxy/package.json b/packages/service-proxy/package.json index db5b01c20580..054e65ef29bd 100644 --- a/packages/service-proxy/package.json +++ b/packages/service-proxy/package.json @@ -5,11 +5,12 @@ "engines": { "node": ">=8.9" }, - "main": "index", + "types": "./dist/index.d.ts", "scripts": { "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-service-proxy*.tgz dist package api-docs", "integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"", "pretest": "npm run build", diff --git a/packages/service-proxy/tsconfig.build.json b/packages/service-proxy/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/service-proxy/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/service-proxy/tsconfig.json b/packages/service-proxy/tsconfig.json new file mode 100644 index 000000000000..12d1347c5f2a --- /dev/null +++ b/packages/service-proxy/tsconfig.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [ + { + "path": "../testlab/tsconfig.json" + }, + { + "path": "../context/tsconfig.json" + }, + { + "path": "../core/tsconfig.json" + } + ], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/packages/testlab/index.d.ts b/packages/testlab/index.d.ts deleted file mode 100644 index d15be2753161..000000000000 --- a/packages/testlab/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/testlab -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/testlab/index.ts b/packages/testlab/index.ts deleted file mode 100644 index d9ed8e1f6382..000000000000 --- a/packages/testlab/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/testlab -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/testlab/package.json b/packages/testlab/package.json index 25231cf1d720..6cbc7cffe15f 100644 --- a/packages/testlab/package.json +++ b/packages/testlab/package.json @@ -5,9 +5,11 @@ "engines": { "node": ">=8.9" }, + "types": "./dist/index.d.ts", "scripts": { "build": "lb-tsc es2017 --outDir dist", "build:apidocs": "lb-apidocs", + "build:resources": "lb-copy-resources", "clean": "lb-clean loopback-testlab*.tgz dist package api-docs", "pretest": "npm run build", "test": "lb-mocha \"dist/__tests__\"", diff --git a/packages/testlab/tsconfig.build.json b/packages/testlab/tsconfig.build.json deleted file mode 100644 index 6e15e4be4f6f..000000000000 --- a/packages/testlab/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "src" - }, - "include": ["src"] -} diff --git a/packages/testlab/tsconfig.json b/packages/testlab/tsconfig.json new file mode 100644 index 000000000000..b1790172a4d3 --- /dev/null +++ b/packages/testlab/tsconfig.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src", + "composite": true, + "target": "es2017", + "outDir": "dist" + }, + "references": [], + "include": [ + "src/**/*", + "src/**/*.json" + ] +} diff --git a/tsconfig.json b/tsconfig.json index c6d681524147..2389061c9255 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,15 +1,78 @@ { "extends": "./packages/build/config/tsconfig.common.json", - "include": [ - "benchmark", - "examples", - "packages" + "compilerOptions": { + "composite": true + }, + "references": [ + { + "path": "benchmark/tsconfig.json" + }, + { + "path": "examples/hello-world/tsconfig.json" + }, + { + "path": "examples/log-extension/tsconfig.json" + }, + { + "path": "examples/rpc-server/tsconfig.json" + }, + { + "path": "examples/soap-calculator/tsconfig.json" + }, + { + "path": "examples/todo-list/tsconfig.json" + }, + { + "path": "examples/todo/tsconfig.json" + }, + { + "path": "packages/authentication/tsconfig.json" + }, + { + "path": "packages/boot/tsconfig.json" + }, + { + "path": "packages/context/tsconfig.json" + }, + { + "path": "packages/core/tsconfig.json" + }, + { + "path": "packages/http-caching-proxy/tsconfig.json" + }, + { + "path": "packages/http-server/tsconfig.json" + }, + { + "path": "packages/metadata/tsconfig.json" + }, + { + "path": "packages/openapi-spec-builder/tsconfig.json" + }, + { + "path": "packages/openapi-v3-types/tsconfig.json" + }, + { + "path": "packages/openapi-v3/tsconfig.json" + }, + { + "path": "packages/repository-json-schema/tsconfig.json" + }, + { + "path": "packages/repository/tsconfig.json" + }, + { + "path": "packages/rest-explorer/tsconfig.json" + }, + { + "path": "packages/rest/tsconfig.json" + }, + { + "path": "packages/service-proxy/tsconfig.json" + }, + { + "path": "packages/testlab/tsconfig.json" + } ], - "exclude": [ - "node_modules/**", - "benchmark/node_modules/**", - "examples/*/node_modules/**", - "packages/*/node_modules/**", - "**/*.d.ts" - ] + "files": [] }