Skip to content

Commit a825fa7

Browse files
fix: install-peers and gitignore improvements
1 parent edeb636 commit a825fa7

11 files changed

+104
-42
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ node_modules
33
dist
44
.rpt2_cache
55

6-
example-nextjs/src/reactComponentLib
6+
example-nextjs/src/react-component-lib

.travis.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

LICENSE

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
Copyright (c) 2017 [these people](https://github.com/rollup/rollup-starter-lib/graphs/contributors)
1+
MIT License
22

3-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3+
Copyright (c) 2024 Michał Wrzosek
44

5-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
611

7-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ npm i
1616
It will install:
1717

1818
- `dependencies` and `devDependencies` from ./package.json
19-
- `peerDependencies` from ./package.json thanks to `install-peers-cli`
19+
- `peerDependencies` from ./package.json thanks to `install-peers`
2020
- `dependencies` and `devDependencies` from ./example-nextjs/package.json (example `nextjs` app for testing)
2121

2222
## Developing your library:
2323

24-
To start developing your library, run `npm run dev`. It will build your library and run example `nextjs` where you can test your components. Each time you make changes to your library or example app, app will be reloaded to reflect your changes.
24+
To start developing your library, run `npm run dev`. It will build your library and run example `nextjs` app where you can test your components. Each time you make changes to your library or example app, app will be reloaded to reflect your changes.
2525

2626
## Styled-components:
2727

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default [
1414
settings: { react: { version: 'detect' } },
1515
},
1616
{
17-
ignores: ['node_modules', 'dist', '.git', 'dist', 'reactComponentLib'],
17+
ignores: ['node_modules', 'dist', '.git', 'dist', 'react-component-lib'],
1818
},
1919
eslintPluginPrettierRecommended,
2020
{

example-nextjs/src/app/client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { TestComponent } from '@/reactComponentLib';
3+
import { TestComponent } from '@/react-component-lib';
44
import styled from 'styled-components';
55

66
const StyledDiv = styled.div`

next-env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.

package-lock.json

Lines changed: 33 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"name": "react-component-lib",
33
"version": "1.0.0",
4-
"main": "dist/index.cjs.js",
5-
"module": "dist/index.esm.js",
4+
"module": "dist/index.js",
65
"repository": {
76
"url": "https://github.com/michal-wrzosek/react-component-lib",
87
"type": "git"
@@ -21,23 +20,24 @@
2120
"eslint-plugin-prettier": "^5.2.1",
2221
"eslint-plugin-react": "^7.35.0",
2322
"globals": "^15.9.0",
24-
"install-peers-cli": "^2.2.0",
23+
"install-peers": "^1.0.4",
2524
"prettier": "^3.3.3",
2625
"rollup": "^4.20.0",
26+
"rollup-preserve-directives": "^1.1.1",
2727
"ts-node": "^10.9.2",
2828
"typescript": "^5.5.4",
2929
"typescript-eslint": "^8.0.1"
3030
},
3131
"peerDependencies": {
32-
"react": "^18.3.1",
33-
"react-dom": "^18.3.1",
32+
"react": "^18",
33+
"react-dom": "^18",
3434
"styled-components": "^6.1.12"
3535
},
3636
"scripts": {
3737
"build": "rollup -c",
3838
"build-watch": "rollup -c -w",
3939
"prepublishOnly": "npm run build",
40-
"postinstall": "install-peers -f && cd example-nextjs && npm i",
40+
"prepare": "cd example-nextjs && npm i",
4141
"start-example": "cd example-nextjs && npm run dev",
4242
"deploy-example": "npm run build && cd example-nextjs && npm run deploy",
4343
"dev": "concurrently --kill-others \"npm run build-watch\" \"npm run start-example\"",

rollup.config.mjs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import typescript from '@rollup/plugin-typescript';
2+
import preserveDirectives from 'rollup-preserve-directives';
23
import fs from 'fs';
34

45
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
@@ -8,17 +9,32 @@ export default [
89
input: 'src/index.ts',
910
external: Object.keys(pkg.peerDependencies || {}),
1011
plugins: [
12+
preserveDirectives(),
1113
typescript({
1214
sourceMap: false,
15+
tsconfig: './tsconfig.json',
16+
}),
17+
],
18+
output: [{ dir: 'dist', format: 'esm', preserveModules: true, preserveModulesRoot: 'src' }],
19+
},
20+
{
21+
input: 'src/index.ts',
22+
external: Object.keys(pkg.peerDependencies || {}),
23+
plugins: [
24+
preserveDirectives(),
25+
typescript({
26+
sourceMap: false,
27+
tsconfig: './tsconfig.example-nextjs.json',
28+
declarationDir: 'example-nextjs/src/react-component-lib',
1329
}),
1430
],
1531
output: [
16-
{ file: pkg.main, format: 'cjs' },
17-
{ file: pkg.module, format: 'esm' },
1832
{
19-
file: 'example-nextjs/src/reactComponentLib/index.js',
33+
dir: 'example-nextjs/src/react-component-lib',
2034
format: 'es',
2135
banner: '/* eslint-disable */',
36+
preserveModules: true,
37+
preserveModulesRoot: 'src',
2238
},
2339
],
2440
},

tsconfig.example-nextjs.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"declaration": true,
4+
"declarationDir": "./dist",
5+
"strict": true,
6+
"allowSyntheticDefaultImports": true,
7+
"sourceMap": true,
8+
"noUnusedParameters": true,
9+
"strictNullChecks": true,
10+
"moduleResolution": "node",
11+
"noImplicitAny": true,
12+
"outDir": "./example-nextjs/src/react-component-lib",
13+
"target": "es5",
14+
"jsx": "react"
15+
},
16+
"include": ["next-env.d.ts", "src/**/*"],
17+
"exclude": ["node_modules"]
18+
}

0 commit comments

Comments
 (0)