fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #1813 from hey-api/feat/rollup-plugin

feat: add rollup-plugin

authored by

Lubos and committed by
GitHub
215cbf0a 764a2b88

+229 -2
+5
.changeset/empty-horses-invent.md
··· 1 + --- 2 + '@hey-api/rollup-plugin': minor 3 + --- 4 + 5 + feat: initial release
+21
packages/rollup-plugin/.gitignore
··· 1 + .DS_Store 2 + .idea 3 + .tsup 4 + .tmp 5 + junit.xml 6 + logs 7 + node_modules 8 + npm-debug.log* 9 + temp 10 + yarn-debug.log* 11 + yarn-error.log* 12 + 13 + *.iml 14 + dist 15 + coverage 16 + .env 17 + 18 + # test files 19 + test/generated 20 + test/e2e/generated 21 + generated/
+21
packages/rollup-plugin/LICENSE.md
··· 1 + MIT License 2 + 3 + Copyright (c) Hey API 4 + 5 + Permission is hereby granted, free of charge, to any person obtaining a copy 6 + of this software and associated documentation files (the "Software"), to deal 7 + in the Software without restriction, including without limitation the rights 8 + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 + copies of the Software, and to permit persons to whom the Software is 10 + furnished to do so, subject to the following conditions: 11 + 12 + The above copyright notice and this permission notice shall be included in all 13 + copies or substantial portions of the Software. 14 + 15 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 + SOFTWARE.
+41
packages/rollup-plugin/README.md
··· 1 + <div align="center"> 2 + <img alt="Hey API logo" height="150" src="https://heyapi.dev/images/logo-300w.png" width="150"> 3 + <h1 align="center"><b>Vite/Rollup Plugin</b></h1> 4 + <p align="center">🚀 Vite/Rollup plugin for `@hey-api/openapi-ts` codegen.</p> 5 + </div> 6 + 7 + ## Platform 8 + 9 + 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). 10 + 11 + ## Documentation 12 + 13 + Please visit our [website](https://heyapi.dev/) for documentation, guides, migrating, and more. 14 + 15 + ## Sponsors 16 + 17 + Love Hey API? Become our [sponsor](https://github.com/sponsors/hey-api). 18 + 19 + <p> 20 + <a href="https://kutt.it/pkEZyc" target="_blank"> 21 + <img alt="Stainless logo" height="50" src="https://heyapi.dev/images/stainless-logo-wordmark-480w.jpeg" /> 22 + </a> 23 + </p> 24 + 25 + ## Usage 26 + 27 + Add to `plugins` inside your Vite/Rollup configuration. 28 + 29 + ```ts 30 + import { heyApiPlugin } from '@hey-api/rollup-plugin'; 31 + 32 + export default defineConfig({ 33 + plugins: [ 34 + heyApiPlugin({ 35 + config: { 36 + // optional configuration instead of using the configuration file 37 + }, 38 + }), 39 + ], 40 + }); 41 + ```
+65
packages/rollup-plugin/package.json
··· 1 + { 2 + "name": "@hey-api/rollup-plugin", 3 + "version": "0.0.0", 4 + "description": "🚀 Vite/Rollup plugin for `@hey-api/openapi-ts` codegen.", 5 + "homepage": "https://heyapi.dev/", 6 + "repository": { 7 + "type": "git", 8 + "url": "git+https://github.com/hey-api/openapi-ts.git" 9 + }, 10 + "bugs": { 11 + "url": "https://github.com/hey-api/openapi-ts/issues" 12 + }, 13 + "license": "MIT", 14 + "author": { 15 + "email": "lubos@heyapi.dev", 16 + "name": "Hey API", 17 + "url": "https://heyapi.dev" 18 + }, 19 + "funding": "https://github.com/sponsors/hey-api", 20 + "keywords": [ 21 + "codegen", 22 + "openapi", 23 + "plugin", 24 + "rollup", 25 + "rollup-plugin", 26 + "vite", 27 + "vite-plugin", 28 + "swagger" 29 + ], 30 + "type": "module", 31 + "main": "./dist/index.cjs", 32 + "module": "./dist/index.js", 33 + "types": "./dist/index.d.ts", 34 + "exports": { 35 + ".": { 36 + "import": { 37 + "types": "./dist/index.d.ts", 38 + "default": "./dist/index.js" 39 + }, 40 + "require": { 41 + "types": "./dist/index.d.cts", 42 + "default": "./dist/index.cjs" 43 + } 44 + }, 45 + "./package.json": "./package.json" 46 + }, 47 + "files": [ 48 + "dist", 49 + "LICENSE.md" 50 + ], 51 + "scripts": { 52 + "build": "tsup && pnpm check-exports", 53 + "check-exports": "attw --pack .", 54 + "dev": "tsup --watch", 55 + "prepublishOnly": "pnpm build" 56 + }, 57 + "peerDependencies": { 58 + "@hey-api/openapi-ts": "< 2" 59 + }, 60 + "devDependencies": { 61 + "@hey-api/openapi-ts": "workspace:*", 62 + "typescript": "5.5.3", 63 + "vite": "6.0.9" 64 + } 65 + }
+16
packages/rollup-plugin/src/index.ts
··· 1 + import { createClient, type UserConfig } from '@hey-api/openapi-ts'; 2 + 3 + export function heyApiPlugin(options?: { 4 + /** 5 + * `@hey-api/openapi-ts` configuration options. 6 + */ 7 + config?: UserConfig; 8 + }) { 9 + return { 10 + buildStart: async () => { 11 + // @ts-expect-error 12 + await createClient(options?.config ?? {}); 13 + }, 14 + name: 'hey-api-plugin', 15 + }; 16 + }
+14
packages/rollup-plugin/tsconfig.base.json
··· 1 + { 2 + "compilerOptions": { 3 + "declaration": true, 4 + "esModuleInterop": true, 5 + "module": "ESNext", 6 + "moduleResolution": "Bundler", 7 + "noImplicitOverride": true, 8 + "noUncheckedIndexedAccess": true, 9 + "noUnusedLocals": true, 10 + "strict": true, 11 + "target": "ES2022", 12 + "useUnknownInCatchVariables": false 13 + } 14 + }
+9
packages/rollup-plugin/tsconfig.json
··· 1 + { 2 + "extends": "./tsconfig.base.json", 3 + "compilerOptions": { 4 + "declaration": false, 5 + "esModuleInterop": true, 6 + "resolveJsonModule": true, 7 + "skipLibCheck": true 8 + } 9 + }
+23
packages/rollup-plugin/tsup.config.ts
··· 1 + import { defineConfig } from 'tsup'; 2 + 3 + export default defineConfig((options) => ({ 4 + banner(ctx) { 5 + /** 6 + * fix dynamic require in ESM 7 + * @link https://github.com/hey-api/openapi-ts/issues/1079 8 + */ 9 + if (ctx.format === 'esm') { 10 + return { 11 + js: "import { createRequire } from 'module'; const require = createRequire(import.meta.url);", 12 + }; 13 + } 14 + }, 15 + clean: true, 16 + dts: true, 17 + entry: ['src/index.ts'], 18 + format: ['cjs', 'esm'], 19 + minify: !options.watch, 20 + shims: false, 21 + sourcemap: true, 22 + treeshake: true, 23 + }));
+14 -2
pnpm-lock.yaml
··· 922 922 specifier: 3.23.8 923 923 version: 3.23.8 924 924 925 + packages/rollup-plugin: 926 + devDependencies: 927 + '@hey-api/openapi-ts': 928 + specifier: workspace:* 929 + version: link:../openapi-ts 930 + typescript: 931 + specifier: 5.5.3 932 + version: 5.5.3 933 + vite: 934 + specifier: 6.0.9 935 + version: 6.0.9(@types/node@22.10.5)(jiti@2.4.2)(less@4.2.2)(sass@1.85.0)(terser@5.39.0)(yaml@2.7.0) 936 + 925 937 packages: 926 938 927 939 '@algolia/autocomplete-core@1.17.9': ··· 17391 17403 domhandler: 5.0.3 17392 17404 htmlparser2: 9.1.0 17393 17405 picocolors: 1.1.1 17394 - postcss: 8.5.2 17406 + postcss: 8.5.3 17395 17407 postcss-media-query-parser: 0.2.3 17396 17408 17397 17409 better-path-resolve@1.0.0: ··· 24428 24440 vite@6.1.0(@types/node@22.10.5)(jiti@2.4.2)(less@4.2.2)(sass@1.85.0)(terser@5.39.0)(yaml@2.7.0): 24429 24441 dependencies: 24430 24442 esbuild: 0.24.2 24431 - postcss: 8.5.2 24443 + postcss: 8.5.3 24432 24444 rollup: 4.31.0 24433 24445 optionalDependencies: 24434 24446 '@types/node': 22.10.5