Skip to content

Commit

Permalink
feat: introduce code splitting to component library
Browse files Browse the repository at this point in the history
  • Loading branch information
HarveyD committed Apr 29, 2020
1 parent 1bcf738 commit 94631be
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "react-component-library",
"version": "1.0.0",
"main": "build/index.js",
"module": "build/index.esm.js",
"files": [
"build"
],
Expand Down
16 changes: 5 additions & 11 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
import sass from "rollup-plugin-sass";
import copy from "rollup-plugin-copy";

import packageJson from "./package.json";

export default {
input: "src/index.ts",
input: ["src/index.ts", "src/TestComponent/index.ts"],
output: [
{
file: packageJson.main,
dir: "build",
format: "cjs",
sourcemap: true
},
{
file: packageJson.module,
format: "esm",
sourcemap: true
}
],
preserveModules: true, // Important if we want to code split
plugins: [
peerDepsExternal(),
resolve(),
Expand Down
3 changes: 3 additions & 0 deletions src/TestComponent/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import TestComponent from "./TestComponent";

export default TestComponent;
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import TestComponent from "./TestComponent/TestComponent";
import TestComponent from "./TestComponent";

export { TestComponent };

0 comments on commit 94631be

Please sign in to comment.