Skip to content

Commit

Permalink
Merge pull request #131 from rei/pr/tree-shaking
Browse files Browse the repository at this point in the history
Allows the Cedar library to be tree shaken in consuming applications
  • Loading branch information
benjag committed May 3, 2023
2 parents d68f0ca + f2e3209 commit 05069a5
Show file tree
Hide file tree
Showing 10 changed files with 3,910 additions and 2,911 deletions.
6,784 changes: 3,890 additions & 2,894 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rei/cedar",
"version": "13.3.2",
"version": "13.4.0",
"description": "REI Cedar Component Library",
"homepage": "https://rei.github.io/rei-cedar/",
"license": "MIT",
Expand All @@ -13,10 +13,10 @@
},
"author": "REI Software Engineering",
"main": "./dist/cedar.umd.js",
"module": "./dist/cedar.mjs",
"module": "./dist/src/lib.mjs",
"exports": {
".": {
"import": "./dist/cedar.mjs",
"import": "./dist/src/lib.mjs",
"require": "./dist/cedar.umd.js"
},
"./dist/": "./dist/"
Expand Down Expand Up @@ -118,15 +118,11 @@
}
},
"dependencies": {
"core-js": "^3.22.7",
"lodash-es": "^4.17.21",
"tabbable": "^4.0.0",
"vue": "^3.2.23"
"tabbable": "^4.0.0"
},
"peerDependencies": {
"core-js": "^3.22.7",
"lodash-es": "^4.17.21",
"tabbable": "^4.0.0",
"vue": "^3.2.23"
}
}
9 changes: 7 additions & 2 deletions rollupOptions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import { babel } from '@rollup/plugin-babel';
import browserTargets from './browserTargets.mjs';

export default {
external: ['vue', 'core-js', 'lodash-es', 'tabbable'], // Externalize peerDependencies
// external: ['vue', 'core-js', 'lodash-es', 'tabbable'], // Externalize peerDependencies
external: (id) => ['vue', 'core-js', 'lodash-es', 'tabbable'].some(
(dep) => dep === id || id.startsWith(`${dep}/`),
),
output: {
globals: {
vue: 'Vue',
},
preserveModules: true,
},
plugins: [
babel({
Expand All @@ -21,7 +25,8 @@ export default {
{
modules: false, // don't convert ESM modules, as that breaks tree shaking
targets: browserTargets, // polyfill based on supported browsers
corejs: { // use corejs@3 for polyfills
corejs: {
// use corejs@3 for polyfills
version: '3.26', // see https://github.com/zloirock/core-js#babelpreset-env
},
useBuiltIns: 'usage', // polyfill based on usage in source code.
Expand Down
2 changes: 1 addition & 1 deletion src/components/accordion/CdrAccordionGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {
defineComponent, useCssModule, computed, ref, reactive, onMounted, provide,
} from 'vue';
import debounce from 'lodash-es/debounce';
import { debounce } from 'lodash-es';
import propValidator from '../../utils/propValidator';
import getCurrentBreakpoint from '../../mixins/breakpoints';
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/CdrModal.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import debounce from 'lodash-es/debounce';
import { debounce } from 'lodash-es';
import tabbable from 'tabbable';
import {
useCssModule, computed, ref, watch, onMounted, nextTick, onUnmounted, defineComponent,
Expand Down
2 changes: 1 addition & 1 deletion src/components/popup/CdrPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {
defineComponent, useCssModule, computed, ref, watch, nextTick, onMounted, onUnmounted,
} from 'vue';
import debounce from 'lodash-es/debounce';
import { debounce } from 'lodash-es';
import propValidator from '../../utils/propValidator';
import calculatePlacement from './calculatePlacement';
import mapClasses from '../../utils/mapClasses';
Expand Down
2 changes: 1 addition & 1 deletion src/components/tabs/CdrTabPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {
computed, defineComponent, inject, useCssModule, watch,
} from 'vue';
import kebabCase from 'lodash-es/kebabCase';
import { kebabCase } from 'lodash-es';
export default defineComponent({
name: 'CdrTabPanel',
Expand Down
2 changes: 1 addition & 1 deletion src/components/tabs/CdrTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {
defineComponent, ref, provide, onMounted, nextTick, computed, useCssModule,
} from 'vue';
import debounce from 'lodash-es/debounce';
import { debounce } from 'lodash-es';
import {
CdrColorBackgroundPrimary, CdrSpaceOneX, CdrSpaceHalfX,
} from '@rei/cdr-tokens/dist/js/cdr-tokens.mjs';
Expand Down
2 changes: 1 addition & 1 deletion src/dev/SinkWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<script>
import { CdrRadio } from 'srcdir/lib';
import upperFirst from 'lodash-es/upperFirst';
import { upperFirst } from 'lodash-es';
export default {
name: 'SinkWrapper',
Expand Down
4 changes: 3 additions & 1 deletion vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { fileURLToPath, URL } from 'url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
// import path from 'path';
import options from './rollupOptions.mjs';

const version = process.env.npm_package_version;
Expand All @@ -12,7 +13,8 @@ export default defineConfig({
build: {
lib: {
entry: './src/lib.js',
name: 'cedar',
formats: ['es'],
fileName: '[name]',
},
rollupOptions: options,
},
Expand Down

0 comments on commit 05069a5

Please sign in to comment.