Skip to content

Commit

Permalink
refactor: consolidating our ts and tsup configs (#813)
Browse files Browse the repository at this point in the history
* refactor: consolidating our ts and tsup configs

* fix: removing `lib` from our base tsconfig

* fix: pr feedback

* fix: pr feedback

* fix: prettier issues

* fix: getting builds working

* fix: prettier issues
  • Loading branch information
erunion authored Oct 5, 2023
1 parent 8ae855f commit b7df260
Show file tree
Hide file tree
Showing 20 changed files with 78 additions and 89 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"private": true,
"scripts": {
"alex": "alex .",
"attw": "npx lerna run attw --stream",
"build": "npx lerna run build --stream",
"clean": "npx lerna clean",
"lint": "npm run lint:types && npm run lint:js && npm run prettier",
Expand Down
1 change: 1 addition & 0 deletions packages/oas-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"url": "https://github.com/readmeio/oas/issues"
},
"scripts": {
"attw": "attw --pack --format table-flipped",
"build": "tsup",
"lint": "npm run lint:types && npm run lint:js",
"lint:js": "eslint . --ext .js,.ts",
Expand Down
15 changes: 3 additions & 12 deletions packages/oas-extensions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
{
"compilerOptions": {
"allowJs": true,
"baseUrl": "./src/",
"declaration": true,
"esModuleInterop": true,
"module": "ESNext",
"moduleResolution": "bundler",
"noImplicitAny": true,
"outDir": "./dist",
"target": "ES2020"
},
"include": ["./src/**/*"]
"extends": "../../tsconfig.base.json",
"include": ["./src/**/*"],
"exclude": ["dist"]
}
12 changes: 3 additions & 9 deletions packages/oas-extensions/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ import type { Options } from 'tsup';
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from 'tsup';

import config from '../../tsup.config';

export default defineConfig((options: Options) => ({
...options,
...config,

cjsInterop: true,
clean: true,
dts: true,
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
minify: false,
shims: true,
silent: !options.watch,
splitting: true,
sourcemap: true,
treeshake: true,
}));
3 changes: 0 additions & 3 deletions packages/oas-normalize/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

"camelcase": ["error", { "allow": ["OpenAPIV3_1"] }],

// Does not play well with our `swagger2openapi` type sinkhole.
"import/order": "off",

"no-case-declarations": "off",

"unicorn/prefer-node-protocol": "error"
Expand Down
2 changes: 2 additions & 0 deletions packages/oas-normalize/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"url": "https://github.com/readmeio/oas/issues"
},
"scripts": {
"attw": "attw --pack --format table-flipped",
"build": "tsup",
"lint": "npm run lint:types && npm run lint:js",
"lint:js": "eslint . --ext .js,.ts",
Expand All @@ -71,6 +72,7 @@
"devDependencies": {
"@readme/oas-examples": "^5.12.0",
"@types/js-yaml": "^4.0.5",
"@types/swagger2openapi": "^7.0.1",
"@vitest/coverage-v8": "^0.34.1",
"eslint": "^8.46.0",
"fetch-mock": "^9.11.0",
Expand Down
2 changes: 0 additions & 2 deletions packages/oas-normalize/src/.sink.d.ts

This file was deleted.

18 changes: 5 additions & 13 deletions packages/oas-normalize/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"baseUrl": "./src",
"declaration": true,
"esModuleInterop": true,
"module": "ESNext",
"moduleResolution": "bundler",
"outDir": "dist/",
"paths": {
"swagger2openapi": [".sink.d.ts"]
},
"skipLibCheck": true,
"target": "ES2020"
// DOM is needed because `oas-normalize` uses `fetch`.
"lib": ["DOM"]
},
"include": ["./src/**/*"]
"include": ["./src/**/*"],
"exclude": ["dist"]
}
11 changes: 3 additions & 8 deletions packages/oas-normalize/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@ import type { Options } from 'tsup';
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from 'tsup';

import config from '../../tsup.config';

export default defineConfig((options: Options) => ({
...options,
...config,

cjsInterop: true,
clean: true,
dts: true,
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,
}));
1 change: 1 addition & 0 deletions packages/oas-to-har/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"url": "https://github.com/readmeio/oas/issues"
},
"scripts": {
"attw": "attw --pack --format table-flipped",
"build": "tsup",
"lint": "npm run lint:types && npm run lint:js",
"lint:js": "eslint . --ext .js,.ts",
Expand Down
17 changes: 4 additions & 13 deletions packages/oas-to-har/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"baseUrl": "./src",
"declaration": true,
"downlevelIteration": true,
"esModuleInterop": true,
"lib": ["DOM", "ES2020"],
"module": "ESNext",
"moduleResolution": "Bundler",
"noImplicitAny": true,
"outDir": "dist/",
"skipLibCheck": true,
"target": "ES2020"
"downlevelIteration": true
},
"include": ["./src/**/*"]
"include": ["./src/**/*"],
"exclude": ["dist"]
}
8 changes: 3 additions & 5 deletions packages/oas-to-har/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from 'tsup';

