@@ -29,6 +29,16 @@ const packageJSON = JSON.parse(
2929 readFileSync ( path . resolve ( __dirname , '../package.json' ) )
3030) ;
3131
32+ // Read component-level package.json if it exists
33+ let componentPackageJSON = { } ;
34+ try {
35+ componentPackageJSON = JSON . parse (
36+ readFileSync ( path . resolve ( process . cwd ( ) , 'package.json' ) )
37+ ) ;
38+ } catch ( e ) {
39+ // No component package.json, use empty object
40+ }
41+
3242/**
3343 * build function
3444 */
@@ -131,15 +141,21 @@ function getTsCompilerOptions() {
131141 * @returns
132142 */
133143function getRollupConfig ( input , rootDir , outDir ) {
144+ // Merge dependencies from both main package.json and component package.json
145+ const allDependencies = {
146+ ...packageJSON . peerDependencies ,
147+ ...packageJSON . dependencies ,
148+ ...packageJSON . devDependencies ,
149+ ...componentPackageJSON . peerDependencies ,
150+ ...componentPackageJSON . dependencies ,
151+ ...componentPackageJSON . devDependencies ,
152+ } ;
153+
134154 return {
135155 input,
136156 // Mark dependencies listed in `package.json` as external so that they are
137157 // not included in the output bundle.
138- external : [
139- ...Object . keys ( packageJSON . peerDependencies ) ,
140- ...Object . keys ( packageJSON . dependencies ) ,
141- ...Object . keys ( packageJSON . devDependencies ) ,
142- ] . map ( ( name ) => {
158+ external : Object . keys ( allDependencies ) . map ( ( name ) => {
143159 // Transform the name of each dependency into a regex so that imports from
144160 // nested paths are correctly marked as external.
145161 //
0 commit comments