How to use the @embroider/core.PackageCache function in @embroider/core

To help you get started, we’ve selected a few @embroider/core 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 embroider-build / embroider / packages / dedupe / src / index.ts View on Github external
async function traverse(options: Options) {
  let packageCache = new PackageCache();
  let app = packageCache.getApp(options['project-dir']);
  let versionMap: Map> = new Map();
  let consumers: Map> = new Map();

  let packageFilter = makePackageFilter(options, consumers);

  recordConsumers(app, consumers);
  let deps = app.findDescendants(dep => {
    recordConsumers(dep, consumers);
    // for now we're limiting ourselves only to ember addons. We can relax this
    // to eventually also include things that are directly consumed by ember
    // addons, or even the entire node_modules graph.
    return packageFilter(dep);
  });

  for (let dep of deps) {
github embroider-build / embroider / packages / macros / src / macros-config.ts View on Github external
import { join } from 'path';
import { PluginItem } from '@babel/core';
import { PackageCache, getOrCreate } from '@embroider/core';
import { makeFirstTransform, makeSecondTransform } from './glimmer/ast-transform';

const packageCache = new PackageCache();

export type Merger = (configs: unknown[]) => unknown;

// Do not change the public signature of this class without pondering deeply the
// mysteries of being compatible with unwritten future versions of this library.
class GlobalSharedState {
  configs: Map = new Map();
  mergers: Map = new Map();
}

// this is a module-scoped cache. If multiple callers ask _this copy_ of
// @embroider/macros for the shared MacrosConfig, they'll all get the same one.
// And if somebody asks a *different* copy of @embroider/macros for the shared
// MacrosConfig, it will have its own instance with its own code, but will still
// share the GlobalSharedState beneath.
let localSharedState: MacrosConfig | undefined;