import type { BuildOptions } from '../../../helpers/compile/build' ; import { build } from '../../../helpers/compile/build' ; import { fillPlugin } from '../../../helpers/compile/plugins/fill-plugin/fillPlugin' ; import { Extractor , ExtractorConfig } from '@microsoft/api-extractor' ; import path from 'path' ; const external = [ '_http_common' ] ; const generatorBuildConfig = { entryPoints : [ 'src/generation/generator.ts' ] , outfile : 'generator-build/index' , bundle : true , external : external , } ; const runtimeBuildConfig = { entryPoints : [ 'src/runtime/index.ts' ] , outfile : 'runtime/index' , bundle : true , external : external , define : { 'globalThis.NOT_PRISMA_DATA_PROXY' : 'true' , 'define.amd' : 'false' , } , } ; const browserBuildConfig = { entryPoints : [ 'src/runtime/index-browser.ts' ] , outfile : 'runtime/index-browser' , target : [ 'chrome58' , 'firefox57' , 'safari11' , 'edge16' ] , bundle : true , external : external , } ; const proxyBuildConfig = { entryPoints : [ 'src/runtime/index.ts' ] , outfile : 'runtime/proxy' , bundle : true , minify : true , legalComments : 'none' , external : external , define : { 'globalThis.NOT_PRISMA_DATA_PROXY' : 'false' , 'define.amd' : 'false' , } , plugins : [ fillPlugin ( { '@prisma/get-platform' : { contents : '' } , 'supports-color' : { contents : '' } , './warnEnvConflicts' : { contents : '' } , './utils/find' : { contents : '' } , } , ( options ) => options . format === 'esm' ) , ] , logLevel : 'error' , } ; param filename param outfile function bundleTypeDefinitions ( filename , outfile ) { const extractorConfig = ExtractorConfig . prepare ( { configObject : { projectFolder : path . join ( __dirname , '..' ) , mainEntryPointFilePath : `${ filename }.d.ts` , bundledPackages : [ 'decimal.js' , 'sql-template-tag' , '@prisma/sdk' , '@prisma/engine-core' , '@prisma/generator-helper' , ] , compiler : { tsconfigFilePath : 'tsconfig.build.json' , } , dtsRollup : { enabled : true , untrimmedFilePath : `${ outfile }.d.ts` , } , tsdocMetadata : { enabled : false , } , } , packageJsonFullPath : path . join ( __dirname , '..' , 'package.json' ) , configObjectFullPath : undefined , } ) ; const extractorResult = Extractor . invoke ( extractorConfig , { showVerboseMessages : true , localBuild : true , } ) ; if ( extractorResult . succeeded === false ) { console . error ( `API Extractor completed with errors` ) ; process . exit ( 1 ) ; } } void build ( [ generatorBuildConfig , runtimeBuildConfig , browserBuildConfig , proxyBuildConfig ] ) . then ( ( ) => { if ( process . env . DEV !== 'true' ) { bundleTypeDefinitions ( 'declaration/runtime/index' , 'runtime/index' ) ; bundleTypeDefinitions ( 'declaration/runtime/index' , 'runtime/proxy' ) ; bundleTypeDefinitions ( 'declaration/runtime/index-browser' , 'runtime/index-browser' ) ; } } ) ;