fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #2415 from hey-api/fix/cjs-build

fix: cjs build

authored by

Lubos and committed by
GitHub
739a18df f55a54bd

+5 -9
+5 -9
packages/openapi-ts/src/generate/client.ts
··· 1 1 import fs from 'node:fs'; 2 - import { createRequire } from 'node:module'; 3 2 import path from 'node:path'; 3 + import { fileURLToPath } from 'node:url'; 4 4 5 5 import ts from 'typescript'; 6 6 ··· 12 12 import { splitNameAndExtension } from './file'; 13 13 import { ensureDirSync, relativeModulePath } from './utils'; 14 14 15 - // Use require.resolve to find the package root, then construct the path 16 - // This approach works with Yarn PnP and doesn't rely on specific file exports 17 - const packageRoot = path.dirname( 18 - createRequire(import.meta.url).resolve('@hey-api/openapi-ts/package.json'), 19 - ); 15 + const __filename = fileURLToPath(import.meta.url); 16 + const __dirname = path.dirname(__filename); 20 17 21 18 const getClientSrcPath = (name: string) => { 22 19 const pluginFilePathComponents = name.split(path.sep); ··· 161 158 // copy client core 162 159 const coreOutputPath = path.resolve(outputPath, 'core'); 163 160 ensureDirSync(coreOutputPath); 164 - const coreDistPath = path.resolve(packageRoot, 'dist', 'clients', 'core'); 161 + const coreDistPath = path.resolve(__dirname, 'clients', 'core'); 165 162 copyRecursivePnP(coreDistPath, coreOutputPath); 166 163 167 164 if (!legacy) { ··· 179 176 ensureDirSync(clientOutputPath); 180 177 const clientDistFolderName = plugin.name.slice('@hey-api/client-'.length); 181 178 const clientDistPath = path.resolve( 182 - packageRoot, 183 - 'dist', 179 + __dirname, 184 180 'clients', 185 181 clientDistFolderName, 186 182 );