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: add @rxjs/observable package and update rxjs to use it #7430

Merged
merged 12 commits into from
Feb 29, 2024
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages/rxjs/integration/import/fixtures
45 changes: 45 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "off",
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/consistent-type-exports": "warn",
"no-prototype-builtins": "off",
"@typescript-eslint/no-inferrable-types": "warn",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "off"
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
],
"@typescript-eslint/no-unused-vars": "off"
}
}
]
}
3 changes: 3 additions & 0 deletions .github/workflows/ci_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Build, test and lint all projects (except website)
run: yarn nx run-many -t build lint test --exclude=rxjs.dev

- name: rxjs lint
run: yarn workspace rxjs lint
- name: rxjs build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_ts_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
- name: build
run: |
yarn workspace rxjs add typescript@latest @types/node@latest --peer --no-save
yarn workspace rxjs compile
yarn nx compile rxjs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ typings/

# Generated
dist/
.tshy-build

# Import location artifacts
packages/rxjs/ajax/
Expand Down
5 changes: 5 additions & 0 deletions apps/rxjs.dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,10 @@
"xregexp": "^4.0.0",
"yamljs": "^0.3.0",
"yargs": "^13.2.4"
},
"nx": {
"implicitDependencies": [
"rxjs"
]
}
}
29 changes: 28 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,41 @@
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"],
"cache": true
},
"test:circular": {
"dependsOn": ["build"]
},
"test": {
"cache": true
},
"lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json", "{workspaceRoot}/tools/eslint-rules/**/*"],
"cache": true
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": ["default", "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)", "!{projectRoot}/.eslintrc.json"],
"sharedGlobals": [
"{workspaceRoot}/github/workflows/*.yml",
{
"runtime": "node -e 'console.log(`${process.platform}-${process.arch}`)'"
},
{
"runtime": "node --version"
},
{
"runtime": "npm --version"
},
{
"runtime": "yarn --version"
}
]
},
"release": {
"projects": ["rxjs"],
"projects": ["packages/*"],
"releaseTagPattern": "{version}",
"changelog": {
"workspaceChangelog": {
Expand Down
42 changes: 36 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "rxjs",
"private": true,
"workspaces": {
"packages": [
"packages/rxjs",
"packages/*",
"apps/rxjs.dev"
],
"nohoist": [
Expand All @@ -19,12 +18,43 @@
},
"packageManager": "yarn@1.22.21",
"scripts": {
"prepare-packages": "yarn nx run-many -t build,lint,test:circular,dtslint,copy_common_package_files --exclude rxjs.dev",
"prepare-packages": "yarn nx test @rxjs/observable && yarn nx run-many -t build,lint,test:circular,dtslint,copy_common_package_files --exclude rxjs.dev",
"release": "node scripts/release.js"
},
"dependencies": {},
"devDependencies": {
"@nx/js": "17.3.0-beta.4",
"nx": "17.3.0-beta.4"
"@nx/eslint-plugin": "17.3.2",
"@nx/js": "17.3.2",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"cz-conventional-changelog": "1.2.0",
"eslint": "^8.56.0",
"husky": "^4.2.5",
"lint-staged": "^10.2.11",
"nx": "17.3.2",
"ts-node": "^10.9.2",
"tshy": "^1.11.0",
"typescript": "~5.3.3",
"validate-commit-msg": "2.14.0",
"vitest": "^1.2.1"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "validate-commit-msg"
}
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"lint-staged": {
"*.js": "eslint --cache --fix",
"(src|spec)/**/*.ts": [
"eslint --fix",
"prettier --write"
],
"*.{js,css,md}": "prettier --write"
}
}

28 changes: 28 additions & 0 deletions packages/observable/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"parserOptions": {
"project": ["./packages/observable/tsconfig.json"]
},
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["./package.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": ["error"]
}
}
]
}
12 changes: 12 additions & 0 deletions packages/observable/.tshy/browser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
],
"exclude": [],
"compilerOptions": {
"outDir": "../.tshy-build/browser"
}
}
9 changes: 9 additions & 0 deletions packages/observable/.tshy/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../src",
"target": "es2022",
"module": "nodenext",
"moduleResolution": "nodenext"
}
}
14 changes: 14 additions & 0 deletions packages/observable/.tshy/commonjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx"
],
"exclude": [
"../src/**/*.mts"
],
"compilerOptions": {
"outDir": "../.tshy-build/commonjs"
}
}
12 changes: 12 additions & 0 deletions packages/observable/.tshy/esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
],
"exclude": [],
"compilerOptions": {
"outDir": "../.tshy-build/esm"
}
}
14 changes: 14 additions & 0 deletions packages/observable/.tshy/webpack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx"
],
"exclude": [
"../src/**/*.mts"
],
"compilerOptions": {
"outDir": "../.tshy-build/webpack"
}
}
70 changes: 70 additions & 0 deletions packages/observable/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"name": "@rxjs/observable",
"version": "8.0.0-alpha.14",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/ReactiveX/RxJS/issues"
},
"homepage": "https://rxjs.dev",
"author": "Ben Lesh <ben@benlesh.com>",
"files": [
"dist"
],
"main": "./dist/commonjs/index.js",
"types": "./dist/commonjs/index.d.ts",
"type": "module",
"scripts": {
"build": "tshy",
"lint": "eslint ./src",
"test": "vitest --run",
"test:watch": "vitest"
},
"repository": {
"type": "git",
"url": "https://github.com/ReactiveX/rxjs.git",
"directory": "packages/observable"
},
"keywords": [
"Rx",
"RxJS",
"ReactiveX",
"ReactiveExtensions",
"Streams",
"Observables",
"Observable",
"Stream"
],
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
},
"esmDialects": [
"browser"
],
"commonjsDialects": [
"webpack"
]
},
"exports": {
"./package.json": "./package.json",
".": {
"browser": {
"types": "./dist/browser/index.d.ts",
"default": "./dist/browser/index.js"
},
"webpack": {
"types": "./dist/webpack/index.d.ts",
"default": "./dist/webpack/index.js"
},
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
}
}
18 changes: 18 additions & 0 deletions packages/observable/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export { Observable, Subscriber, Subscription, UnsubscriptionError, config, from, isObservable, operate } from './observable.js';
export type { GlobalConfig, SubscriberOverrides } from './observable.js';

// TODO: reevaluate these as part of public API of @rxjs/observable? They aren't exported from rxjs so feel more internal?
export {
COMPLETE_NOTIFICATION,
ObservableInputType,
createNotification,
errorNotification,
fromArrayLike,
getObservableInputType,
isArrayLike,
isFunction,
isPromise,
nextNotification,
readableStreamLikeToAsyncGenerator,
subscribeToArray,
} from './observable.js';