Skip to content

Commit 91747aa

Browse files
authored
Merge pull request #149 from ankeetmaini/fix-bundle
Remove microbundle, use Rollup
2 parents 5c1a85c + 4997cf1 commit 91747aa

File tree

5 files changed

+124
-1981
lines changed

5 files changed

+124
-1981
lines changed

jest.config.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = {
2828
coverageDirectory: 'coverage',
2929

3030
// An array of regexp pattern strings used to skip coverage collection
31-
coveragePathIgnorePatterns: ['/node_modules/', 'stories'],
31+
coveragePathIgnorePatterns: ['/node_modules/', 'stories', 'dist'],
3232

3333
// A list of reporter names that Jest uses when writing coverage reports
3434
coverageReporters: ['lcov', 'text-summary'],
@@ -101,9 +101,7 @@ module.exports = {
101101
// rootDir: null,
102102

103103
// A list of paths to directories that Jest should use to search for files in
104-
// roots: [
105-
// "<rootDir>"
106-
// ],
104+
roots: ['src'],
107105

108106
// Allows you to use a custom runner instead of Jest's default test runner
109107
// runner: "jest-runner",

package.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"description": "An Infinite Scroll component in react.",
55
"source": "src/index.tsx",
66
"main": "dist/index.js",
7-
"module": "dist/index.mjs",
87
"unpkg": "dist/index.umd.js",
8+
"module": "dist/index.es.js",
99
"types": "dist/index.d.ts",
1010
"scripts": {
11-
"build": "microbundle",
11+
"build": "rimraf dist && rollup -c",
1212
"prepublish": "yarn build",
1313
"storybook": "start-storybook -p 6006",
1414
"build-storybook": "build-storybook",
@@ -64,13 +64,16 @@
6464
"husky": ">=1",
6565
"jest": "^24.9.0",
6666
"lint-staged": ">=8",
67-
"microbundle": "^0.11.0",
6867
"prettier": "1.18.2",
6968
"react": "^16.10.1",
7069
"react-docgen-typescript-loader": "^3.2.1",
7170
"react-dom": "^16.10.1",
71+
"rimraf": "^3.0.0",
72+
"rollup": "^1.26.3",
73+
"rollup-plugin-node-resolve": "^5.2.0",
74+
"rollup-plugin-typescript2": "^0.25.2",
7275
"ts-jest": "^24.1.0",
73-
"typescript": "^3.6.3"
76+
"typescript": "^3.7.2"
7477
},
7578
"dependencies": {
7679
"throttle-debounce": "^2.1.0"

rollup.config.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import resolve from 'rollup-plugin-node-resolve';
2+
import typescript from 'rollup-plugin-typescript2';
3+
import pkg from './package.json';
4+
export default {
5+
input: './src/index.tsx',
6+
output: [
7+
{
8+
file: pkg.main,
9+
format: 'cjs',
10+
sourcemap: true,
11+
},
12+
{
13+
file: pkg.module,
14+
format: 'es',
15+
sourcemap: true,
16+
},
17+
{
18+
file: pkg.unpkg,
19+
format: 'iife',
20+
sourcemap: true,
21+
name: 'InfiniteScroll',
22+
},
23+
],
24+
external: [...Object.keys(pkg.peerDependencies || {})],
25+
plugins: [resolve(), typescript({ useTsconfigDeclarationDir: true })],
26+
};

tsconfig.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
// "allowJs": true, /* Allow javascript files to be compiled. */
88
// "checkJs": true, /* Report errors in .js files. */
99
"jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
10-
// "declaration": true, /* Generates corresponding '.d.ts' file. */
10+
"declaration": true /* Generates corresponding '.d.ts' file. */,
11+
"declarationDir": "./dist",
1112
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
1213
// "sourceMap": true, /* Generates corresponding '.map' file. */
1314
// "outFile": "./", /* Concatenate and emit output to single file. */
@@ -57,5 +58,10 @@
5758
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
5859
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
5960
},
60-
"include": ["src/**/*", "lint-staged.config.js", "jest.config.js"]
61+
"include": [
62+
"src/**/*",
63+
"lint-staged.config.js",
64+
"jest.config.js",
65+
"rollup.config.js"
66+
]
6167
}

0 commit comments

Comments
 (0)