Registry / testing / no-cache-loader

no-cache-loader

JSON →
library1.0.0jsnpmunverified

A webpack loader that disables caching by returning a new module instance on each require call. Version 1.0.0. Useful for loading mutable data like JSON fixtures where module identity must differ. Simple and focused; no release cadence documented, likely maintenance mode. Only 4 lines of source code.

npm install no-cache-loader
INSTALL
IMPORT
SIG · NO-CACHE-LOADER
N
no-cache-loader
testingjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import noCacheLoader from 'no-cache-loader'
const noCacheLoader = require('no-cache-loader')
For direct usage as a webpack rule, specify loader string 'no-cache-loader'. Not meant for programmatic import.
no-cache-loader (webpack config)
module: { rules: [{ test: /\.json$/, use: 'no-cache-loader' }] }
module: { rules: [{ test: /\.json$/, loader: 'no-cache' }] }
In webpack config, use full package name 'no-cache-loader' not 'no-cache'.
inline usage
require('no-cache-loader!./module.js')
require('no-cache!./module.js')
Inline usage: always include 'no-cache-loader' not 'no-cache'.

Shows how to configure no-cache-loader in webpack to avoid caching of JSON modules, ensuring each require returns a fresh instance.

// Install: npm install --save no-cache-loader // webpack.config.js module.exports = { module: { rules: [ { test: /\.json$/, use: 'no-cache-loader' } ] } }; // Then in your code: const obj1 = require('./data.json'); const obj2 = require('./data.json'); console.log(obj1 === obj2); // false - different objects each time
Debug
Known issues
gotchaLoader is extremely simple (4 lines) and may not handle edge cases like errors or large files gracefully.
fix
For production use, consider a more robust solution or test thoroughly.
affects: <=1.0.0
gotchaOnly works with webpack. Not compatible with other bundlers or Node.js require.
fix
Use only in webpack builds.
affects: <=1.0.0
gotchaNo caching at all - each require() will re-execute the module logic, which can impact performance if called frequently.
fix
Be mindful of performance. Use only when module identity mutability is required.
affects: <=1.0.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'no-cache' in ...
Using 'no-cache' instead of 'no-cache-loader' in webpack config or inline require.
fix
Change to 'no-cache-loader': require('no-cache-loader!./module.js') or { test: /\.json$/, use: 'no-cache-loader' }.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
no-cache-loader — npm install no-cache-loader · libregistry