@@ -27,10 +27,13 @@ module.exports = defineConfig({
2727 * Fetch a list of all the component workspaces using a glob pattern
2828 * @type {string[] } components
2929 */
30- const components = fg . sync ( '{packages,tools}/*' , {
31- cwd : __dirname ,
32- onlyDirectories : true ,
33- } ) ;
30+ const components = fg . sync (
31+ '{1st-gen/{packages,tools},2nd-gen/packages}/*' ,
32+ {
33+ cwd : __dirname ,
34+ onlyDirectories : true ,
35+ }
36+ ) ;
3437
3538 /**
3639 * This function checks the workspace for any local package references
@@ -101,9 +104,14 @@ module.exports = defineConfig({
101104 * to simplify into a readable set of operations
102105 * @param {Workspace } workspace
103106 * @param {string } folderName
107+ * @param {boolean } is2ndGen
104108 * @returns {void }
105109 */
106- function validateComponentPackageJson ( workspace , folderName ) {
110+ function validateComponentPackageJson (
111+ workspace ,
112+ folderName ,
113+ is2ndGen = false
114+ ) {
107115 // Only update the homepage if it does not already exist
108116 if ( ! workspace . manifest . homepage ) {
109117 workspace . set (
@@ -112,24 +120,32 @@ module.exports = defineConfig({
112120 ) ;
113121 }
114122
115- workspace . set ( 'publishConfig.access' , 'public' ) ;
116123 workspace . set ( 'type' , 'module' ) ;
124+ workspace . set ( 'publishConfig.access' , 'public' ) ;
117125 workspace . set ( 'keywords' , keywords ( [ 'component' , 'css' ] ) ) ;
118126
119- // A subset of components have a different entry point than the default
120- if (
121- [
122- 'clear-button' ,
123- 'close-button' ,
124- 'modal' ,
125- 'opacity-checkerboard' ,
126- ] . includes ( folderName )
127- ) {
128- workspace . set ( 'main' , `./src/${ folderName } .css.js` ) ;
129- workspace . set ( 'module' , `./src/${ folderName } .css.js` ) ;
127+ // 2nd-gen packages use different entry points
128+ if ( is2ndGen ) {
129+ // 2nd-gen uses dist folder for builds
130+ workspace . set ( 'main' , './dist/index.js' ) ;
131+ workspace . set ( 'module' , './dist/index.js' ) ;
130132 } else {
131- workspace . set ( 'main' , './src/index.js' ) ;
132- workspace . set ( 'module' , './src/index.js' ) ;
133+ // 1st-gen packages use src folder
134+ // A subset of components have a different entry point than the default
135+ if (
136+ [
137+ 'clear-button' ,
138+ 'close-button' ,
139+ 'modal' ,
140+ 'opacity-checkerboard' ,
141+ ] . includes ( folderName )
142+ ) {
143+ workspace . set ( 'main' , `./src/${ folderName } .css.js` ) ;
144+ workspace . set ( 'module' , `./src/${ folderName } .css.js` ) ;
145+ } else {
146+ workspace . set ( 'main' , './src/index.js' ) ;
147+ workspace . set ( 'module' , './src/index.js' ) ;
148+ }
133149 }
134150 }
135151
@@ -245,8 +261,10 @@ module.exports = defineConfig({
245261 * Process the components workspaces with component-specific configuration
246262 */
247263 if ( isComponent ) {
248- const folderName = workspace . cwd ?. split ( '/' ) ?. [ 1 ] ;
249- validateComponentPackageJson ( workspace , folderName ) ;
264+ // Get the last part of the path (e.g., 'button' from '1st-gen/packages/button')
265+ const folderName = workspace . cwd ?. split ( '/' ) . pop ( ) ;
266+ const is2ndGen = workspace . cwd . startsWith ( '2nd-gen/' ) ;
267+ validateComponentPackageJson ( workspace , folderName , is2ndGen ) ;
250268 validateLocalPackages ( workspace ) ;
251269 } else {
252270 /**
0 commit comments