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

Extend node to support media imports via customization hooks.

latest
Source
npmnpm
Version
1.4.0
Version published
Maintainers
2
Created
Source

Nodejs Loaders: Media

@node.js loaders logo

npm version unpacked size compatible node version(s)

Usage

$ npm i -D @nodejs-loaders/media
$ node --import @nodejs-loaders/media main.js

See README.md in the repository's root for more details.

Environment: test

This loader returns the specifier (truncated from project root / current working directory) as the default export:

Compatible APIs:

import photo from './team.jpg'; // photo = '[…]/team.jpg'

This ensures snapshots are unaffected by the file system on which the test is run.

Supported file extensions

Audio/Video:

  • .av1
  • .mp3
  • .mp3
  • .mp4
  • .ogg
  • .webm

Documents:

  • .epub
  • .pdf

Images:

  • .avif
  • .gif
  • .ico
  • .jpeg
  • .jpg
  • .png
  • .webp

Extending supported extensions

Media loader's default list of file extenions can be modified via module.register; either with addition(s) and/or deletion(s) OR replacements:

$ node ./example.mts
// ./example.mts

import module from 'node:module';

module.register('@nodejs-loaders/media', import.meta.url, {
	data: {
		additions: ['.ext'], // This will add .ext to the default list.
		deletions: ['.ico'], // This will remove .ico from the default list.
	},
});

const someFileA = await import('./some.ext'); // someFile = '[…]/some.ext'
const someFileB = await import('./some.ico'); // 💥

OR

// ./example.mts

import module from 'node:module';

module.register('@nodejs-loaders/media', import.meta.url, {
	data: ['.ext'], // ⚠️ This will REPLACE the entire list with ONLY the .ext file extension.
});

const someFileA = await import('./some.ext'); // someFile = '[…]/some.ext'
const someFileB = await import('./some.ico'); // 💥

Alternatives

Keywords

audio

FAQs

Package last updated on 08 Nov 2025

Did you know?

Socket

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.

Install

Related posts