Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@ts-bridge/resolver
Advanced tools
@ts-bridge/resolver
An implementation of the Node.js module resolution algorithm as defined in the specification here.
There are several tools out there for resolving modules, such as
enhanced-resolve
, or
import-meta-resolve
, or even
Node.js' own require.resolve
or import.meta.resolve
functions. Unfortunately
we cannot use these in TS Bridge, since the resolution logic has some specific
requirements:
ESM_FILE_FORMAT
function in the
specification if
you're curious.To ensure correct behaviour, the best solution seemed to reimplement the algorithm as used by Node.js.
[!NOTE] Usage outside of TS Bridge is possible, but not recommended. Consider using a library like
enhanced-resolve
orimport-meta-resolve
instead.
[!NOTE] This is an ESM-only module. It cannot be used from CommonJS.
resolve
This library exports a single function, resolve
, which can be used to resolve
a package specifier to its path and format (e.g., module
, commonjs
).
It takes the following arguments:
Name | Type | Optional | Description |
---|---|---|---|
packageSpecifier | string | No | The specifier to resolve, e.g., @ts-bridge/resolver , or some-module/sub-path . |
parentUrl | string | URL | No | The URL to start resolving from. This can be an (absolute) path, or instance of URL . |
fileSystem | FileSystemInterface | Yes | The file system to use for the resolution. This is mainly used for testing purposes, but can be used to use the resolver on custom file systems. |
import { resolve } from '@ts-bridge/resolver';
const { path, format } = resolve('some-es-module/sub-path', import.meta.url);
console.log(path); // "/path/to/node_modules/some-es-module/dist/sub-path.mjs"
console.log(format); // "module"
FAQs
An implementation of the Node.js module resolution algorithm.
The npm package @ts-bridge/resolver receives a total of 15 weekly downloads. As such, @ts-bridge/resolver popularity was classified as not popular.
We found that @ts-bridge/resolver demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.