Skip to content

Bug: npm package ships TypeScript source only — no compiled output (dist/) #1619

Closed

Description

@SinoGod

Bug: npm package ships TypeScript source only — no compiled output (dist/)

Description

The @memtensor/memos-local-openclaw-plugin npm package (both 1.0.8 and 1.0.10) publishes only TypeScript source code without compiled JavaScript output. This causes the plugin to fail loading in OpenClaw 2026.5.4, which expects compiled JS (dist/index.js, dist/index.mjs, or dist/index.cjs).

Steps to Reproduce

  1. Run the official install script:
    curl -fsSL https://cdn.memtensor.com.cn/memos-local-openclaw/install.sh | bash
  2. The install completes but the plugin fails to load with:
    plugins.slots.memory: plugin not found: memos-local-openclaw-plugin
    
  3. OpenClaw reports:
    installed plugin package requires compiled runtime output for TypeScript entry index.ts: expected ./dist/index.js, ./dist/index.mjs, ./dist/index.cjs, index.js, index.mjs, index.cjs
    

Root Cause

  • package.json has "main": "index.ts" (pointing to raw TypeScript)
  • prepublishOnly script is: echo 'Source-only publish — no build needed.'
  • No dist/ directory exists in the published package
  • No tsconfig.json is included

The package was designed assuming the runtime would handle TypeScript directly, but OpenClaw's plugin loader requires compiled JS.

Environment

  • OpenClaw: 2026.5.4 (stable)
  • OS: macOS 26.3.1 (arm64)
  • Node.js: v22.18.0
  • Plugin version: 1.0.10 (also confirmed on 1.0.8)

Workaround

Manually compile the plugin after install:

cd ~/.openclaw/extensions/memos-local-openclaw-plugin

# Create tsconfig.json
cat > tsconfig.json << 'TSEOF'
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "outDir": "./dist",
    "rootDir": ".",
    "declaration": false,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "resolveJsonModule": true,
    "strict": false,
    "noEmit": false
  },
  "include": ["index.ts", "src/**/*.ts"],
  "exclude": ["node_modules", "dist", "scripts", "skill"]
}
TSEOF

# Create type shim for openclaw/plugin-sdk
mkdir -p dist
cat > dist/openclaw-plugin-sdk.d.ts << 'DTEOF'
export interface OpenClawPluginApi {
  registerTool(...args: any[]): void;
  registerHook(...args: any[]): void;
  registerMemoryCapability(...args: any[]): void;
  getConfig(): any;
  getLogger(): any;
  logger: any;
  [key: string]: any;
}
DTEOF

# Compile
npx tsc

Then re-register the plugin in ~/.openclaw/openclaw.json.

Suggested Fix

Either:

  1. Add a tsconfig.json and include a prepublishOnly build step that compiles to dist/
  2. Or ship the compiled JS alongside the TypeScript source in the npm package
  3. Or change "main" in package.json to point to a compiled entry point

