-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(package): support subpath alias with top-level root
- Loading branch information
Showing
7 changed files
with
36 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
}); | ||
|