scalar / openapi-parser

Modern OpenAPI parser written in TypeScript
MIT License
26 stars 7 forks source link

chore: entrypoints for plugins #126

Closed hanspagel closed 1 month ago

hanspagel commented 1 month ago

I’ve got some errors with node:fs (used in the readFiles plugin) in a Docusaurus/Webpack setup, though it wasn’t even used. Seems Webpack isn’t shaking the tree enough.

This PR moves the two plugins to dedicated entrypoints, that can be used like that:

import { dereference, load } from '@scalar/openapi-parser'
import { fetchUrls } from '@scalar/openapi-parser/plugins/fetch-urls'
import { readFiles } from '@scalar/openapi-parser/plugins/read-files'

// Load a file and all referenced files
const { filesystem } = await load('./openapi.yaml', {
  plugins: [
    readFiles(),
    fetchUrls({
      limit: 5,
    }),
  ],
})

This should help Webpack, because it doesn't need to shake the tree if the tree isn’t even in the garden. If you know what I mean. :)

I've tested the build and it fixed the problem.

changeset-bot[bot] commented 1 month ago

🦋 Changeset detected

Latest commit: 536d7f92006f7018ff143a591b2b00fbdf5dac6a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ---------------------- | ----- | | @scalar/openapi-parser | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

relativeci[bot] commented 1 month ago

#87 Bundle Size — 114.45KiB (-0.22%).

536d7f9(current) vs 72703c8 main#83(baseline)

Bundle metrics  Change 2 changes Improvement 1 improvement
                 Current
#87
     Baseline
#83
Improvement  Initial JS 114.45KiB(-0.22%) 114.71KiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 3.08% 4.51%
No change  Chunks 45 45
No change  Assets 45 45
No change  Modules 45 45
No change  Duplicate Modules 0 0
No change  Duplicate Code 0% 0%
No change  Packages 0 0
No change  Duplicate Packages 0 0

Bundle size by type  Change 1 change Improvement 1 improvement
|            |       Current
[#87](https://app.relative-ci.com/projects/hXQ54UQKluDUZAKvpt9b/jobs/87-Xg9VQMeyaR2q6dnhcK0D?utm_source=github&utm_medium=pr-report "View bundle analysis report") |      Baseline
[#83](https://app.relative-ci.com/projects/hXQ54UQKluDUZAKvpt9b/jobs/83-emhfC7lQeFeVjZbyXkxO?utm_source=github&utm_medium=pr-report "View baseline bundle analysis report") | |:--|--:|--:| | Improvement  [JS](https://app.relative-ci.com/projects/hXQ54UQKluDUZAKvpt9b/jobs/87-Xg9VQMeyaR2q6dnhcK0D/assets?ba=%7B%22filters%22%3A%22ft.CSS-0_ft.JS-1_ft.IMG-0_ft.MEDIA-0_ft.FONT-0_ft.HTML-0_ft.OTHER-0%22%7D "View JS assets") | `114.45KiB` (`-0.22%`) | `114.71KiB` |

Bundle analysis reportBranch chore/entrypoints-for-pluginsProject dashboard

cloudflare-pages[bot] commented 1 month ago

Deploying openapi-parser with  Cloudflare Pages  Cloudflare Pages

Latest commit: 536d7f9
Status: ✅  Deploy successful!
Preview URL: https://56dfd698.openapi-parser.pages.dev
Branch Preview URL: https://chore-entrypoints-for-plugin.openapi-parser.pages.dev

View logs