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

fix: reorganize exports to get default export working #295

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
}));