From 2a280ddc72e9243e23bcede2acf6653766ade412 Mon Sep 17 00:00:00 2001 From: Alex Okrushko Date: Mon, 11 May 2020 21:52:11 -0400 Subject: [PATCH] feat(component-store): add initial setup (#2519) --- CONTRIBUTING.md | 1 + modules/component-store/BUILD | 27 ++++++++++++++++++ modules/component-store/CHANGELOG.md | 3 ++ modules/component-store/README.md | 3 ++ modules/component-store/index.ts | 7 +++++ modules/component-store/package.json | 28 +++++++++++++++++++ modules/component-store/public_api.ts | 1 + modules/component-store/rollup.config.js | 9 ++++++ modules/component-store/spec/BUILD | 21 ++++++++++++++ .../component-store/spec/placeholder.spec.ts | 7 +++++ modules/component-store/src/index.ts | 1 + modules/component-store/src/placeholder.ts | 3 ++ modules/component-store/tsconfig-build.json | 27 ++++++++++++++++++ .../content/guide/component-store/index.md | 3 ++ projects/ngrx.io/content/guide/nightlies.md | 10 +++++++ projects/ngrx.io/content/marketing/docs.md | 3 +- projects/ngrx.io/content/navigation.json | 9 ++++++ tools/defaults.bzl | 1 + tsconfig.json | 1 + 19 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 modules/component-store/BUILD create mode 100644 modules/component-store/CHANGELOG.md create mode 100644 modules/component-store/README.md create mode 100644 modules/component-store/index.ts create mode 100644 modules/component-store/package.json create mode 100644 modules/component-store/public_api.ts create mode 100644 modules/component-store/rollup.config.js create mode 100644 modules/component-store/spec/BUILD create mode 100644 modules/component-store/spec/placeholder.spec.ts create mode 100644 modules/component-store/src/index.ts create mode 100644 modules/component-store/src/placeholder.ts create mode 100644 modules/component-store/tsconfig-build.json create mode 100644 projects/ngrx.io/content/guide/component-store/index.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f3fef63907..dad5ec2e32 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -99,6 +99,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** +- **component-store** - **data** - **effects** - **entity** diff --git a/modules/component-store/BUILD b/modules/component-store/BUILD new file mode 100644 index 0000000000..62dbbbbf65 --- /dev/null +++ b/modules/component-store/BUILD @@ -0,0 +1,27 @@ +package(default_visibility = ["//visibility:public"]) + +load("//tools:defaults.bzl", "ng_package", "ts_library") + +ts_library( + name = "component-store", + srcs = glob([ + "*.ts", + "src/**/*.ts", + ]), + module_name = "@ngrx/component-store", + deps = [ + "@npm//rxjs", + "@npm//tslib", + ], +) + +ng_package( + name = "npm_package", + srcs = glob(["**/*.externs.js"]) + [ + "package.json", + ], + entry_point = "modules/component-store/index.js", + deps = [ + ":component-store", + ], +) diff --git a/modules/component-store/CHANGELOG.md b/modules/component-store/CHANGELOG.md new file mode 100644 index 0000000000..3b9c4d91aa --- /dev/null +++ b/modules/component-store/CHANGELOG.md @@ -0,0 +1,3 @@ +# Change Log + +See [CHANGELOG.md](https://github.com/ngrx/platform/blob/master/CHANGELOG.md) diff --git a/modules/component-store/README.md b/modules/component-store/README.md new file mode 100644 index 0000000000..ae2425bad8 --- /dev/null +++ b/modules/component-store/README.md @@ -0,0 +1,3 @@ + # @ngrx/component-store + +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. diff --git a/modules/component-store/index.ts b/modules/component-store/index.ts new file mode 100644 index 0000000000..637e1cf2bf --- /dev/null +++ b/modules/component-store/index.ts @@ -0,0 +1,7 @@ +/** + * DO NOT EDIT + * + * This file is automatically generated at build + */ + +export * from './public_api'; diff --git a/modules/component-store/package.json b/modules/component-store/package.json new file mode 100644 index 0000000000..9e5ea18d59 --- /dev/null +++ b/modules/component-store/package.json @@ -0,0 +1,28 @@ +{ + "name": "@ngrx/component-store", + "version": "0.0.0-PLACEHOLDER", + "description": "Reactive store for component state", + "repository": { + "type": "git", + "url": "https://github.com/ngrx/platform.git" + }, + "keywords": [ + "Angular", + "Redux", + "NgRx", + "Schematics", + "Local State", + "Component State", + "State management" + ], + "author": "NgRx", + "license": "MIT", + "bugs": { + "url": "https://github.com/ngrx/platform/issues" + }, + "homepage": "https://github.com/ngrx/platform#readme", + "peerDependencies": { + "rxjs": "RXJS_VERSION" + }, + "sideEffects": false +} diff --git a/modules/component-store/public_api.ts b/modules/component-store/public_api.ts new file mode 100644 index 0000000000..cba1843545 --- /dev/null +++ b/modules/component-store/public_api.ts @@ -0,0 +1 @@ +export * from './src/index'; diff --git a/modules/component-store/rollup.config.js b/modules/component-store/rollup.config.js new file mode 100644 index 0000000000..92e89de176 --- /dev/null +++ b/modules/component-store/rollup.config.js @@ -0,0 +1,9 @@ +export default { + entry: './dist/component-store/@ngrx/component-store.es5.js', + dest: './dist/component-store/bundles/component-store.umd.js', + format: 'umd', + exports: 'named', + moduleName: 'ngrx.component-store', + globals: { + }, +}; diff --git a/modules/component-store/spec/BUILD b/modules/component-store/spec/BUILD new file mode 100644 index 0000000000..6be3f0e1fb --- /dev/null +++ b/modules/component-store/spec/BUILD @@ -0,0 +1,21 @@ +load("//tools:defaults.bzl", "jasmine_node_test", "ts_test_library") + +ts_test_library( + name = "test_lib", + srcs = glob( + [ + "**/*.ts", + ], + ), + deps = [ + "//modules/component-store", + "@npm//rxjs", + ], +) + +jasmine_node_test( + name = "test", + deps = [ + ":test_lib", + ], +) diff --git a/modules/component-store/spec/placeholder.spec.ts b/modules/component-store/spec/placeholder.spec.ts new file mode 100644 index 0000000000..bd4a1425bb --- /dev/null +++ b/modules/component-store/spec/placeholder.spec.ts @@ -0,0 +1,7 @@ +import { sum } from '@ngrx/component-store'; + +describe('placeholder', () => { + it('should run specs', () => { + expect(sum(2, 5)).toBe(7); + }); +}); diff --git a/modules/component-store/src/index.ts b/modules/component-store/src/index.ts new file mode 100644 index 0000000000..44ebde2c43 --- /dev/null +++ b/modules/component-store/src/index.ts @@ -0,0 +1 @@ +export * from './placeholder'; diff --git a/modules/component-store/src/placeholder.ts b/modules/component-store/src/placeholder.ts new file mode 100644 index 0000000000..508f35f62e --- /dev/null +++ b/modules/component-store/src/placeholder.ts @@ -0,0 +1,3 @@ +export function sum(a: number, b: number) { + return a + b; +} diff --git a/modules/component-store/tsconfig-build.json b/modules/component-store/tsconfig-build.json new file mode 100644 index 0000000000..6454cb03b7 --- /dev/null +++ b/modules/component-store/tsconfig-build.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "declaration": true, + "stripInternal": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "module": "es2015", + "moduleResolution": "node", + "strict": true, + "outDir": "../../dist/packages/component-store", + "paths": {}, + "rootDir": ".", + "sourceMap": true, + "inlineSources": true, + "lib": ["es2015", "dom"], + "target": "es2015", + "skipLibCheck": true + }, + "files": ["public_api.ts"], + "angularCompilerOptions": { + "annotateForClosureCompiler": true, + "flatModuleOutFile": "index.js", + "flatModuleId": "@ngrx/component-store", + "enableIvy": false + } +} diff --git a/projects/ngrx.io/content/guide/component-store/index.md b/projects/ngrx.io/content/guide/component-store/index.md new file mode 100644 index 0000000000..1bce4be83d --- /dev/null +++ b/projects/ngrx.io/content/guide/component-store/index.md @@ -0,0 +1,3 @@ +# @ngrx/component-store + +Placeholder diff --git a/projects/ngrx.io/content/guide/nightlies.md b/projects/ngrx.io/content/guide/nightlies.md index b4a2e8b900..51f5046a56 100644 --- a/projects/ngrx.io/content/guide/nightlies.md +++ b/projects/ngrx.io/content/guide/nightlies.md @@ -72,6 +72,16 @@ npm install github:ngrx/component-builds yarn add github:ngrx/component-builds ``` +### Component Store + +```sh +npm install github:ngrx/component-store-builds +``` + +```sh +yarn add github:ngrx/component-store-builds +``` + ### Schematics ```sh diff --git a/projects/ngrx.io/content/marketing/docs.md b/projects/ngrx.io/content/marketing/docs.md index b58b198abf..84f1eca958 100644 --- a/projects/ngrx.io/content/marketing/docs.md +++ b/projects/ngrx.io/content/marketing/docs.md @@ -36,7 +36,7 @@ NgRx is also powered by memoized selector functions which optimize state query c In particular, you might use NgRx when you build an application with a lot of user interactions and multiple data sources, when managing state in services are no longer sufficient. -A good substance that might answer the question "Do I need NgRx", is the +A good substance that might answer the question "Do I need NgRx", is the **SHARI** principle: * **S**hared: state that is accessed by many components and services. @@ -63,4 +63,5 @@ It is also often require a steep learning curve, including some good understandi - [Entity](guide/entity) - Entity State adapter for managing record collections. - [NgRx Data](guide/data) - Extension for simplified entity data management. - [NgRx Component](guide/component) - Extension for fully reactive, fully zone-less applications. +- [ComponentStore](guide/component-store) - Standalone library for managing local/component state. - [Schematics](guide/schematics) - Scaffolding library for Angular applications using NgRx libraries. diff --git a/projects/ngrx.io/content/navigation.json b/projects/ngrx.io/content/navigation.json index 4bbff4e95f..9524c87ccf 100644 --- a/projects/ngrx.io/content/navigation.json +++ b/projects/ngrx.io/content/navigation.json @@ -336,6 +336,15 @@ } ] }, + { + "title": "@ngrx/component-store", + "children": [ + { + "title": "Overview", + "url": "guide/component-store" + } + ] + }, { "title": "@ngrx/schematics", "children": [ diff --git a/tools/defaults.bzl b/tools/defaults.bzl index 7728379825..ac78247a51 100644 --- a/tools/defaults.bzl +++ b/tools/defaults.bzl @@ -18,6 +18,7 @@ NGRX_SCOPED_PACKAGES = ["@ngrx/%s" % p for p in [ "router-store", "data", "component", + "component-store", "schematics", "store-devtools", ]] diff --git a/tsconfig.json b/tsconfig.json index d59e69fab9..6cf380c17f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,7 @@ "strict": true, "paths": { "@ngrx/component": ["./modules/component"], + "@ngrx/component-store": ["./modules/component-store"], "@ngrx/data": ["./modules/data"], "@ngrx/data/schematics-core": ["./modules/data/schematics-core"], "@ngrx/effects": ["./modules/effects"],