diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -922,7 +922,7 @@ specifier: 3.23.8 version: 3.23.8 - packages/rollup-plugin: + packages/vite-plugin: devDependencies: '@hey-api/openapi-ts': specifier: workspace:* diff --git a/.changeset/curvy-chicken-swim.md b/.changeset/curvy-chicken-swim.md --- a/.changeset/curvy-chicken-swim.md +++ b/.changeset/curvy-chicken-swim.md @@ -1,5 +1,5 @@ --- -'@hey-api/rollup-plugin': patch +'@hey-api/vite-plugin': minor --- -fix: use configResolved hook +fix: initial release diff --git a/packages/rollup-plugin/.gitignore b/packages/rollup-plugin/.gitignore deleted file mode 100644 --- a/packages/rollup-plugin/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -.DS_Store -.idea -.tsup -.tmp -junit.xml -logs -node_modules -npm-debug.log* -temp -yarn-debug.log* -yarn-error.log* - -*.iml -dist -coverage -.env - -# test files -test/generated -test/e2e/generated -generated/ diff --git a/packages/rollup-plugin/CHANGELOG.md b/packages/rollup-plugin/CHANGELOG.md deleted file mode 100644 --- a/packages/rollup-plugin/CHANGELOG.md +++ /dev/null @@ -1,24 +0,0 @@ -# @hey-api/rollup-plugin - -## 0.1.2 - -### Patch Changes - -- [#1836](https://github.com/hey-api/openapi-ts/pull/1836) [`f22dc53`](https://github.com/hey-api/openapi-ts/commit/f22dc533bb822d90b2be835217367ae9e6bbc559) Thanks [@mrlubos](https://github.com/mrlubos)! - fix: use enforce pre - -## 0.1.1 - -### Patch Changes - -- [#1826](https://github.com/hey-api/openapi-ts/pull/1826) [`90886c1`](https://github.com/hey-api/openapi-ts/commit/90886c1372a999e8cb59d5da218762f6ee6cd459) Thanks [@mrlubos](https://github.com/mrlubos)! - fix: allow config to be a function - -- [#1825](https://github.com/hey-api/openapi-ts/pull/1825) [`0670a38`](https://github.com/hey-api/openapi-ts/commit/0670a38c66dffc1431a7d4b48ec06b72d4f6868f) Thanks [@mrlubos](https://github.com/mrlubos)! - fix: move @hey-api/openapi-ts to peerDependencies - -- Updated dependencies [[`c73b0d4`](https://github.com/hey-api/openapi-ts/commit/c73b0d401c2bfa6f0b0d89d844a6aa09f2685a69), [`90886c1`](https://github.com/hey-api/openapi-ts/commit/90886c1372a999e8cb59d5da218762f6ee6cd459)]: - - @hey-api/openapi-ts@0.64.13 - -## 0.1.0 - -### Minor Changes - -- [#1813](https://github.com/hey-api/openapi-ts/pull/1813) [`c737e05`](https://github.com/hey-api/openapi-ts/commit/c737e055591376e9351cd07533779023f773cff0) Thanks [@mrlubos](https://github.com/mrlubos)! - feat: initial release diff --git a/packages/rollup-plugin/LICENSE.md b/packages/rollup-plugin/LICENSE.md deleted file mode 100644 --- a/packages/rollup-plugin/LICENSE.md +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) Hey API - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/rollup-plugin/README.md b/packages/rollup-plugin/README.md deleted file mode 100644 --- a/packages/rollup-plugin/README.md +++ /dev/null @@ -1,41 +0,0 @@ -
- Hey API logo -

Vite/Rollup Plugin

-

🚀 Vite/Rollup plugin for `@hey-api/openapi-ts` codegen.

-
- -## Platform - -Our platform for OpenAPI specifications is now available. Automatically update your code when the APIs it depends on change. [Find out more](https://heyapi.dev/openapi-ts/integrations). - -## Documentation - -Please visit our [website](https://heyapi.dev/) for documentation, guides, migrating, and more. - -## Sponsors - -Love Hey API? Become our [sponsor](https://github.com/sponsors/hey-api). - -

