How to use decache - 10 common examples

To help you get started, we’ve selected a few decache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github runtools / run / core / src / resource / index.js View on Github external
function requireImplementation(file, {disableCache} = {}) {
  let implementation;

  try {
    if (disableCache) {
      decache(file);
    }

    implementation = require(file);
    if (implementation.default) {
      // ES Module
      implementation = implementation.default;
    }

    if (typeof implementation !== 'function') {
      throw createClientError(
        `A resource implementation file must export a function (file: ${formatPath(file)})`
      );
    }
  } catch (err) {
    implementation = () => {
      throw err;
github tonickkozlov / vue-tweet-embed / index.spec.jsdom.js View on Github external
test.afterEach(() => {
    // remove old cached every time to avoid side-effects
    decache('./dist')
    decache('./dist/tweet')
    decache('./dist/moment')
    decache('./dist/timeline')
})
github tonickkozlov / vue-tweet-embed / index.spec.jsdom.js View on Github external
test.afterEach(() => {
    // remove old cached every time to avoid side-effects
    decache('./dist')
    decache('./dist/tweet')
    decache('./dist/moment')
    decache('./dist/timeline')
})
github tonickkozlov / vue-tweet-embed / index.spec.jsdom.js View on Github external
test.afterEach(() => {
    // remove old cached every time to avoid side-effects
    decache('./dist')
    decache('./dist/tweet')
    decache('./dist/moment')
    decache('./dist/timeline')
})
github ariporad / pirates / test / helpers / utils.js View on Github external
function assertModule(t, filename, expected) {
  const absFilename = path.join(__dirname, '../fixture', filename);
  decache(absFilename);

  return t.is(require(absFilename), expected);
}
github nodkz / webpack-plugin-graphql-schema-hot / index.js View on Github external
const fs = require('fs').default || require('fs');
const minimatch = require('minimatch');
const decache = require('decache').default || require('decache');

function matchesGlobs(filePath, globs) {
  return (globs || []).some(glob => minimatch(filePath, glob, { matchBase: true }));
}

function WebpackPluginGraphqlSchemaHot(options) {
  this._canRun = true;
  const startupError = msg => {
    this._canRun = false;
    console.error('[WebpackPluginGraphqlSchemaHot]:\n' + msg);
  };

  const opts = options || {};
  this._isFirstRun = true;

  ///////////
github ludicrousxyz / light / src / cli / commands / dev.ts View on Github external
files.forEach((f): void => {
        decache(f.handler);
      });
      const routeObjs = importRoutes(files, routesPath, true);
github matthewconstantine / exuberant / src / render.js View on Github external
watcher.on('change', changePath => {
      const displayPath = path.relative(process.cwd(), changePath)
      log(`\n\nRebuilding. Detected change in ${displayPath}}`)
      decache(appFile)
      const updatedApp = require(appFile)
      const updatedElement = updatedApp.default
      rerenderElement(updatedElement, state)
    })
  }
github ludicrousxyz / light / src / cli / commands / dev.ts View on Github external
watcher.on('change', (p: string): void => {
      logger.hmr(`swapping out ${chalk.yellow(relative(cwd, p))}`);
      app.router.reset();
      decache(join(routesPath, '../', 'routes.js'));
      const files: any[] = findRoutes(routesPath);
      files.forEach((f): void => {
        decache(f.handler);
      });
      const routeObjs = importRoutes(files, routesPath, true);
      routeObjs.forEach((route: Route): void => {
        addRoute(app.router, route, opts);
      });
    });
  });
github n6g7 / httpdf / src / resolve.js View on Github external
indexDocument(srcPath) {
    const relPath = this.relPath(srcPath)
    const distPath = this.distPath(srcPath)
    const extension = path.extname(srcPath)
    const basename = path.basename(srcPath, extension)
    const relativeDir = path.dirname(relPath)
    const trimed = path.join(relativeDir, basename)

    const url = `/${trimed}`
    const requirePath = `./${path.relative(__dirname, distPath)}`

    try {
      decache(requirePath)
    } catch (err) {
      debug("Couldn't decache(%o)", requirePath)
    }
    const Component = require(requirePath).default

    if (!Component || !Component.document) return

    this.index.set(url, {
      filename: `${basename}.pdf`,
      Component,
    })

    debug("Indexed %o (at url %o)", relPath, url)
  }
}

decache

decache (Delete Cache) lets you delete modules from node.js require() cache; useful when testing your modules/projects.

MIT
Latest version published 2 years ago

Package Health Score

71 / 100
Full package analysis

Popular decache functions