Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[bug]: dist/ JS retains @agentscript/* imports after scope rewrite, breaking installed package

オープン
#35 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
node.js, typescript

調査の方向性

scripts/publish.mjs から始め、package.json のスコープの書き換えに対して packages//dist/ がどのように生成されるかを調べます。提供されている npm install と動的 import で再現し、その後 dist/index.js と dist/index.d.ts に残っている @agentscript/ 参照を調べます。インストールされたパッケージが @sf-agentscript/* 依存関係を解決し、parse export を呼び出せれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug

Summary

Installing the published npm package @sf-agentscript/agentforce@2.5.31 and importing it throws ERR_MODULE_NOT_FOUND: Cannot find package '@agentscript/parser' at runtime. The package on npm is currently unusable end-to-end.

Root cause

scripts/publish.mjs rewrites @agentscript/*@sf-agentscript/* in package.json files only (lines 14–15, 28–29). The compiled JS in packages/*/dist/ is built before this rewrite step, so the compiled output still contains literal import specifiers like:

import { parseAndHighlight } from "@agentscript/parser";

When npm installs @sf-agentscript/agentforce, dependency resolution correctly places the dep at node_modules/@sf-agentscript/parser (because the rewritten package.json lists it under that name). But the runtime code still asks for @agentscript/parser, so Node throws ERR_MODULE_NOT_FOUND.

The same issue affects the JSDoc @example blocks in dist/index.d.ts (cosmetic, but inconsistent).

Reproduction

mkdir /tmp/repro && cd /tmp/repro
npm init -y
node -e "let p=require('./package.json');p.type='module';require('fs').writeFileSync('package.json',JSON.stringify(p,null,2))"
npm install @sf-agentscript/agentforce
node --input-type=module -e "import('@sf-agentscript/agentforce').then(m => console.log(typeof m.parse))"

Actual output:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@agentscript/parser' imported from
  /tmp/repro/node_modules/@sf-agentscript/agentforce/dist/index.js

Expected: function (the parse export is callable).

Evidence

  • node_modules/@sf-agentscript/agentforce/package.json correctly lists "@sf-agentscript/parser": "4.0.0"
  • node_modules/@sf-agentscript/agentforce/dist/index.js line ~3 reads import { ... } from "@agentscript/parser"
  • node_modules/@sf-agentscript/agentforce/dist/index.d.ts JSDoc @example blocks reference '@agentscript/agentforce' (cosmetic, lower priority)

grep -rE "from '(@agentscript|@sf-agentscript)" node_modules/@sf-agentscript/agentforce/dist/ confirms every cross-package import in dist/ uses the un-rewritten @agentscript/* scope.

Possible fixes

  1. Rewrite dist after build, before publish. Add a step to scripts/publish.mjs that walks packages/*/dist/**/*.{js,mjs,cjs,d.ts,d.mts,map} and applies the same @agentscript/@sf-agentscript/ string replace. ~20 lines. Lowest blast radius.
  2. Build after rewrite. Reorder publish steps so package.json rewrite happens before pnpm build, then build emits the new scope. But TypeScript doesn't transform import specifiers, so this alone wouldn't help — sources still say from '@agentscript/parser'. Would also require source rewrites or a tsconfig path alias.
  3. Bundler alias / path mapping during publish builds. More invasive, requires per-package config changes.

Option 1 is the smallest, safest, and most localized change. I have a draft patch ready and am happy to send a PR if this approach is acceptable.

Related

  • #6 — the install command in the README was wrong; the README fix is in #34. This issue is the runtime half of the same end-to-end user journey.
  • This is also why PR #23's installation.md troubleshooting note describes the npm visibility error: users hitting the install-side bug never get to discover the runtime-side bug.

Environment

  • Node v20.14.0 (also reproduced on v22)
  • npm 10.7.0
  • macOS arm64
  • Package: @sf-agentscript/agentforce@2.5.31 (current latest on npm at time of report)
主要言語
TypeScript
スター
267
フォーク
54
平均マージ
48分
マージ済み PR(30日)
1

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

salesforce/agentscript のほかの issue

salesforce/agentscript の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。