Skip to content

Commit

Permalink
build(package): support subpath alias with top-level root
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Sep 23, 2019
1 parent bb575d5 commit f8861b0
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 40 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,18 @@ img/
spec-js/
spec-build/
.out/
.tmp/

ajax/
fetch/
operators/
testing/
webSocket/

# Misc
npm-debug.log
.DS_STORE
*.tgz

# The check-side-effects package generates and deletes this file.
# If the process is killed, it will be left behind.
Expand Down
8 changes: 0 additions & 8 deletions src/ajax/package.json

This file was deleted.

8 changes: 0 additions & 8 deletions src/fetch/package.json

This file was deleted.

8 changes: 0 additions & 8 deletions src/operators/package.json

This file was deleted.

8 changes: 0 additions & 8 deletions src/testing/package.json

This file was deleted.

8 changes: 0 additions & 8 deletions src/webSocket/package.json

This file was deleted.

28 changes: 28 additions & 0 deletions tools/generate-alias.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Alias subpath import (`dist/cjs/*`) to top-level path mapping (`rxjs/*`)
* Previously this was done by placing cjs to top-level package when it's published -
* Now build uses `dist` as explicit output subpath so we generate top-level alias here instead.
*/
const fs = require('fs-extra');
const path = require('path');

const aliasRoot = [
'ajax', 'fetch', 'operators', 'testing', 'webSocket'
]

aliasRoot.forEach((alias) => fs.removeSync(alias));
aliasRoot.forEach((alias) => fs.ensureDirSync(alias));

aliasRoot.forEach((alias) => {
const pkgManifest = {
"name": `rxjs/${alias}`,
"typings": `../dist/types/${alias}/index.d.ts`,
"main": `../dist/cjs/${alias}/index.js`,
"module": `../dist/esm5/${alias}/index.js`,
"es2015": `../dist/esm/${alias}/index.js`,
"sideEffects": false
};

fs.writeJSON(path.resolve(__dirname, `../${alias}/package.json`), pkgManifest, { spaces: 2 });
});

0 comments on commit f8861b0

Please sign in to comment.