refactor(deps): replace url-parse with native URL API#122
Open
Kyzgor wants to merge 1 commit intopermitio:mainfrom
Open
refactor(deps): replace url-parse with native URL API#122Kyzgor wants to merge 1 commit intopermitio:mainfrom
Kyzgor wants to merge 1 commit intopermitio:mainfrom
Conversation
Remove the `url-parse` dependency in favor of the native `URL` class, which has been available since Node.js v10 (the SDK's minimum supported version). This eliminates an unnecessary dependency and reduces bundle size. Fixes permitio#106
0053425 to
aa6d88b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remove the
url-parsedependency in favor of the nativeURLclass, which has been available since Node.js v10 — the SDK's minimum supported version.Problem
As reported in #106,
url-parseis an unnecessary third-party dependency. Node.js natively supports theURLclass since v10, making this package redundant and adding unnecessary weight to the bundle.Solution
Replaced all
url-parseusage insrc/enforcement/enforcer.tswith the nativeURLAPI:opaBaseUrl.set('port', '8181')→opaBaseUrl.port = '8181'opaBaseUrl.set('pathname', ...)→opaBaseUrl.pathname = ....toString()— works identically on bothChanges
src/enforcement/enforcer.ts— Removedurl-parseimport, replaced.set()calls with native property assignmentpackage.json— Removedurl-parsefrom dependencies and@types/url-parsefrom devDependenciesyarn.lock— Regenerated withouturl-parseTesting
yarn lint— passes (0 errors)yarn build— succeeds (both CJS and ESM)yarn test:module-imports— all 9 tests passnode -e "const { Permit } = require('./build'); console.log(typeof Permit);"→functionBackwards Compatibility
No breaking changes. Fully backwards-compatible. The native
URLAPI has identical behavior for the operations used (constructor, port/pathname assignment, toString).Checklist
yarn lintpassesyarn buildsucceeds (both CJS and ESM)yarn test:module-importspassessrc/openapi/(auto-generated)Fixes #106