@@ -25,6 +25,7 @@ function bindgenResource(filePath) {
25
25
function typescriptBindings ( outputDir , buildDir , wasmBinaries , options , forNode = false ) {
26
26
// index module
27
27
let indexContent = ''
28
+ let indexCommonContent = ''
28
29
const nodeTextKebab = forNode ? '-node' : ''
29
30
const nodeTextCamel = forNode ? 'Node' : ''
30
31
@@ -53,7 +54,7 @@ function typescriptBindings (outputDir, buildDir, wasmBinaries, options, forNode
53
54
packageJson . module = `./dist/index.js`
54
55
packageJson . exports [ '.' ] . browser = `./dist/index.js`
55
56
packageJson . exports [ '.' ] . node = `./dist/index-node.js`
56
- packageJson . exports [ '.' ] . default = `./dist/index.js`
57
+ packageJson . exports [ '.' ] . default = `./dist/index-all .js`
57
58
if ( options . repository ) {
58
59
packageJson . repository = { 'type' : 'git' , 'url' : options . repository }
59
60
}
@@ -140,8 +141,8 @@ if (!params.has('functionName')) {
140
141
141
142
const { readmeOptions } = optionsModule ( srcOutputDir , interfaceJson , modulePascalCase , nodeTextCamel , moduleKebabCase , haveOptions )
142
143
if ( haveOptions ) {
143
- indexContent += `import ${ modulePascalCase } Options from './${ moduleKebabCase } -options.js'\n`
144
- indexContent += `export type { ${ modulePascalCase } Options }\n\n`
144
+ indexCommonContent += `import ${ modulePascalCase } Options from './${ moduleKebabCase } -options.js'\n`
145
+ indexCommonContent += `export type { ${ modulePascalCase } Options }\n\n`
145
146
}
146
147
147
148
const { readmeFunction, usedInterfaceTypes } = functionModule ( srcOutputDir , forNode , interfaceJson , modulePascalCase , moduleKebabCase , moduleCamelCase , nodeTextCamel , nodeTextKebab , haveOptions )
@@ -156,8 +157,8 @@ if (!params.has('functionName')) {
156
157
} )
157
158
158
159
if ( allUsedInterfaceTypes . size > 0 ) {
159
- indexContent += '\n'
160
- allUsedInterfaceTypes . forEach ( iType => indexContent += `export type { ${ iType } } from 'itk-wasm'\n` )
160
+ indexCommonContent += '\n'
161
+ allUsedInterfaceTypes . forEach ( iType => indexCommonContent += `export type { ${ iType } } from 'itk-wasm'\n` )
161
162
}
162
163
163
164
if ( ! forNode ) {
@@ -168,9 +169,25 @@ if (!params.has('functionName')) {
168
169
readmeInterface += `} from "${ packageName } "\n\`\`\`\n`
169
170
readmeInterface += readmePipelines
170
171
171
- const indexPath = path . join ( srcOutputDir , `index${ nodeTextKebab } .ts` )
172
+ const indexPath = path . join ( srcOutputDir , `index${ nodeTextKebab } -only .ts` )
172
173
writeIfOverrideNotPresent ( indexPath , indexContent )
173
174
175
+ const indexCommonPath = path . join ( srcOutputDir , `index-common.ts` )
176
+ writeIfOverrideNotPresent ( indexCommonPath , indexCommonContent )
177
+
178
+ const indexEnvContent = `export * from './index-common.js'
179
+ export * from './index${ nodeTextKebab } -only.js'
180
+ `
181
+ const indexEnvPath = path . join ( srcOutputDir , `index${ nodeTextKebab } .ts` )
182
+ writeIfOverrideNotPresent ( indexEnvPath , indexEnvContent )
183
+
184
+ const indexAllContent = `export * from './index-common.js'
185
+ export * from './index-only.js'
186
+ export * from './index-node-only.js'
187
+ `
188
+ const indexAllPath = path . join ( srcOutputDir , `index-all.ts` )
189
+ writeIfOverrideNotPresent ( indexAllPath , indexAllContent )
190
+
174
191
if ( ! forNode ) {
175
192
const demoIndexPath = path . join ( outputDir , 'test' , 'browser' , 'demo-app' , 'index.html' )
176
193
let demoIndexContent = fs . readFileSync ( bindgenResource ( path . join ( 'demo-app' , 'index.html' ) ) , { encoding : 'utf8' , flag : 'r' } )
0 commit comments