Skip to content

Commit

Permalink
fix: Use peer-deps plugin to avoid bundling dependencies and their ev…
Browse files Browse the repository at this point in the history
…entual subfolders
  • Loading branch information
cgero-eth committed Mar 15, 2024
1 parent f508378 commit 2b75f10
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Update `Tag` component primary variant styling
- Update Eslint rules to align usage of boolean properties

### Fixed

- Library build process to avoid bundling dependencies and peer-dependencies when using subfolders import (e.g.
`wagmi/chains`)

## [1.0.20] - 2024-03-13

### Fixed
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rollup": "^4.12.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-visualizer": "^5.12.0",
"storybook": "^7.6.17",
Expand Down
6 changes: 4 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const commonjs = require('@rollup/plugin-commonjs');
const images = require('@rollup/plugin-image');
const { nodeResolve } = require('@rollup/plugin-node-resolve');
const peerDepsExternal = require('rollup-plugin-peer-deps-external');
const terser = require('@rollup/plugin-terser');
const typescript = require('@rollup/plugin-typescript');
const { visualizer } = require('rollup-plugin-visualizer');
Expand All @@ -10,7 +11,6 @@ const postcss = require('rollup-plugin-postcss');
const tsConfig = require('./tsconfig.json');
const { outDir } = tsConfig.compilerOptions;

const package = require('./package.json');
const analyze = process.env.ANALYZE === 'true';

module.exports = [
Expand All @@ -36,8 +36,10 @@ module.exports = [
plugins: [analyze ? visualizer({ filename: 'stats.cjs.html', open: true }) : undefined],
},
],
external: [...Object.keys(package.dependencies), ...Object.keys(package.peerDependencies)],
plugins: [
// Mark all dependencies / peer-dependencies as external to not include them on the library build
peerDepsExternal({ includeDependencies: true }),

// Locate and resolve node modules
nodeResolve(),

Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12494,6 +12494,11 @@ rimraf@~2.6.2:
dependencies:
glob "^7.1.3"

rollup-plugin-peer-deps-external@^2.2.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/rollup-plugin-peer-deps-external/-/rollup-plugin-peer-deps-external-2.2.4.tgz#8a420bbfd6dccc30aeb68c9bf57011f2f109570d"
integrity sha512-AWdukIM1+k5JDdAqV/Cxd+nejvno2FVLVeZ74NKggm3Q5s9cbbcOgUPGdbxPi4BXu7xGaZ8HG12F+thImYu/0g==

rollup-plugin-postcss@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/rollup-plugin-postcss/-/rollup-plugin-postcss-4.0.2.tgz#15e9462f39475059b368ce0e49c800fa4b1f7050"
Expand Down

0 comments on commit 2b75f10

Please sign in to comment.