Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
fix: reorganize exports to get default export working (#295)
Browse files Browse the repository at this point in the history
* fix: reorganize exports to get default export working

* fix: tests + lint
  • Loading branch information
kanadgupta committed Sep 25, 2023
1 parent 1424f7c commit 1a2dfa2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import path from 'node:path';
import fetchMock from 'fetch-mock';
import { describe, afterEach, beforeAll, beforeEach, it, expect } from 'vitest';

import OASNormalize, { getAPIDefinitionType, isAPIDefinition } from '../src';
import { isOpenAPI, isPostman, isSwagger } from '../src/lib/utils';
import OASNormalize from '../src';
import { getAPIDefinitionType, isAPIDefinition, isOpenAPI, isPostman, isSwagger } from '../src/lib/utils';

function cloneObject(obj) {
return JSON.parse(JSON.stringify(obj));
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"require": "./dist/index.cjs",
"import": "./dist/index.js"
},
"./lib/types": {
"require": "./dist/lib/types.cjs",
"import": "./dist/lib/types.js"
},
"./lib/utils": {
"require": "./dist/lib/utils.cjs",
"import": "./dist/lib/utils.js"
Expand Down
11 changes: 2 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Options } from './lib/types';
import type { OpenAPI } from 'openapi-types';

import fs from 'node:fs';
Expand All @@ -9,14 +10,6 @@ import converter from 'swagger2openapi';

import * as utils from './lib/utils';

export interface Options {
colorizeErrors?: boolean;
enablePaths?: boolean;
}

export const isAPIDefinition = utils.isAPIDefinition;
export const getAPIDefinitionType = utils.getAPIDefinitionType;

export default class OASNormalize {
cache: {
bundle?: false | OpenAPI.Document;
Expand Down Expand Up @@ -215,7 +208,7 @@ export default class OASNormalize {
*/
version() {
return this.load().then(schema => {
switch (getAPIDefinitionType(schema)) {
switch (utils.getAPIDefinitionType(schema)) {
case 'openapi':
return {
specification: 'openapi',
Expand Down
4 changes: 4 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface Options {
colorizeErrors?: boolean;
enablePaths?: boolean;
}
3 changes: 1 addition & 2 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ export default defineConfig((options: Options) => ({
cjsInterop: true,
clean: true,
dts: true,
entry: ['src/lib/utils.ts', 'src/index.ts'],
entry: ['src/index.ts', 'src/lib/types.ts', 'src/lib/utils.ts'],
format: ['esm', 'cjs'],
minify: false,
shims: true,
silent: !options.watch,
sourcemap: true,
splitting: true,
treeshake: true,
}));

0 comments on commit 1a2dfa2

Please sign in to comment.