import config from '../../tsup.config.js';

export default defineConfig(options => ({
...options,
...config,

cjsInterop: true,
dts: true,
entry: ['src/index.ts', 'src/lib/configure-security.ts', 'src/lib/types.ts'],
format: ['esm', 'cjs'],
shims: true,
silent: !options.watch,
sourcemap: true,
}));
1 change: 1 addition & 0 deletions packages/oas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"url": "https://github.com/readmeio/oas/issues"
},
"scripts": {
"attw": "attw --pack --format table-flipped",
"build": "tsup",
"lint": "npm run lint:types && npm run lint:js",
"lint:js": "eslint . --ext .js,.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/oas/src/lib/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SchemaObject } from 'rmoas.types';
import type { SchemaObject } from '../rmoas.types';

export function hasSchemaType(schema: SchemaObject, discriminator: 'array' | 'object') {
if (Array.isArray(schema.type)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/oas/src/operation/get-response-as-json-schema.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type Operation from 'operation';
import type Operation from '../operation';
import type {
ComponentsObject,
MediaTypeObject,
OASDocument,
ResponseObject,
SchemaObject,
HeaderObject,
} from 'rmoas.types';
} from '../rmoas.types';

import cloneObject from '../lib/clone-object';
import { isPrimitive } from '../lib/helpers';
Expand Down
16 changes: 3 additions & 13 deletions packages/oas/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
{
"compilerOptions": {
"allowJs": true,
"baseUrl": "./src/",
"declaration": true,
"esModuleInterop": true,
"lib": ["ES2023"],
"module": "ESNext",
"moduleResolution": "bundler",
"noImplicitAny": true,
"outDir": "./dist",
"target": "ES2020"
},
"include": ["./src/**/*"]
"extends": "../../tsconfig.base.json",
"include": ["./src/**/*"],
"exclude": ["dist"]
}
11 changes: 3 additions & 8 deletions packages/oas/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import type { Options } from 'tsup';
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from 'tsup';

import config from '../../tsup.config';

export default defineConfig((options: Options) => ({
...options,
...config,

cjsInterop: true,
clean: true,
dts: true,
entry: [
'src/analyzer/index.ts',
'src/lib/reducer.ts',
Expand All @@ -18,10 +18,5 @@ export default defineConfig((options: Options) => ({
'src/rmoas.types.ts',
'src/utils.ts',
],
format: ['esm', 'cjs'],
minify: false,
shims: true,
silent: !options.watch,
sourcemap: true,
splitting: true,
}));
17 changes: 17 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"allowJs": true,
"baseUrl": "./src",
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"lib": ["ES2023"],
"module": "ESNext",
"moduleResolution": "Bundler",
"noImplicitAny": true,
"outDir": "./dist",
"skipLibCheck": true,
"sourceMap": true,
"target": "ES2020"
}
}
14 changes: 14 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Options } from 'tsup';

const config: Options = {
cjsInterop: true,
clean: true,
dts: true,
format: ['esm', 'cjs'],
minify: false,
shims: true,
sourcemap: true,
splitting: true,
};

export default config;

0 comments on commit b7df260

Please sign in to comment.