@@ -212,6 +212,95 @@ describe("openclaw-bootstrap", () => {
212212 )
213213 ) . toContain ( "module.exports" ) ;
214214 } ) ;
215+
216+ it ( "installs scoped dependencies without resolving their runtime entrypoint" , async ( ) => {
217+ const packageRoot = await mkTempDir ( ) ;
218+ const homeDir = await mkTempDir ( ) ;
219+ const env = { OPENCLAW_STATE_DIR : path . join ( homeDir , ".openclaw" ) } ;
220+
221+ await mkdir ( path . join ( packageRoot , "dist" ) , { recursive : true } ) ;
222+ await writeFile (
223+ path . join ( packageRoot , "package.json" ) ,
224+ JSON . stringify (
225+ {
226+ name : "@aitoearn/openclaw-plugin" ,
227+ version : "1.2.3" ,
228+ files : [ "dist" , "openclaw.plugin.json" ] ,
229+ dependencies : {
230+ "@scope/dep-a" : "1.0.0" ,
231+ } ,
232+ } ,
233+ null ,
234+ 2
235+ ) ,
236+ "utf8"
237+ ) ;
238+ await writeFile ( path . join ( packageRoot , "dist" , "index.js" ) , "export {};\n" , "utf8" ) ;
239+ await writeFile ( path . join ( packageRoot , "openclaw.plugin.json" ) , "{}\n" , "utf8" ) ;
240+
241+ const scopedDependencyRoot = path . join (
242+ packageRoot ,
243+ "node_modules" ,
244+ "@scope" ,
245+ "dep-a"
246+ ) ;
247+ await mkdir ( path . join ( scopedDependencyRoot , "dist" , "esm" ) , { recursive : true } ) ;
248+ await writeFile (
249+ path . join ( scopedDependencyRoot , "package.json" ) ,
250+ JSON . stringify (
251+ {
252+ name : "@scope/dep-a" ,
253+ version : "1.0.0" ,
254+ type : "module" ,
255+ exports : {
256+ "." : {
257+ import : "./dist/esm/index.js" ,
258+ require : "./dist/cjs/index.js" ,
259+ } ,
260+ } ,
261+ } ,
262+ null ,
263+ 2
264+ ) ,
265+ "utf8"
266+ ) ;
267+ await writeFile (
268+ path . join ( scopedDependencyRoot , "dist" , "esm" , "index.js" ) ,
269+ "export const ok = true;\n" ,
270+ "utf8"
271+ ) ;
272+
273+ const result = await installPackageIntoOpenClaw (
274+ {
275+ rootDir : packageRoot ,
276+ manifest : {
277+ name : "@aitoearn/openclaw-plugin" ,
278+ version : "1.2.3" ,
279+ files : [ "dist" , "openclaw.plugin.json" ] ,
280+ dependencies : {
281+ "@scope/dep-a" : "1.0.0" ,
282+ } ,
283+ } ,
284+ } satisfies PackageContext ,
285+ env ,
286+ ( ) => homeDir
287+ ) ;
288+
289+ expect (
290+ await readFile (
291+ path . join (
292+ result . targetDir ,
293+ "node_modules" ,
294+ "@scope" ,
295+ "dep-a" ,
296+ "dist" ,
297+ "esm" ,
298+ "index.js"
299+ ) ,
300+ "utf8"
301+ )
302+ ) . toContain ( "ok = true" ) ;
303+ } ) ;
215304} ) ;
216305
217306async function mkTempDir ( ) : Promise < string > {
0 commit comments