Skip to content

Commit

Permalink
fix: Switch to rollup for library bundling (#49)
Browse files Browse the repository at this point in the history
* Forced the bundle to use commonjs2

* fix: Configured the publish to allow import without the extension

* fix: updated webpack config to solve issue with jest tests

* fix: switched from webpack to using rollup for bundling
  • Loading branch information
erwagasore authored Jul 11, 2020
1 parent 0bdd655 commit 863a803
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 14 deletions.
25 changes: 12 additions & 13 deletions packages/blocjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
"description": "Blocjs is a minimal structural set of components built with Styled System",
"author": "Team Pindo <[email protected]>",
"license": "MIT",
"main": "src/index.js",
"files": [
"dist"
],
"main": "dist/index.js",
"files": ["/dist"],
"scripts": {
"develop": "webpack --mode development --watch",
"build": "webpack --mode production"
"build": "rollup -c"
},
"dependencies": {
"@styled-system/css": "^5.1.5",
Expand All @@ -19,18 +16,20 @@
"devDependencies": {
"@babel/core": "^7.10.2",
"@babel/preset-env": "^7.10.2",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"babel-loader": "^8.1.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12",
"webpack-node-externals": "^1.7.2",
"@babel/preset-react": "^7.8.0",
"rollup": "^1.27.8",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-peer-deps-external": "^2.2.0",
"rollup-plugin-terser": "^5.1.2",
"rollup-plugin-uglify": "^6.0.3",
"styled-components": "^5.1.1"
},
"peerDependencies": {
"react": "^16.13.1",
"styled-components": "^5.1.1"
},
"repository": {
"repository": {
"type": "git",
"url": "git+https://github.com/pindoio/blocjs.git"
}
Expand Down
45 changes: 45 additions & 0 deletions packages/blocjs/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import babel from "rollup-plugin-babel";
import commonjs from "rollup-plugin-commonjs";
import resolve from "rollup-plugin-node-resolve";
import external from "rollup-plugin-peer-deps-external";
import { terser } from "rollup-plugin-terser";

import packageJSON from "./package.json";
const input = "./src/index.js";
const minifyExtension = pathToFile => pathToFile.replace(/\.js$/, ".min.js");

export default [
// CommonJS
{
input,
output: {
file: packageJSON.main,
format: "cjs"
},

plugins: [
babel({
exclude: "node_modules/**"
}),
external(),
resolve(),
commonjs()
]
},
{
input,
output: {
file: minifyExtension(packageJSON.main),
format: "cjs"
},
plugins: [
babel({
exclude: "node_modules/**"
}),
external(),
resolve(),
commonjs(),
terser()
]
}
];
2 changes: 1 addition & 1 deletion packages/blocjs/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { default as Box } from "./box";
export { default as Bloc } from "./bloc";
export { default as Flex } from "./flex";
export { default as Bloc } from "./bloc";

0 comments on commit 863a803

Please sign in to comment.