Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

chore: entrypoints for plugins #126

Merged
merged 4 commits into from
Jun 11, 2024
Merged

Conversation

hanspagel
Copy link
Member

@hanspagel hanspagel commented Jun 11, 2024

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.

@hanspagel hanspagel requested a review from marclave June 11, 2024 12:54
Copy link

changeset-bot bot commented Jun 11, 2024

🦋 Changeset detected

Latest commit: 536d7f9

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

Copy link

relativeci bot commented Jun 11, 2024

#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
     Baseline
#83
Improvement  JS 114.45KiB (-0.22%) 114.71KiB

Bundle analysis reportBranch chore/entrypoints-for-pluginsProject dashboard

Copy link

cloudflare-workers-and-pages bot commented Jun 11, 2024

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

Copy link
Member

@marclave marclave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫡 unreal @hanspagel

@hanspagel hanspagel merged commit ec01324 into main Jun 11, 2024
8 checks passed
@hanspagel hanspagel deleted the chore/entrypoints-for-plugins branch June 11, 2024 16:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants