Skip to content

Commit

Permalink
fix: updates rollup config for new bundling, adds missing input depen…
Browse files Browse the repository at this point in the history
…dencies
  • Loading branch information
Chris Friedberg authored and chrisfalaska committed Oct 7, 2024
1 parent 314a3d4 commit 7d4720e
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 15 deletions.
56 changes: 56 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
"node": "^18.x || ^20.x "
},
"dependencies": {
"@aurodesignsystem/auro-button": "^8.0.0",
"@aurodesignsystem/auro-formvalidation": "^1.0.3",
"@aurodesignsystem/auro-icon": "^5.0.0",
"@floating-ui/dom": "^1.6.11",
"cleave.js": "^1.6.0",
"lit": "^3.2.0"
},
"peerDependencies": {
Expand Down
42 changes: 27 additions & 15 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,45 @@ import path from 'path';

const production = !process.env.ROLLUP_WATCH;

// Function to get additional entry points
const getAdditionalEntryPoints = () => {
// Get entry points for each component
const getComponentEntryPoints = () => {
const files = glob.sync('src/*/index.js');
return files.reduce((acc, file) => {
return files.map(file => {
const name = path.basename(path.dirname(file));
acc[`${name}__bundled`] = file;
return acc;
}, {});
return {
name,
input: file,
output: `dist/${name}`
};
});
};

const modernConfig = {
input: {
['auro-form__bundled']: './index.js',
...getAdditionalEntryPoints()
},
const createConfig = (name, input, output) => ({
input: { [`${name}__bundled`]: input },
output: {
format: 'esm',
dir: 'dist/'
dir: output,
chunkFileNames: '[name]-[hash].js'
},
plugins: [
nodeResolve(),
nodeResolve({
browser: true,
dedupe: ['lit', 'lit-element', 'lit-html'],
preferBuiltins: false,
moduleDirectories: ['node_modules']
}),
!production &&
serve({
open: true,
openPage: '/docs/'
})
]
};
});

const mainConfig = createConfig('auro-form', './index.js', 'dist');

const componentConfigs = getComponentEntryPoints().map(({ name, input, output }) =>
createConfig(name, input, output)
);

export default [modernConfig];
export default [mainConfig, ...componentConfigs];

0 comments on commit 7d4720e

Please sign in to comment.