Activity

  1. fancyboi999 commented on May 6, 2026

    @fancyboi999
    Contributor

    @SinoGod Your report was solid — three repro steps plus a workaround saved a ton of dead-end exploration. Thanks.

    #1622 is up. Digging in, the problem turned out to go one layer deeper than the issue describes: tsconfig.json had rootDir: "src", which silently kept the OpenClaw plugin entry (root index.ts) out of the compile graph entirely. So even with a build step bolted on, the resulting dist/index.js would still have been src/index.ts's output — a separate library-style entry, not the plugin entry. Easy trap because the filenames collide.

    Could you try the branch on your side before we cut a release? My Node 25 ESM loader resolves dist/index.js to {id, register} here, which matches the OpenClaw plugin contract — but I don't have OpenClaw 2026.5.4 set up locally, so your environment is the real proof.

    git clone -b fix/openclaw-plugin-1619-publish-compiled-output \
      https://github.com/fancyboi999/MemOS.git
    cd MemOS/apps/memos-local-openclaw
    npm install
    npm run build      # tsc + post-process to add .js suffixes for Node ESM
    npm pack
    
    # Drop into OpenClaw
    rm -rf ~/.openclaw/extensions/memos-local-openclaw-plugin
    mkdir -p ~/.openclaw/extensions/memos-local-openclaw-plugin
    tar -xzf memtensor-memos-local-openclaw-plugin-*.tgz \
      -C ~/.openclaw/extensions/memos-local-openclaw-plugin --strip-components=1
    cd ~/.openclaw/extensions/memos-local-openclaw-plugin && npm install --omit=dev
    openclaw gateway stop && openclaw gateway start

    Ping me if anything still misloads — __dirname-style paths shifted with the new layout, so viewer/server.ts and bundled-memory-guide.ts are where I'd look first.

  2. treesan commented on May 9, 2026

    @treesan

    ~.openclaw/extensions/memos-local-openclaw-plugin/openclaw.plugin.json还需要增加:
    "contracts": { "tools": [ "memory_search", "memory_get", "memory_timeline", "memory_write_public", "memory_add", "memory_share", "memory_unshare", "memory_viewer", "network_memory_detail", "task_summary", "task_share", "task_unshare", "skill_search", "skill_get", "skill_install", "skill_publish", "skill_unpublish", "skill_file_get", "skill_files", "network_skill_pull", "network_team_info" ] }

  3. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on May 26, 2026
  4. Memtensor-AI commented on May 28, 2026

    @Memtensor-AI
    Collaborator

    ✅ AutoDev task 34246bb4eb50a83b completed.

    Summary: 修复 #1619:让 @memtensor/memos-local-openclaw-plugin 在 npm 发布时真正产出 dist/。改 tsconfig 把根 index.ts 与 src/ 一起编进 dist/(ESNext + bundler 解析以匹配 "type":"module"),新增 types/openclaw-plugin-sdk.d.ts 让 tsc 能解析 OpenClaw 注入的虚拟模块;package.json 把 main/types/openclaw.extensions 指向 ./dist/index.js,prepublishOnly 改为 npm run build,files 增加 dist 和 types;openclaw.plugin.json 同步切到 ./dist/index.js;postinstall.cjs 不再在升级时擦除 dist/(否则会把刚铺好的入口删掉)。本地 npm run build 通过,npm pack --dry-run 确认 tarball 内包含 dist/index.js。

    Base branch: v2.0.16
    Branch: autodev/MemOS-1619
    Commit: 5a6c63f
    PR: #1820
    Assigned to: @CarltonXiang, @syzsunshine219
    Reviewers: @CarltonXiang, @syzsunshine219

  5. added
    types:bugSomething isn't working | 功能异常
    ai:codingAI agent is coding | AI 正在编码
    on Jun 1, 2026
  6. Memtensor-AI commented on Jun 3, 2026

    @Memtensor-AI
    Collaborator

    🤖 AutoDev has picked up this issue and started working on it.

    Task ID: baa97aeeefdfdb4b
    Working branch: autodev/MemOS-1619
    Target branch: main
    Workflow: opsp (analysis → coding → testing → PR)

    I will post the PR link here once done. If I need more information, I will ask in the comments.

  7. Memtensor-AI commented on Jun 3, 2026

    @Memtensor-AI
    Collaborator

    ❌ AutoDev task baa97aeeefdfdb4b failed.

    Summary: Claude Code 未通过 submit_result 工具提交结果,且无文本输出
    Error: Claude SDK stream ended without invoking submit_result and without producing any text

  8. added
    ai:failedAI task failed | AI 任务失败
    ai:codingAI agent is coding | AI 正在编码
    and removed
    ai:codingAI agent is coding | AI 正在编码
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Jun 3, 2026
  9. self-assigned this
    on Jun 4, 2026
  10. Memtensor-AI commented on Jun 4, 2026

    @Memtensor-AI
    Collaborator

    🤖 AutoDev has picked up this issue and started working on it.

    Task ID: 6d210954ecf1948f
    Working branch: autodev/MemOS-1619
    Target branch: main
    Workflow: opsp (analysis → coding → testing → PR)

    I will post the PR link here once done. If I need more information, I will ask in the comments.

  11. added a commit that references this issue on Jun 4, 2026
    1b454c4
  12. Memtensor-AI commented on Jun 4, 2026

    @Memtensor-AI
    Collaborator

    ✅ AutoDev task 6d210954ecf1948f completed.

    Summary: Successfully fixed the npm package bug for @memtensor/memos-local-openclaw-plugin. The package was configured to ship TypeScript source files directly without compilation, which violated npm best practices and broke standard JavaScript module consumption.

    Changes Made:

    1. package.json updates:

      • Changed main entry from index.ts to dist/index.js (compiled output)
      • Added types field pointing to dist/index.d.ts for TypeScript type definitions
      • Updated files array to include dist/ instead of raw src/ and index.ts
      • Updated openclaw.extensions to reference ./dist/index.js
      • Replaced prepublishOnly no-op with prepack: npm run build to ensure compilation before packaging
    2. tsconfig.json updates:

      • Changed rootDir from "src" to "." to include root-level index.ts
      • Updated include to compile both src/ and index.ts
      • Changed module from CommonJS to ES2022 to match package.json "type": "module"
      • Changed moduleResolution to "bundler" for better ES module support
      • Added path mapping for openclaw/plugin-sdk external dependency
      • Set strict: false to allow compilation (package was previously source-only, has some type issues)
      • Expanded exclude to skip non-source directories
    3. New files added:

      • types/openclaw__plugin-sdk/index.d.ts - Type declarations for OpenClaw runtime-provided module
      • tests/verify-npm-package.sh - Automated test script verifying the package includes compiled output

    Verification:

    ✓ TypeScript compilation succeeds with npm run build
    ✓ dist/ directory generated with compiled JavaScript and type declarations
    ✓ npm pack --dry-run confirms package includes dist/ with all compiled files
    ✓ TypeScript source files excluded from package (only type declarations included)
    ✓ Main entry points to dist/index.js, OpenClaw extensions point to ./dist/index.js
    ✓ Test script passes all validation checks

    The package now follows standard npm conventions: pre-compiled JavaScript in dist/, proper entry points, and build hook ensuring compilation before publishing.

    Base branch: main
    Branch: autodev/MemOS-1619
    Commit: 1b454c4
    PR: #1887
    Assigned to: @MatthewZhuang, @CarltonXiang, @syzsunshine219
    Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219

  13. added
    ai:testingAI agent is running tests | AI 正在运行测试
    and removed
    ai:codingAI agent is coding | AI 正在编码
    ai:failedAI task failed | AI 任务失败
    ai:testingAI agent is running tests | AI 正在运行测试
    on Jun 4, 2026
  14. added a commit that references this issue on Jul 2, 2026
    0824256
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:pluginOpenClaw & Hermestypes:bugSomething isn't working | 功能异常

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions