Skip to content

Commit

Permalink
feat: dual packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip committed Jan 14, 2022
1 parent e34455c commit 08925be
Show file tree
Hide file tree
Showing 6 changed files with 410 additions and 121 deletions.
47 changes: 39 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,59 @@
"url": "https://github.com/stoplightio/http-spec"
},
"license": "Apache-2.0",
"main": "src/index.ts",
"files": [
"**/*"
],
"engines": {
"node": ">=10"
"node": "^12.20 || >=14.13"
},
"type": "commonjs",
"main": "./cjs/index.js",
"module": "./esm/index.esm.js",
"types": "./types/index.d.ts",
"exports": {
".": {
"types": "./types/index.d.ts",
"import": "./esm/index.mjs",
"require": "./cjs/index.js"
},
"./oas": {
"types": "./types/oas/index.d.ts",
"import": "./esm/oas/index.mjs",
"require": "./cjs/oas/index.js"
},
"./oas2": {
"types": "./types/oas2/index.d.ts",
"import": "./esm/oas2/index.mjs",
"require": "./cjs/oas2/index.js"
},
"./oas3": {
"types": "./types/oas3/index.d.ts",
"import": "./esm/oas3/index.mjs",
"require": "./cjs/oas3/index.js"
},
"./postman": {
"types": "./types/postman/index.d.ts",
"import": "./esm/postman/index.mjs",
"require": "./cjs/postman/index.js"
}
},
"scripts": {
"build": "sl-scripts build",
"build": "rollup -c && cp ./dist/esm/index.mjs ./dist/esm/index.esm.js && tsc -p tsconfig.build.json --declaration --emitDeclarationOnly --declarationDir dist/types",
"postbuild": "cp package.json README.md LICENSE dist && yarn test.packaging",
"lint": "eslint 'src/**/*.ts'",
"lint.fix": "yarn lint --fix",
"release": "sl-scripts release",
"release.dryRun": "sl-scripts release --dry-run --debug",
"test": "jest"
"test": "jest",
"test.packaging": "#"
},
"dependencies": {
"@stoplight/json": "^3.17.1",
"@stoplight/types": "^12.4.0",
"@stoplight/types": "^12.3.0",
"@types/swagger-schema-official": "~2.0.21",
"@types/type-is": "^1.6.3",
"@types/urijs": "~1.19.9",
"json-schema": "^0.4.0",
"json-schema": "^0.3.0",
"json-schema-generator": "^2.0.6",
"lodash": "^4.17.15",
"openapi3-ts": "^2.0.1",
Expand All @@ -42,7 +73,7 @@
},
"devDependencies": {
"@stoplight/eslint-config": "^1.1.0",
"@stoplight/scripts": "^8.2.1",
"@stoplight/scripts": "^9.2.0",
"@stoplight/test-utils": "^0.0.1",
"@types/jest": "26.0.3",
"@types/json-schema": "7.0.5",
Expand Down
32 changes: 32 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as path from 'path';
import typescript from 'rollup-plugin-typescript2';

import pkg from './package.json';

module.exports = {
input: Object.keys(pkg.exports).map(entry => path.join('src', entry, './index.ts')),
output: [
{
dir: './dist/cjs',
entryFileNames: '[name].js',
exports: 'named',
format: 'cjs',
name: pkg.name,
preserveModules: true,
},
{
dir: './dist/esm',
entryFileNames: '[name].mjs',
format: 'es',
name: pkg.name,
preserveModules: true,
},
],
external: [...Object.keys(pkg.dependencies), 'lodash/fp'],
plugins: [
typescript({
tsconfig: './tsconfig.build.json',
useTsconfigDeclarationDir: true,
}),
],
};
2 changes: 1 addition & 1 deletion src/postman/transformers/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@stoplight/types';
import { JSONSchema7 } from 'json-schema';
// @ts-ignore
import * as jsonSchemaGenerator from 'json-schema-generator';
import jsonSchemaGenerator from 'json-schema-generator';
import { FormParam, Header, PropertyList, QueryParam, RequestBody } from 'postman-collection';
import * as typeIs from 'type-is';

Expand Down
3 changes: 1 addition & 2 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
],
"compilerOptions": {
"outDir": "dist",
"moduleResolution": "node",
"target": "es6"
"moduleResolution": "node"
}
}
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"."
],
"compilerOptions": {
"module": "commonjs",
"noUnusedLocals": false
"module": "ESNext",
"noUnusedLocals": false,
"target": "ES2019",
"esModuleInterop": true
}
}
Loading

0 comments on commit 08925be

Please sign in to comment.