Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@nodejs-loaders/media

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nodejs-loaders/media - npm Package Compare versions

Comparing version
1.0.0
to
1.0.1
+5
media.d.mts
export const exts: Set<string>;
declare function resolveMedia(specifier: string, context: import("module").ResolveHookContext, nextResolve: (specifier: string, context?: import("module").ResolveHookContext) => import("module").ResolveFnOutput | Promise<import("module").ResolveFnOutput>): import("module").ResolveFnOutput | Promise<import("module").ResolveFnOutput>;
declare function loadMedia(url: string, context: import("module").LoadHookContext, nextLoad: (url: string, context?: import("module").LoadHookContext) => import("module").LoadFnOutput | Promise<import("module").LoadFnOutput>): import("module").LoadFnOutput | Promise<import("module").LoadFnOutput>;
export { resolveMedia as resolve, loadMedia as load };
//# sourceMappingURL=media.d.mts.map
{"version":3,"file":"media.d.mts","sourceRoot":"","sources":["media.mjs"],"names":[],"mappings":"AA0CA,+BAoBG;uIACsoP,CAAC;kHAA4nD,CAAC"}
+45
-38

@@ -5,30 +5,37 @@ import process from 'node:process';

/**
* @type {import('node:module').ResolveHook}
*/
async function resolveMedia(specifier, ctx, nextResolve) {
const nextResult = await nextResolve(specifier);
const nextResult = await nextResolve(specifier);
// Check against the fully resolved URL, not just the specifier, in case another loader has
// something to contribute to the resolution.
if (!exts.has(getFilenameExt(nextResult.url))) return nextResult;
// Check against the fully resolved URL, not just the specifier, in case another loader has
// something to contribute to the resolution.
if (!exts.has(getFilenameExt(nextResult.url))) return nextResult;
return {
...ctx,
format: 'media',
url: nextResult.url,
}
return {
...ctx,
// @ts-ignore https://github.com/DefinitelyTyped/DefinitelyTyped/pull/71493
format: 'media',
url: nextResult.url,
};
}
export { resolveMedia as resolve }
export { resolveMedia as resolve };
/**
* @type {import('node:module').LoadHook}
*/
async function loadMedia(url, ctx, nextLoad) {
if (ctx.format !== 'media') return nextLoad(url);
// @ts-ignore https://github.com/DefinitelyTyped/DefinitelyTyped/pull/71493
if (ctx.format !== 'media') return nextLoad(url);
const source = `export default '${url.replace(cwd, '[…]')}';`;
const source = `export default '${url.replace(cwd, '[…]')}';`;
return {
format: 'module',
shortCircuit: true, // There's nothing else for another loader to do, so signal to stop.
source,
};
return {
format: 'module',
shortCircuit: true, // There's nothing else for another loader to do, so signal to stop.
source,
};
}
export { loadMedia as load }
export { loadMedia as load };

@@ -38,21 +45,21 @@ const cwd = process.cwd();

export const exts = new Set([
/**
* A/V
*/
'.av1',
'.mp3',
'.mp3',
'.mp4',
'.ogg',
'.webm',
/**
* images
*/
'.avif',
'.gif',
'.ico',
'.jpeg',
'.jpg',
'.png',
'.webp',
/**
* A/V
*/
'.av1',
'.mp3',
'.mp3',
'.mp4',
'.ogg',
'.webm',
/**
* images
*/
'.avif',
'.gif',
'.ico',
'.jpeg',
'.jpg',
'.png',
'.webp',
]);
{
"version": "1.0.0",
"version": "1.0.1",
"name": "@nodejs-loaders/media",
"description": "Extend node to support media imports via customization hooks.",
"type": "module",
"author": "Jacob Smith",
"maintainers": [
"Augustin Mauroy"
"Augustin Mauroy",
"Jacob Smith"
],
"license": "ISC",
"main": "./media.mjs",
"types": "./media.d.mts",
"keywords": [
"audio",
"customisation hook",
"customization hooks",
"images",

@@ -18,4 +21,8 @@ "video",

"media",
"node",
"node.js"
],
"engines": {
"node": ">=22 || ^20.6.0 || ^18.19.0"
},
"dependencies": {

@@ -25,4 +32,6 @@ "@nodejs-loaders/parse-filename": "1.0.0"

"repository": {
"url": "https://github.com/JakobJingleheimer/nodejs-loaders"
"type": "git",
"url": "git+https://github.com/nodejs-loaders/nodejs-loaders.git",
"directory": "packages/media"
}
}
# Nodejs Loaders: Media
<img src="https://raw.githubusercontent.com/JakobJingleheimer/nodejs-loaders/refs/heads/main/logo.svg" height="100" width="100" alt="@node.js loaders logo" />
<img src="https://raw.githubusercontent.com/nodejs-loaders/nodejs-loaders/refs/heads/main/logo.svg" height="100" width="100" alt="@node.js loaders logo" />
[![npm version](https://img.shields.io/npm/v/nodejs-loaders/media.svg)](https://www.npmjs.com/package/nodejs-loaders/media)
![size](https://img.shields.io/github/languages/code-size/JakobJingleheimer/nodejs-loaders/media)
[![npm version](https://img.shields.io/npm/v/@nodejs-loaders/media.svg)](https://www.npmjs.com/package/nodejs-loaders/media)
![unpacked size](https://img.shields.io/npm/unpacked-size/@nodejs-loaders/media)

@@ -12,2 +12,4 @@ **Environment**: test

**Compatible APIs**: [`module.register`](https://nodejs.org/api/module.html#moduleregisterspecifier-parenturl-options)
```js

@@ -14,0 +16,0 @@ import photo from './team.jpg'; // photo = '[…]/team.jpg'