@@ -4,7 +4,6 @@ SPDX-License-Identifier: GPL-3.0-only */
44import { PACKAGE_OUTPUT , TEMP_BUILD_OUTPUT } from 'consts'
55import fs from 'fs/promises'
66import { dirname , join } from 'path'
7- import type { Bundler } from 'types'
87import { fileURLToPath } from 'url'
98
109// Gets workspace directory from the current directory
@@ -87,15 +86,7 @@ export const getTemplate = async (name: string) => {
8786// Generate package package.json file from source package.json
8887export const generatePackageJson = async (
8988 inputDir : string ,
90- outputDir : string ,
91- bundler : Bundler | null ,
92- additionalExports : Record <
93- string ,
94- {
95- import : string
96- require : string
97- }
98- > = { }
89+ outputDir : string
9990) : Promise < boolean > => {
10091 try {
10192 // Read the original package.json.
@@ -120,22 +111,17 @@ export const generatePackageJson = async (
120111
121112 // Attempt to get exports and bundler info
122113 let pkgConfig
123- let configBundler = bundler // Use the passed bundler as fallback
124114 try {
125115 pkgConfig = JSON . parse (
126116 await fs . readFile ( join ( inputDir , 'pkg.config.json' ) , 'utf8' )
127117 )
128- // If bundler info is available in config, use it (unless explicitly overridden)
129- if ( 'bundler' in pkgConfig && bundler === null ) {
130- configBundler = pkgConfig . bundler
131- }
132118 } catch ( e ) {
133119 // Silently fail getting exports
134120 }
135121
136122 // Construct the minimal package.json object
137123 // eslint-disable-next-line @typescript-eslint/no-explicit-any
138- let minimalPackageJson : any = {
124+ const minimalPackageJson : any = {
139125 name : packageName ,
140126 version,
141127 license,
@@ -159,33 +145,9 @@ export const generatePackageJson = async (
159145 minimalPackageJson . bugs = bugs
160146 }
161147
162- if ( configBundler === 'gulp' ) {
163- minimalPackageJson = {
164- ...minimalPackageJson ,
165- exports : pkgConfig ?. exports || {
166- '.' : {
167- import : './mjs/index.js' ,
168- require : './cjs/index.js' ,
169- } ,
170- ...additionalExports ,
171- } ,
172- }
173- } else if ( configBundler === 'tsup' ) {
174- minimalPackageJson = {
175- ...minimalPackageJson ,
176- exports : pkgConfig ?. exports || {
177- '.' : {
178- import : './index.js' ,
179- require : './index.cjs' ,
180- } ,
181- ...additionalExports ,
182- } ,
183- }
184- } else {
185- // For custom bundlers, null, or any other case, include exports if provided
186- if ( pkgConfig ?. exports ) {
187- minimalPackageJson . exports = pkgConfig . exports
188- }
148+ // Include package exports if provided
149+ if ( pkgConfig ?. exports ) {
150+ minimalPackageJson . exports = pkgConfig . exports
189151 }
190152
191153 if ( dependencies ) {
@@ -194,6 +156,7 @@ export const generatePackageJson = async (
194156 if ( peerDependencies ) {
195157 minimalPackageJson [ 'peerDependencies' ] = peerDependencies
196158 }
159+
197160 if ( pkgConfig ?. peerDependencies ) {
198161 minimalPackageJson [ 'peerDependencies' ] = {
199162 ...minimalPackageJson [ 'peerDependencies' ] ,
0 commit comments