Registry / devops / new-url-loader

new-url-loader

JSON →
library0.1.1jsnpmunverified

A tiny alternative to url-loader and file-loader for webpack 5, replacing deprecated loaders with asset modules. Current stable version is 0.1.1. The package is actively maintained with a simple API that delegates to webpack 5's built-in asset modules, providing backward compatibility for setups that still require a loader pipeline (e.g., @svgr/webpack). Unlike url-loader/file-loader, it uses webpack 5's native asset handling and has zero runtime dependencies beyond webpack 5 itself. Supports data URI inlining and separate file emission via asset type configuration.

npm install new-url-loader
INSTALL
IMPORT
SIG · NEW-URL-LOADER
N
new-url-loader
devopsjavascriptv0.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

new-url-loader
import NewUrlLoader from 'new-url-loader'
const NewUrlLoader = require('new-url-loader')
The loader is used in webpack config, not directly imported in application code. However, if using ESM in webpack config, use import; CommonJS require also works.

Shows how to replace url-loader with new-url-loader for SVG files processed by @svgr/webpack, using webpack 5 asset modules.

// webpack.config.js module.exports = { module: { rules: [ { test: /\.svg$/, oneOf: [ { dependency: { not: ['url'] }, use: ['@svgr/webpack', 'new-url-loader'], }, { type: 'asset', }, ], }, ], }, };
Debug
Known issues
gotchaThe loader must be used with webpack 5 asset modules; it does not work with webpack 4.
fix
Upgrade to webpack 5 and configure asset modules.
affects: 0.0.0 - 0.1.1
gotchaWhen using with @svgr/webpack, you must exclude URL dependencies to avoid double-processing.
fix
Add `dependency: { not: ['url'] }` to the loader rule as shown in the documentation.
affects: 0.0.0 - 0.1.1
breakingVersion 0.1.1 changed export to use toString() for string output instead of URL object. If you relied on the URL object type, this will break.
fix
Update to 0.1.1 and expect string values instead of URL objects.
affects: >=0.1.0 <0.1.1
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'new-url-loader'
The loader package is not installed or is not in node_modules.
fix
Run `npm install new-url-loader --save-dev`
TypeError: The 'compilation' argument must be an instance of Compilation
Using loader with webpack version < 5.
fix
Upgrade to webpack 5 or use url-loader/file-loader instead.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
webpackrequiredpeer dependency required for loader functionality
Agent activity
2 hits · last 30 days
node
2
Resources
new-url-loader — npm install new-url-loader · libregistry