File tree Expand file tree Collapse file tree 2 files changed +2
-23
lines changed
packages/openapi-typescript Expand file tree Collapse file tree 2 files changed +2
-23
lines changed Original file line number Diff line number Diff line change 43
43
"build" : " run-s -s build:*" ,
44
44
"build:clean" : " del dist" ,
45
45
"build:esm" : " tsc -p tsconfig.build.json" ,
46
- "build:cjs" : " esbuild --bundle --platform=node --target=es2019 --outfile=dist/index.cjs --external:@redocly/ajv --external:@redocly/openapi-core --external:typescript src/index.ts --footer:js= \" module.exports = module.exports.default; \" " ,
46
+ "build:cjs" : " esbuild --bundle --platform=node --target=es2019 --outfile=dist/index.cjs --external:@redocly/ajv --external:@redocly/openapi-core --external:typescript src/index.ts" ,
47
47
"dev" : " tsc -p tsconfig.build.json --watch" ,
48
48
"download:schemas" : " vite-node ./scripts/download-schemas.ts" ,
49
49
"format" : " prettier --write \" src/**/*\" " ,
Original file line number Diff line number Diff line change 2
2
3
3
// important: MUST use require()!
4
4
const { fileURLToPath } = require ( "node:url" ) ;
5
- const ts = require ( "typescript" ) ;
6
- const openapiTS = require ( "../dist/index.cjs" ) ;
7
-
8
- // copy from lib/ts.ts for CJS
9
- function astToString ( ast , options ) {
10
- const sourceFile = ts . createSourceFile (
11
- options ?. fileName ?? "openapi-ts.ts" ,
12
- options ?. sourceText ?? "" ,
13
- ts . ScriptTarget . ESNext ,
14
- false ,
15
- ts . ScriptKind . TS ,
16
- ) ;
17
- sourceFile . statements = ts . factory . createNodeArray (
18
- Array . isArray ( ast ) ? ast : [ ast ] ,
19
- ) ;
20
- const printer = ts . createPrinter ( {
21
- newLine : ts . NewLineKind . LineFeed ,
22
- removeComments : false ,
23
- ...options ?. formatOptions ,
24
- } ) ;
25
- return printer . printFile ( sourceFile ) ;
26
- }
5
+ const { astToString, default : openapiTS } = require ( '../dist/index.cjs' ) ;
27
6
28
7
describe ( "CJS bundle" , ( ) => {
29
8
it ( "basic" , async ( ) => {
You can’t perform that action at this time.
0 commit comments