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

Add exports within package.json to enable scoped package loading. #6192

Merged
merged 2 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .github/workflows/ci_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ jobs:
- name: import
if: ${{ matrix.node == '14' }}
run: npm run test:import
- name: import
if: ${{ matrix.node == '14' || matrix.node == '15' }}
run: npm run test:esm

28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@
"es2015": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"sideEffects": false,
"exports": {
".": {
"node": "./dist/cjs/index.js",
"default": "./dist/esm5/index.js"
},
"./ajax": {
"node": "./dist/cjs/ajax/index.js",
"default": "./dist/dist/esm5/ajax/index.js"
},
"./fetch": {
"node": "./dist/cjs/fetch/index.js",
"default": "./dist/dist/esm5/fetch/index.js"
},
"./operators": {
"node": "./dist/cjs/operators/index.js",
"default": "./dist/dist/esm5/operators/index.js"
},
"./testing": {
"node": "./dist/cjs/testing/index.js",
"default": "./dist/dist/esm5/testing/index.js"
},
"./webSocket": {
"node": "./dist/cjs/webSocket/index.js",
"default": "./dist/dist/esm5/webSocket/index.js"
},
"./package.json": "./package.json"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
Expand All @@ -30,6 +57,7 @@
"prepublishOnly": "npm run build:package && npm run lint && npm run test && npm run test:circular && npm run dtslint && npm run test:side-effects && npm run api_guardian",
"publish_docs": "./publish_docs.sh",
"test": "npm run compile && mocha --config spec/support/.mocharc.js \"dist/spec/**/*-spec.js\"",
"test:esm": "node spec/module-test-spec.mjs",
"test:browser": "echo \"Browser test is not working currently\" && exit -1 && npm-run-all build:spec:browser && opn spec/support/mocha-browser-runner.html",
"test:circular": "dependency-cruiser --validate .dependency-cruiser.json -x \"^node_modules\" dist/esm5",
"test:systemjs": "node integration/systemjs/systemjs-compatibility-spec.js",
Expand Down
13 changes: 13 additions & 0 deletions spec/module-test-spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Test file to ensure rxjs can be loaded from esm

https://github.com/ReactiveX/rxjs/pull/6192
If this fails node will error when running this with an error like
node:internal/process/esm_loader:74
internalBinding('errors').triggerUncaughtException(
*/
import {Observable} from 'rxjs';
import * as o from 'rxjs/operators';
import * as a from 'rxjs/ajax';
import * as f from 'rxjs/fetch';
import * as t from 'rxjs/testing';
import * as w from 'rxjs/webSocket';