Skip to content

Commit 5c681e3

Browse files
authored
improvement(global-aspect), allow aspects from .bitrc.jsonc to have main.runtime and no static-id (#9496)
Currently, these global-aspects from .bitrc.jsonc file must have `scope.runtime` instead of the `main.runtime`. It causes issues when testing via `loadAspect` API, which searches for "main.runtime" files. They also have to have `static id` prop in their runtime file in addition to the aspect file. This PR fixes these two issues. Normal aspects can work out of the box with no modifications.
1 parent e1283c9 commit 5c681e3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

scopes/harmony/aspect-loader/aspect-loader.main.runtime.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,9 +783,18 @@ export class AspectLoaderMain {
783783
res[manifest.id] = localAspect;
784784
return manifest;
785785
}
786-
// eslint-disable-next-line global-require, import/no-dynamic-require
787786
const module = require(dirPath);
788787
const manifest = module.default || module;
788+
const mainRuntime = this.findRuntime(dirPath, 'main');
789+
if (mainRuntime) {
790+
// eslint-disable-next-line global-require, import/no-dynamic-require
791+
const mainRuntimeModule = require(join(dirPath, 'dist', mainRuntime));
792+
const mainRuntimeManifest = mainRuntimeModule.default || mainRuntimeModule;
793+
// manifest has the "id" prop. the mainRuntimeManifest doesn't have it normally.
794+
mainRuntimeManifest.id = manifest.id;
795+
res[mainRuntimeManifest.id] = localAspect;
796+
return mainRuntimeManifest;
797+
}
789798
res[manifest.id] = localAspect;
790799
return manifest;
791800
});

0 commit comments

Comments
 (0)