<commit_before>#!/usr/bin/env node
const fs = require('fs')
const esbuild = require('esbuild')
const pathLib = require('path')
const packagesDir = pathLib.resolve(__dirname, '../..')

const localPackages = fs.readdirSync(packagesDir)

const pnpmPackageJson = JSON.parse(fs.readFileSync(pathLib.join(__dirname, 'package.json'), 'utf8'))

// This plugin rewrites imports to reference the `src` dir instead of `lib` so
// esbuild can compile the original TypeScript
const spnpmImportsPlugin = {
  name: 'spnpmImports',
  setup: (build) => {
    // This is an exception to the rule that all local packages start with `@pnpm`
    build.onResolve({ filter: /^dependency-path$/ }, ({path, resolveDir}) => ({
      path: pathLib.resolve(packagesDir, 'dependency-path', 'src', 'index.ts')
    }))

    // E.g. @pnpm/config -> /<some_dir>/pnpm/packages/config/src/index.ts
    build.onResolve({ filter: /@pnpm\// }, ({path, resolveDir}) => {
      const pathParts = path.split('/')
      const packageName = pathParts[1]

      // Bail if the package isn't present locally
      if (!localPackages.includes(packageName)) {
        return
      }

      const newPath = pathLib.resolve(packagesDir, packageName, 'src', 'index.ts')

      return {
        path: newPath
      }
    })
  }
}

;(async () => {
  await esbuild.build({
    bundle: true,
    platform: 'node',
    target: 'node14',<commit_msg>chore: fix pd.js<commit_after>#!/usr/bin/env node
const fs = require('fs')
const esbuild = require('esbuild')
const pathLib = require('path')
const { findWorkspacePackagesNoCheck } = require('@pnpm/find-workspace-packages')
const { findWorkspaceDir } = require('@pnpm/find-workspace-dir')

const pnpmPackageJson = JSON.parse(fs.readFileSync(pathLib.join(__dirname, 'package.json'), 'utf8'))

;(async () => {
  const workspaceDir = await findWorkspaceDir(process.cwd())
  const pkgs = await findWorkspacePackagesNoCheck(workspaceDir)
  const localPackages = pkgs.map(pkg => pkg.manifest.name)
  const dirByPackageName = pkgs.reduce((acc, pkg) => {
    acc[pkg.manifest.name] = pkg.dir
    return acc
  })

  // This plugin rewrites imports to reference the `src` dir instead of `lib` so
  // esbuild can compile the original TypeScript
  const spnpmImportsPlugin = {
    name: 'spnpmImports',
    setup: (build) => {
      // This is an exception to the rule that all local packages start with `@pnpm`
      build.onResolve({ filter: /^dependency-path$/ }, ({path, resolveDir}) => ({
        path: pathLib.resolve(dirByPackageName['dependency-path'], 'src', 'index.ts')
      }))

      // E.g. @pnpm/config -> /<some_dir>/pnpm/packages/config/src/index.ts
      build.onResolve({ filter: /@pnpm\// }, ({path, resolveDir}) => {
        const pathParts = path.split('/')
        const packageName = pathParts[1]

        // Bail if the package isn't present locally
        if (!localPackages.includes(packageName)) {
          return
        }

        const newPath = pathLib.resolve(dirByPackageName[packageName], packageName, 'src', 'index.ts')

        return {
          path: newPath
        }
      })
    }
  }

  await esbuild.build({
    bundle: true,
    platform: 'node',
    target: 'node14',
{'fraction_non_alphanumeric': 0.14857679074132, 'fraction_numerical': 0.0025023459493274947, 'mean_word_length': 3.2301587301587302, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3165429', 'n_tokens_mistral': 1028, 'n_tokens_neox': 999, 'n_words': 246}