LinkedSoftwareDependencies / Components.js

🧩 A semantic dependency injection framework
https://componentsjs.readthedocs.io/
Other
41 stars 6 forks source link

Some kind of package names are not allowed if it has a substring match with an existing components.js package? #117

Closed phochste closed 1 year ago

phochste commented 1 year ago

Issue type:


Description:

I have a project abcd can uses Components.Js for which I create typescript plugins that I can inject with success in my project. All works fine. Now I try to create these typescript plugins in a separate project abcddemo also with Components.js. I need to include abcd as a dependency (because I need some interfaces and helper functions). All works well as long as I don't have a package name that starts with an a or ab or abc. When I use abcddemo as package name and run a demo test I get as error:

> koreografeyeplugindemo@1.0.0 demo
> node dist/demo.js

2023-03-30T07:06:29.378Z [Components.js] error: Detected fatal error. Generated 'componentsjs-error-state.json' with more information.
/Users/hochsten/github.com/eyereasoner/KoreografeyePluginDemo/node_modules/componentsjs/lib/preprocess/ConfigPreprocessorComponent.js:32
                throw new ErrorResourcesContext_1.ErrorResourcesContext(`Could not find (valid) component types for config "${config.value}" among its types, or a requireName`, {
                      ^

ErrorResourcesContext: Could not find (valid) component types for config "urn:my-package:myInstance" among its types, or a requireName
    at ConfigPreprocessorComponentMapped.canHandle (/Users/hochsten/github.com/eyereasoner/KoreografeyePluginDemo/node_modules/componentsjs/lib/preprocess/ConfigPreprocessorComponent.js:32:23)
    at ConfigPreprocessorComponentMapped.canHandle (/Users/hochsten/github.com/eyereasoner/KoreografeyePluginDemo/node_modules/componentsjs/lib/preprocess/ConfigPreprocessorComponentMapped.js:28:38)
    at ConfigConstructorPool.getRawConfig (/Users/hochsten/github.com/eyereasoner/KoreografeyePluginDemo/node_modules/componentsjs/lib/construction/ConfigConstructorPool.js:70:53)
    at ConfigConstructorPool.instantiate (/Users/hochsten/github.com/eyereasoner/KoreografeyePluginDemo/node_modules/componentsjs/lib/construction/ConfigConstructorPool.js:48:34)

But, when I rename my package to xbcddemo and rebuild and rename the contexts in config.jsonld everything works well


Environment:

OSX.

  "dependencies": {
    "componentsjs": "^5.3.2"
  },
  "devDependencies": {
    "@types/n3": "^1.10.4",
    "componentsjs-generator": "^3.1.0",
    "typescript": "^5.0.2"
  }

Crash log:

componentsjs-error-state.json.zip

github-actions[bot] commented 1 year ago

Thanks for reporting!

rubensworks commented 1 year ago

Heh, that's a funny error.

It could be related to the auto-generated prefixes. Could you try overwriting that via -r in componentsjs-generator?

phochste commented 1 year ago

@rubensworks yes that works!

rubensworks commented 1 year ago

🎉