- - Stainless logo - -

- -## Usage - -Add to `plugins` inside your Vite/Rollup configuration. - -```ts -import { heyApiPlugin } from '@hey-api/rollup-plugin'; - -export default defineConfig({ - plugins: [ - heyApiPlugin({ - config: { - // optional configuration instead of using the configuration file - }, - }), - ], -}); -``` diff --git a/packages/rollup-plugin/package.json b/packages/rollup-plugin/package.json deleted file mode 100644 --- a/packages/rollup-plugin/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@hey-api/rollup-plugin", - "version": "0.1.2", - "description": "🚀 Vite/Rollup plugin for `@hey-api/openapi-ts` codegen.", - "homepage": "https://heyapi.dev/", - "repository": { - "type": "git", - "url": "git+https://github.com/hey-api/openapi-ts.git" - }, - "bugs": { - "url": "https://github.com/hey-api/openapi-ts/issues" - }, - "license": "MIT", - "author": { - "email": "lubos@heyapi.dev", - "name": "Hey API", - "url": "https://heyapi.dev" - }, - "funding": "https://github.com/sponsors/hey-api", - "keywords": [ - "codegen", - "openapi", - "plugin", - "rollup", - "rollup-plugin", - "vite", - "vite-plugin", - "swagger" - ], - "type": "module", - "main": "./dist/index.cjs", - "module": "./dist/index.js", - "types": "./dist/index.d.ts", - "exports": { - ".": { - "import": { - "types": "./dist/index.d.ts", - "default": "./dist/index.js" - }, - "require": { - "types": "./dist/index.d.cts", - "default": "./dist/index.cjs" - } - }, - "./package.json": "./package.json" - }, - "files": [ - "dist", - "LICENSE.md" - ], - "scripts": { - "build": "tsup && pnpm check-exports", - "check-exports": "attw --pack .", - "dev": "tsup --watch", - "prepublishOnly": "pnpm build" - }, - "peerDependencies": { - "@hey-api/openapi-ts": "0.64.13" - }, - "devDependencies": { - "@hey-api/openapi-ts": "workspace:*", - "typescript": "5.5.3", - "vite": "6.0.9" - } -} diff --git a/packages/rollup-plugin/tsconfig.base.json b/packages/rollup-plugin/tsconfig.base.json deleted file mode 100644 --- a/packages/rollup-plugin/tsconfig.base.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "declaration": true, - "esModuleInterop": true, - "module": "ESNext", - "moduleResolution": "Bundler", - "noImplicitOverride": true, - "noUncheckedIndexedAccess": true, - "noUnusedLocals": true, - "strict": true, - "target": "ES2022", - "useUnknownInCatchVariables": false - } -} diff --git a/packages/rollup-plugin/tsconfig.json b/packages/rollup-plugin/tsconfig.json deleted file mode 100644 --- a/packages/rollup-plugin/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "compilerOptions": { - "declaration": false, - "esModuleInterop": true, - "resolveJsonModule": true, - "skipLibCheck": true - } -} diff --git a/packages/rollup-plugin/tsup.config.ts b/packages/rollup-plugin/tsup.config.ts deleted file mode 100644 --- a/packages/rollup-plugin/tsup.config.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { defineConfig } from 'tsup'; - -export default defineConfig((options) => ({ - banner(ctx) { - /** - * fix dynamic require in ESM - * @link https://github.com/hey-api/openapi-ts/issues/1079 - */ - if (ctx.format === 'esm') { - return { - js: "import { createRequire } from 'module'; const require = createRequire(import.meta.url);", - }; - } - }, - clean: true, - dts: true, - entry: ['src/index.ts'], - format: ['cjs', 'esm'], - minify: !options.watch, - shims: false, - sourcemap: true, - treeshake: true, -})); diff --git a/packages/vite-plugin/.gitignore b/packages/vite-plugin/.gitignore new file mode 100644 --- /dev/null +++ b/packages/vite-plugin/.gitignore @@ -0,0 +1,21 @@ +.DS_Store +.idea +.tsup +.tmp +junit.xml +logs +node_modules +npm-debug.log* +temp +yarn-debug.log* +yarn-error.log* + +*.iml +dist +coverage +.env + +# test files +test/generated +test/e2e/generated +generated/ diff --git a/packages/vite-plugin/CHANGELOG.md b/packages/vite-plugin/CHANGELOG.md new file mode 100644 --- /dev/null +++ b/packages/vite-plugin/CHANGELOG.md @@ -0,0 +1,24 @@ +# @hey-api/vite-plugin + +## 0.1.2 + +### Patch Changes + +- [#1836](https://github.com/hey-api/openapi-ts/pull/1836) [`f22dc53`](https://github.com/hey-api/openapi-ts/commit/f22dc533bb822d90b2be835217367ae9e6bbc559) Thanks [@mrlubos](https://github.com/mrlubos)! - fix: use enforce pre + +## 0.1.1 + +### Patch Changes + +- [#1826](https://github.com/hey-api/openapi-ts/pull/1826) [`90886c1`](https://github.com/hey-api/openapi-ts/commit/90886c1372a999e8cb59d5da218762f6ee6cd459) Thanks [@mrlubos](https://github.com/mrlubos)! - fix: allow config to be a function + +- [#1825](https://github.com/hey-api/openapi-ts/pull/1825) [`0670a38`](https://github.com/hey-api/openapi-ts/commit/0670a38c66dffc1431a7d4b48ec06b72d4f6868f) Thanks [@mrlubos](https://github.com/mrlubos)! - fix: move @hey-api/openapi-ts to peerDependencies + +- Updated dependencies [[`c73b0d4`](https://github.com/hey-api/openapi-ts/commit/c73b0d401c2bfa6f0b0d89d844a6aa09f2685a69), [`90886c1`](https://github.com/hey-api/openapi-ts/commit/90886c1372a999e8cb59d5da218762f6ee6cd459)]: + - @hey-api/openapi-ts@0.64.13 + +## 0.1.0 + +### Minor Changes + +- [#1813](https://github.com/hey-api/openapi-ts/pull/1813) [`c737e05`](https://github.com/hey-api/openapi-ts/commit/c737e055591376e9351cd07533779023f773cff0) Thanks [@mrlubos](https://github.com/mrlubos)! - feat: initial release diff --git a/packages/vite-plugin/LICENSE.md b/packages/vite-plugin/LICENSE.md new file mode 100644 --- /dev/null +++ b/packages/vite-plugin/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Hey API + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/vite-plugin/README.md b/packages/vite-plugin/README.md new file mode 100644 --- /dev/null +++ b/packages/vite-plugin/README.md @@ -0,0 +1,41 @@ +
+ Hey API logo +

