Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace builtins dep w/ builtinModules #9

Merged
merged 2 commits into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions lib/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ import {Stats, statSync, realpathSync} from 'node:fs'
import process from 'node:process'
import {URL, fileURLToPath, pathToFileURL} from 'node:url'
import path from 'node:path'
// @ts-expect-error: hush
import builtins from 'builtins'
import {builtinModules} from 'node:module'
import packageJsonReader from './package-json-reader.js'
import {defaultGetFormatWithoutErrors} from './get-format.js'
import {codes} from './errors.js'

/** @type {Array<string>} */
const listOfBuiltins = builtins()

const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace]

// To do: potentially enable?
Expand Down Expand Up @@ -989,7 +985,7 @@ function parsePackageName(specifier, base) {
* @returns {URL}
*/
function packageResolve(specifier, base, conditions) {
if (listOfBuiltins.includes(specifier)) {
if (builtinModules.includes(specifier)) {
return new URL('node:' + specifier)
}

Expand Down Expand Up @@ -1162,7 +1158,7 @@ function checkIfDisallowedImport(specifier, parsed, parsedParentURL) {
return {url: parsed.href}
}

if (listOfBuiltins.includes(specifier)) {
if (builtinModules.includes(specifier)) {
throw new ERR_NETWORK_IMPORT_DISALLOWED(
specifier,
parsedParentURL,
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
"index.d.ts",
"index.js"
],
"dependencies": {
"builtins": "^5.0.0"
},
Comment on lines -31 to -33
Copy link
Owner

Choose a reason for hiding this comment

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

Can you keep this as "dependencies": {},?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. It might be the case that a package manager removes this the next time the dependencies are modified via the CLI, though.

"dependencies": {},
"devDependencies": {
"@types/node": "^17.0.0",
"@types/semver": "^7.0.0",
Expand Down