How to use @yarnpkg/pnpify - 3 common examples

To help you get started, we’ve selected a few @yarnpkg/pnpify 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 yarnpkg / berry / packages / plugin-node-modules / sources / NodeModulesLinker.ts View on Github external
const rootPath = this.opts.project.cwd;
    let prevLocatorMap: NodeModulesLocatorMap;
    try {
      prevLocatorMap = await readLocatorState(ppath.join(rootPath, NODE_MODULES, LOCATOR_STATE_FILE));
    } catch (e) {
      prevLocatorMap = new Map();
    }

    const pnp = makeRuntimeApi(pnpSettings, rootPath, defaultFsLayer);
    const nmTree = buildNodeModulesTree(pnp, {
      optimizeSizeOnDisk: true,
      knownLocatorWeights: new Map(Array.from(prevLocatorMap).map(([key, val]) => [key, val.size])),
      pnpifyFs: false,
    });
    const locatorMap = buildLocatorMap(rootPath, nmTree);
    await persistNodeModules(rootPath, prevLocatorMap, locatorMap, baseFs, this.opts.report);
  }
github yarnpkg / berry / packages / plugin-node-modules / sources / NodeModulesLinker.ts View on Github external
baseFs: nodeFs,
      maxOpenFiles: 80,
      readOnlyArchives: true,
    });
    const defaultFsLayer: FakeFS = new VirtualFS({baseFs});

    const rootPath = this.opts.project.cwd;
    let prevLocatorMap: NodeModulesLocatorMap;
    try {
      prevLocatorMap = await readLocatorState(ppath.join(rootPath, NODE_MODULES, LOCATOR_STATE_FILE));
    } catch (e) {
      prevLocatorMap = new Map();
    }

    const pnp = makeRuntimeApi(pnpSettings, rootPath, defaultFsLayer);
    const nmTree = buildNodeModulesTree(pnp, {
      optimizeSizeOnDisk: true,
      knownLocatorWeights: new Map(Array.from(prevLocatorMap).map(([key, val]) => [key, val.size])),
      pnpifyFs: false,
    });
    const locatorMap = buildLocatorMap(rootPath, nmTree);
    await persistNodeModules(rootPath, prevLocatorMap, locatorMap, baseFs, this.opts.report);
  }
github yarnpkg / berry / packages / plugin-node-modules / sources / NodeModulesLinker.ts View on Github external
const promise: Promise = (async () => {
      try {
        await removeDir(dstDir, {excludeNodeModules: keepNodeModules});
        if (linkType === LinkType.SOFT) {
          await xfs.mkdirpPromise(ppath.dirname(dstDir));
          await xfs.symlinkPromise(srcDir, dstDir);
        } else {
          const archivePath = getArchivePath(srcDir);
          if (archivePath) {
            const prefixInsideArchive = srcDir.substring(archivePath.length);
            await xfs.createReadStream(archivePath)
              .pipe(unzipper.Parse({concurrency: 8}))
              .on('entry', (entry) => {
                if (entry.path.length <= prefixInsideArchive.length) {
                  entry.autodrain();
                } else {
                  const entryName = entry.path.substring(prefixInsideArchive.length);
                  const fullPath = ppath.join(dstDir, entryName);
                  if (entry.type === 'Directory') {
                    xfs.mkdirpSync(fullPath, {chmod: 0o777});
                    entry.autodrain();
                  } else {
                    xfs.mkdirpSync(ppath.dirname(fullPath), {chmod: 0o777});
                    entry.pipe(fs.createWriteStream(fullPath));

@yarnpkg/pnpify

BSD-2-Clause
Latest version published 2 months ago

Package Health Score

95 / 100
Full package analysis

Similar packages