Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(component): initial setup #2257

Merged
merged 2 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ The scope should be the name of the npm package affected (as perceived by the pe

The following is the list of supported scopes:

- **component**
- **data**
- **effects**
- **entity**
Expand Down
5 changes: 4 additions & 1 deletion build/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export async function copySchematicsCore(config: Config) {
.toString('utf-8');
const pkgConfig = JSON.parse(packageJson);

if (pkgConfig.schematics || pkgConfig['ng-update'].migrations) {
if (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

component doesn't have schematics, pkgConfig['ng-update'].migrations threw an error.

pkgConfig.schematics ||
(pkgConfig['ng-update'] && pkgConfig['ng-update'].migrations)
) {
ncp(
`${modulesDir}/schematics-core`,
`${modulesDir}/${pkg}/schematics-core`,
Expand Down
34 changes: 34 additions & 0 deletions modules/component/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "ng_module", "ng_package")

ng_module(
name = "component",
srcs = glob([
"*.ts",
"src/**/*.ts",
]),
module_name = "@ngrx/component",
deps = [
# TODO: @ngrx/component - add ngrx deps, also add it to package.json as peerDependency
# "//modules/store",
"@npm//@angular/common",
"@npm//@angular/core",
"@npm//rxjs",
],
)

ng_package(
name = "npm_package",
srcs = glob(["**/*.externs.js"]) + [
"package.json",
],
entry_point = "modules/component/index.js",
packages = [
# TODO: @ngrx/component - add schematic
# "//modules/component/schematics-core:npm_package",
],
deps = [
":component",
],
)
3 changes: 3 additions & 0 deletions modules/component/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Change Log

See [CHANGELOG.md](https://github.com/ngrx/platform/blob/master/CHANGELOG.md)
5 changes: 5 additions & 0 deletions modules/component/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @ngrx/component

The sources for this package are in the main [NgRx](https://github.com/ngrx/platform) repo. Please file issues and pull requests against that repo.

License: MIT
7 changes: 7 additions & 0 deletions modules/component/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* DO NOT EDIT
*
* This file is automatically generated at build
*/

export * from './public_api';
28 changes: 28 additions & 0 deletions modules/component/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@ngrx/component",
"version": "0.0.0-PLACEHOLDER",
"description": "Reactive utilities for components",
"repository": {
"type": "git",
"url": "https://github.com/ngrx/platform.git"
},
"keywords": [
"Angular",
"Redux",
"NgRx",
"Schematics",
"Angular CLI"
],
"author": "NgRx",
"license": "MIT",
"bugs": {
"url": "https://github.com/ngrx/platform/issues"
},
"homepage": "https://github.com/ngrx/platform#readme",
"peerDependencies": {
"@angular/common": "NG_VERSION",
"@angular/core": "NG_VERSION",
"rxjs": "RXJS_VERSION"
},
"sideEffects": false
}
1 change: 1 addition & 0 deletions modules/component/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/index';
11 changes: 11 additions & 0 deletions modules/component/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
entry: './dist/component/@ngrx/component.es5.js',
dest: './dist/component/bundles/component.umd.js',
format: 'umd',
exports: 'named',
moduleName: 'ngrx.component',
globals: {
// TODO: @ngrx/component - add ngrx deps, also add it to tsconfig-build.json as path
// '@ngrx/store': 'ngrx.store',
},
};
27 changes: 27 additions & 0 deletions modules/component/spec/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load("//tools:defaults.bzl", "jasmine_node_test", "ts_test_library")

ts_test_library(
name = "test_lib",
srcs = glob(
[
"**/*.ts",
],
),
deps = [
"//modules/component",
# TODO: @ngrx/component - add ngrx deps
# "//modules/store",
"@npm//@angular/common",
"@npm//rxjs",
],
)

jasmine_node_test(
name = "test",
deps = [
":test_lib",
"//modules/component",
# TODO: @ngrx/component - add ngrx deps
# "//modules/store",
],
)
9 changes: 9 additions & 0 deletions modules/component/spec/placeholder.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// TODO: @ngrx/component - remove this file

import { sum } from '@ngrx/component';

describe('placeholder', () => {
it('should run specs', () => {
expect(sum(2, 5)).toBe(7);
});
});
1 change: 1 addition & 0 deletions modules/component/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './placeholder';
5 changes: 5 additions & 0 deletions modules/component/src/placeholder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// TODO: @ngrx/component - remove this file

export function sum(a: number, b: number) {
return a + b;
}
33 changes: 33 additions & 0 deletions modules/component/tsconfig-build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"stripInternal": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"module": "es2015",
"moduleResolution": "node",
"noEmitOnError": false,
"noImplicitAny": true,
"noImplicitReturns": true,
"downlevelIteration": true,
"outDir": "../../dist/packages/component",
"paths": {},
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"lib": ["es2015", "dom"],
"target": "es2015",
"skipLibCheck": true
},
"files": ["public_api.ts"],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
// Work around for issue: https://github.com/angular/angular/issues/22210
"strictMetadataEmit": false,
"flatModuleOutFile": "index.js",
"flatModuleId": "@ngrx/component",
"enableIvy": false
}
}
1 change: 1 addition & 0 deletions tools/defaults.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ NGRX_SCOPED_PACKAGES = ["@ngrx/%s" % p for p in [
"entity",
"router-store",
"data",
"component",
"schematics",
"store-devtools",
]]
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"rootDir": "./",
"strict": true,
"paths": {
"@ngrx/component": ["./modules/component"],
"@ngrx/data": ["./modules/data"],
"@ngrx/data/schematics-core": ["./modules/data/schematics-core"],
"@ngrx/effects": ["./modules/effects"],
Expand Down