-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add @pkgr/named-exports package
- Loading branch information
Showing
14 changed files
with
222 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@1stg/eslint-config/recommended" | ||
} |
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
coverage | ||
lib | ||
node_modules | ||
/packages/named-exports/index.ts |
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 |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
"publish": { | ||
"ignoreChanges": [ | ||
"test", | ||
"tsconfig.json", | ||
"*.md" | ||
] | ||
} | ||
|
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 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,57 @@ | ||
# @pkgr/named-exports | ||
|
||
[](https://www.npmjs.com/package/@pkgr/named-exports) | ||
 | ||
 | ||
|
||
[](https://david-dm.org/rx-ts/pkgr?path=packages/named-exports&type=peer) | ||
[](https://david-dm.org/rx-ts/pkgr?path=packages/named-exports) | ||
[](https://david-dm.org/rx-ts/pkgr?path=packages/named-exports&type=dev) | ||
|
||
> Union `namedExports` definitions for [rollup-plugin-commonjs][]. | ||
## TOC <!-- omit in toc --> | ||
|
||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [Changelog](#changelog) | ||
- [License](#license) | ||
|
||
## Install | ||
|
||
```sh | ||
# yarn | ||
yarn add -D @pkgr/named-exports | ||
|
||
# npm | ||
npm i -D @pkgr/named-exports | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
// rollup.config.js | ||
import commonjs from 'rollup-plugin-commonjs' | ||
import { namedExports } from '@pkgr/named-exports' | ||
|
||
export default { | ||
plugins: [ | ||
commonjs({ | ||
namedExports, | ||
}), | ||
], | ||
} | ||
``` | ||
|
||
## Changelog | ||
|
||
Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md). | ||
|
||
## License | ||
|
||
[MIT][] © [JounQin][]@[1stG.me][] | ||
|
||
[1stg.me]: https://www.1stg.me | ||
[jounqin]: https://GitHub.com/JounQin | ||
[mit]: http://opensource.org/licenses/MIT | ||
[rollup-plugin-commonjs]: https://github.com/rollup/rollup-plugin-commonjs#custom-named-exports |
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,25 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
// eslint-disable-next-line node/no-extraneous-import | ||
import prettier from 'prettier' | ||
|
||
const PKGS = ['prettier', 'react', 'react-dom'] | ||
|
||
const namedExports = PKGS.reduce( | ||
(acc, pkg) => | ||
Object.assign(acc, { | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires | ||
[pkg]: Object.keys(require(pkg)).filter(key => !/^[_$]/.test(key)), | ||
}), | ||
{}, | ||
) | ||
|
||
fs.writeFileSync( | ||
path.resolve(__dirname, 'index.ts'), | ||
prettier.format(` | ||
export const namedExports = ${JSON.stringify(namedExports)} | ||
export { namedExports as default } | ||
`), | ||
) |
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,33 @@ | ||
{ | ||
"name": "@pkgr/named-exports", | ||
"version": "0.0.0", | ||
"description": "Union `namedExports` definitions for rollup-plugin-commonjs", | ||
"repository": "git+https://github.com/rx-ts/pkgr.git", | ||
"homepage": "https://github.com/rx-ts/pkgr/blob/master/packages/named-exports", | ||
"author": "JounQin <admin@1stg.me>", | ||
"license": "MIT", | ||
"main": "lib/cjs", | ||
"module": "lib", | ||
"es2015": "lib/es2015", | ||
"fesm5": "lib/esm", | ||
"jsdelivr": "lib/umd", | ||
"unpkg": "lib/umd", | ||
"types": "lib", | ||
"files": [ | ||
"lib" | ||
], | ||
"keywords": [ | ||
"named-exports", | ||
"rollup", | ||
"rollup-config", | ||
"rollup-plugin", | ||
"rollup-plugin-commonjs" | ||
], | ||
"scripts": { | ||
"build": "ts-node -O '{\"module\":\"commonjs\"}' build" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"sideEffects": false | ||
} |
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,19 @@ | ||
import _, { namedExports } from '../index' | ||
|
||
describe('named exports', () => { | ||
it('default export and `namedExports` named export should be same exactly ', () => | ||
expect(_).toBe(namedExports)) | ||
|
||
it('should be a string array map', () => | ||
expect( | ||
Object.values(namedExports).every( | ||
exports => | ||
Array.isArray(exports) && exports.every(_ => typeof _ === 'string'), | ||
), | ||
).toBeTruthy()) | ||
|
||
it('should not include any private member nor property', () => | ||
expect( | ||
Object.values(namedExports).every(_ => _.every(_ => !/^[_$]/.test(_))), | ||
).toBeTruthy()) | ||
}) |
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,7 @@ | ||
{ | ||
"extends": "@1stg/tsconfig/composite", | ||
"compilerOptions": { | ||
"outDir": "lib" | ||
}, | ||
"files": ["index.ts"] | ||
} |
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 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 |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
"compilerOptions": { | ||
"outDir": "lib" | ||
}, | ||
"exclude": ["test"] | ||
"exclude": ["lib", "test"] | ||
} |
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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
{ | ||
"extends": "./tsconfig.base.json", | ||
"extends": "@1stg/tsconfig", | ||
"compilerOptions": { | ||
"incremental": false, | ||
"noEmit": true | ||
}, | ||
"references": [ | ||
{ | ||
"path": "packages/umd-globals" | ||
}, | ||
{ | ||
"path": "packages/named-exports" | ||
} | ||
] | ||
} |
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