[bug]: dist/ JS retains @agentscript/* imports after scope rewrite, breaking installed package
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- node.js, typescript
- Lĩnh vực
- build-system, release
Hướng nghiên cứu
Bắt đầu với scripts/publish.mjs và kiểm tra cách packages//dist/ được tạo ra so với việc viết lại scope của package.json. Tái hiện bằng npm install được cung cấp và dynamic import, sau đó kiểm tra dist/index.js và dist/index.d.ts để tìm các tham chiếu @agentscript/ còn lại. Hoàn tất khi package đã cài đặt phân giải được các dependency @sf-agentscript/* và export parse có thể được gọi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Installing the published npm package @sf-agentscript/[email protected] 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.jsoncorrectly lists"@sf-agentscript/parser": "4.0.0"✅node_modules/@sf-agentscript/agentforce/dist/index.jsline ~3 readsimport { ... } from "@agentscript/parser"❌node_modules/@sf-agentscript/agentforce/dist/index.d.tsJSDoc@exampleblocks 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
- Rewrite dist after build, before publish. Add a step to
scripts/publish.mjsthat walkspackages/*/dist/**/*.{js,mjs,cjs,d.ts,d.mts,map}and applies the same@agentscript/→@sf-agentscript/string replace. ~20 lines. Lowest blast radius. - 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 sayfrom '@agentscript/parser'. Would also require source rewrites or a tsconfig path alias. - 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.mdtroubleshooting 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/[email protected](current latest on npm at time of report)
- Ngôn ngữ chính
- TypeScript
- Star
- 267
- Fork
- 54
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của salesforce/agentscript
-
README Quick Start fails on macOS: Node 26 incompatibility and missing tree-sitter CLI prerequisiteĐang mở
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 75/100
salesforce/agentscript#33 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
salesforce/agentscript#73 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
salesforce/agentscript#71 · 1 bình luận ·
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
salesforce/agentscript#67 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
salesforce/agentscript#42 · 1 bình luận ·
Tất cả issue của salesforce/agentscript
Issue tương tự
-
docs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
remix-run/react-router#15558 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
solana-foundation/pay-kit#341 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
supabase/agent-skills#607 ·
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày