用工小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
主管理员 f501ad139d Merge branch 'master' of http://175.178.51.79:3000/Augcl/employ-front 2 months ago
..
index.d.ts 1 6 months ago
index.js 修复:修复代码 3 months ago
license 1 6 months ago
package.json Merge branch 'master' of http://175.178.51.79:3000/Augcl/employ-front 2 months ago
readme.md 修复:修复代码 3 months ago

readme.md

import-fresh

Import a module while bypassing the cache

Useful for testing purposes when you need to freshly import a module.

ESM

For ESM, you can use this snippet:

const importFresh = moduleName => import(`${moduleName}?${Date.now()}`);

const {default: foo} = await importFresh('foo');

This snippet causes a memory leak, so only use it for short-lived tests.

Install

npm install import-fresh

Usage

// foo.js
let i = 0;
module.exports = () => ++i;
const importFresh = require('import-fresh');

require('./foo')();
//=> 1

require('./foo')();
//=> 2

importFresh('./foo')();
//=> 1

importFresh('./foo')();
//=> 1