Skip to content

Commit b6aab5f

Browse files
committed
chore: upgrade to Rollup 4, TypeScript 5, drop throttle-debounce
Replace rollup.config.js with rollup.config.mjs, swap rollup v1 plugins for @rollup/plugin-node-resolve and @rollup/plugin-typescript, and remove the throttle-debounce runtime dependency.
1 parent e6d8fda commit b6aab5f

5 files changed

Lines changed: 258 additions & 161 deletions

File tree

package.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@
5656
"@storybook/addon-essentials": "^7.6.0",
5757
"@storybook/react": "^7.6.0",
5858
"@storybook/react-webpack5": "^7.6.0",
59+
"@rollup/plugin-node-resolve": "^15.0.0",
60+
"@rollup/plugin-typescript": "^11.0.0",
5961
"@testing-library/react": "^12.1.5",
6062
"@types/jest": "^29.5.14",
6163
"@types/react": "^17.0.0",
6264
"@types/react-dom": "^17.0.0",
63-
"@types/throttle-debounce": "^2.1.0",
6465
"@typescript-eslint/eslint-plugin": "^8.50.1",
6566
"@typescript-eslint/parser": "^8.50.1",
6667
"babel-loader": "^8.0.6",
@@ -75,17 +76,13 @@
7576
"react": "^17.0.2",
7677
"react-dom": "^17.0.2",
7778
"rimraf": "^3.0.0",
78-
"rollup": "^1.26.3",
79-
"rollup-plugin-node-resolve": "^5.2.0",
80-
"rollup-plugin-typescript2": "^0.25.2",
79+
"rollup": "^4.0.0",
8180
"size-limit": "^12.0.1",
8281
"storybook": "^7.6.0",
8382
"ts-jest": "^29.4.6",
84-
"typescript": "^4.9.0"
85-
},
86-
"dependencies": {
87-
"throttle-debounce": "^2.1.0"
83+
"typescript": "^5.4.0"
8884
},
85+
"dependencies": {},
8986
"size-limit": [
9087
{
9188
"path": "dist/index.es.js",

rollup.config.js

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

rollup.config.mjs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import resolve from '@rollup/plugin-node-resolve';
2+
import typescript from '@rollup/plugin-typescript';
3+
import { createRequire } from 'module';
4+
5+
const require = createRequire(import.meta.url);
6+
const pkg = require('./package.json');
7+
8+
export default {
9+
input: './src/index.tsx',
10+
output: [
11+
{
12+
file: pkg.main,
13+
format: 'cjs',
14+
sourcemap: true,
15+
},
16+
{
17+
file: pkg.module,
18+
format: 'es',
19+
sourcemap: true,
20+
},
21+
{
22+
file: pkg.unpkg,
23+
format: 'iife',
24+
sourcemap: true,
25+
name: 'InfiniteScroll',
26+
globals: {
27+
react: 'React',
28+
'react/jsx-runtime': 'ReactJSXRuntime',
29+
'react-dom': 'ReactDOM',
30+
},
31+
},
32+
],
33+
external: [...Object.keys(pkg.peerDependencies || {}), 'react/jsx-runtime'],
34+
plugins: [resolve(), typescript({ tsconfig: './tsconfig.json' })],
35+
};

tsconfig.json

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66
"lib": [
77
"ES2019",
88
"DOM"
9-
], /* Specify library files to be included in the compilation. */
9+
] /* Specify library files to be included in the compilation. */,
1010
// "allowJs": true, /* Allow javascript files to be compiled. */
1111
// "checkJs": true, /* Report errors in .js files. */
1212
"jsx": "react-jsx" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
1313
"declaration": true /* Generates corresponding '.d.ts' file. */,
1414
"declarationDir": "./dist",
15-
"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
16-
"sourceMap": true, /* Generates corresponding '.map' file. */
15+
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
16+
"sourceMap": true /* Generates corresponding '.map' file. */,
1717
// "outFile": "./", /* Concatenate and emit output to single file. */
18-
"outDir": "./dist", /* Redirect output structure to the directory. */
18+
"outDir": "./dist" /* Redirect output structure to the directory. */,
1919
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
2020
// "composite": true, /* Enable project compilation */
2121
// "removeComments": true, /* Do not emit comments to output. */
2222
// "noEmit": true, /* Do not emit outputs. */
2323
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
2424
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
25-
"isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
25+
"isolatedModules": true /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */,
2626
/* Strict Type-Checking Options */
2727
"strict": true /* Enable all strict type-checking options. */,
2828
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
@@ -43,11 +43,13 @@
4343
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
4444
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
4545
// "typeRoots": [], /* List of folders to include type definitions from. */
46-
// "types": [], /* Type declaration files to be included in compilation. */
46+
"types": [
47+
"jest"
48+
] /* Type declaration files to be included in compilation. */,
4749
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
4850
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
4951
"skipLibCheck": true,
50-
"forceConsistentCasingInFileNames": true,
52+
"forceConsistentCasingInFileNames": true
5153
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
5254
/* Source Map Options */
5355
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
@@ -58,14 +60,6 @@
5860
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
5961
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
6062
},
61-
"include": [
62-
"src/**/*",
63-
"lint-staged.config.js",
64-
"jest.config.js",
65-
"rollup.config.js"
66-
],
67-
"exclude": [
68-
"node_modules",
69-
"dist"
70-
]
71-
}
63+
"include": ["src/**/*", "lint-staged.config.js", "jest.config.js"],
64+
"exclude": ["node_modules", "dist"]
65+
}

0 commit comments

Comments
 (0)