Vite Plugin

+

🚀 Vite plugin for `@hey-api/openapi-ts` codegen.

+
+ +## Platform + +Our platform for OpenAPI specifications is now available. Automatically update your code when the APIs it depends on change. [Find out more](https://heyapi.dev/openapi-ts/integrations). + +## Documentation + +Please visit our [website](https://heyapi.dev/) for documentation, guides, migrating, and more. + +## Sponsors + +Love Hey API? Become our [sponsor](https://github.com/sponsors/hey-api). + +

+ + Stainless logo + +

+ +## Usage + +Add to `plugins` inside your Vite configuration. + +```ts +import { heyApiPlugin } from '@hey-api/vite-plugin'; + +export default defineConfig({ + plugins: [ + heyApiPlugin({ + config: { + // optional configuration instead of using the configuration file + }, + }), + ], +}); +``` diff --git a/packages/vite-plugin/package.json b/packages/vite-plugin/package.json new file mode 100644 --- /dev/null +++ b/packages/vite-plugin/package.json @@ -0,0 +1,63 @@ +{ + "name": "@hey-api/vite-plugin", + "version": "0.1.2", + "description": "🚀 Vite plugin for `@hey-api/openapi-ts` codegen.", + "homepage": "https://heyapi.dev/", + "repository": { + "type": "git", + "url": "git+https://github.com/hey-api/openapi-ts.git" + }, + "bugs": { + "url": "https://github.com/hey-api/openapi-ts/issues" + }, + "license": "MIT", + "author": { + "email": "lubos@heyapi.dev", + "name": "Hey API", + "url": "https://heyapi.dev" + }, + "funding": "https://github.com/sponsors/hey-api", + "keywords": [ + "codegen", + "openapi", + "plugin", + "vite", + "vite-plugin", + "swagger" + ], + "type": "module", + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "require": { + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs" + } + }, + "./package.json": "./package.json" + }, + "files": [ + "dist", + "LICENSE.md" + ], + "scripts": { + "build": "tsup && pnpm check-exports", + "check-exports": "attw --pack .", + "dev": "tsup --watch", + "prepublishOnly": "pnpm build" + }, + "peerDependencies": { + "@hey-api/openapi-ts": "0.64.13" + }, + "devDependencies": { + "@hey-api/openapi-ts": "workspace:*", + "typescript": "5.5.3", + "vite": "6.0.9" + } +} diff --git a/packages/vite-plugin/tsconfig.base.json b/packages/vite-plugin/tsconfig.base.json new file mode 100644 --- /dev/null +++ b/packages/vite-plugin/tsconfig.base.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "declaration": true, + "esModuleInterop": true, + "module": "ESNext", + "moduleResolution": "Bundler", + "noImplicitOverride": true, + "noUncheckedIndexedAccess": true, + "noUnusedLocals": true, + "strict": true, + "target": "ES2022", + "useUnknownInCatchVariables": false + } +} diff --git a/packages/vite-plugin/tsconfig.json b/packages/vite-plugin/tsconfig.json new file mode 100644 --- /dev/null +++ b/packages/vite-plugin/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "declaration": false, + "esModuleInterop": true, + "resolveJsonModule": true, + "skipLibCheck": true + } +} diff --git a/packages/vite-plugin/tsup.config.ts b/packages/vite-plugin/tsup.config.ts new file mode 100644 --- /dev/null +++ b/packages/vite-plugin/tsup.config.ts @@ -0,0 +1,23 @@ +import { defineConfig } from 'tsup'; + +export default defineConfig((options) => ({ + banner(ctx) { + /** + * fix dynamic require in ESM + * @link https://github.com/hey-api/openapi-ts/issues/1079 + */ + if (ctx.format === 'esm') { + return { + js: "import { createRequire } from 'module'; const require = createRequire(import.meta.url);", + }; + } + }, + clean: true, + dts: true, + entry: ['src/index.ts'], + format: ['cjs', 'esm'], + minify: !options.watch, + shims: false, + sourcemap: true, + treeshake: true, +})); diff --git a/packages/rollup-plugin/src/index.ts b/packages/rollup-plugin/src/index.ts deleted file mode 100644 --- a/packages/rollup-plugin/src/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { createClient } from '@hey-api/openapi-ts'; - -export function heyApiPlugin(options?: { - /** - * `@hey-api/openapi-ts` configuration options. - */ - config?: Parameters[0]; -}) { - return { - // TODO: rename to vite-plugin if we end up using `configResolved` - configResolved: async () => { - await createClient(options?.config); - }, - enforce: 'pre', - name: 'hey-api-plugin', - }; -} diff --git a/packages/vite-plugin/src/index.ts b/packages/vite-plugin/src/index.ts new file mode 100644 --- /dev/null +++ b/packages/vite-plugin/src/index.ts @@ -0,0 +1,16 @@ +import { createClient } from '@hey-api/openapi-ts'; + +export function heyApiPlugin(options?: { + /** + * `@hey-api/openapi-ts` configuration options. + */ + config?: Parameters[0]; +}) { + return { + configResolved: async () => { + await createClient(options?.config); + }, + enforce: 'pre', + name: 'hey-api-plugin', + }; +}