LinkedSoftwareDependencies / Components-Generator.js

⚙️ Generate Components.js component files from TypeScript
13 stars 7 forks source link

"lsd:module": true does not work on Windows #115

Closed joachimvh closed 1 year ago

joachimvh commented 1 year ago

I'm assuming this is a Windows problem as it occurred trying to build Comunica. But I have no idea what is causing this or why so I'm just describing the situation as I don't know where to look further, so the title might also be wrong.

When building Comunica, and first fixing https://github.com/LinkedSoftwareDependencies/Components-Generator.js/issues/114, I get the following error:

Could not find a valid import path for lib/ActorAbstractMediaTyped.jsonld. 'lsd:importPaths' in package.json may be invalid.

This error is thrown if the following loop does not find a result: https://github.com/LinkedSoftwareDependencies/Components-Generator.js/blob/d58bfa24097617ca75e066f027b91589b91f5e4b/lib/serialize/ComponentConstructor.ts#L167-L171

The reason it doesn't find a result is because in this case the sourcePath is lib/ActorAbstractMediaTyped.jsonld, but the values for path are components/ and config/, which are the default values that are used when the package.json does not define any import paths and only has 'lsd:module': true.

So I have no idea how this function is supposed to succeed. Does this mean the sourcePath value is wrong or are there supposed to be other import paths? The sourcePath is created here: https://github.com/LinkedSoftwareDependencies/Components-Generator.js/blob/d58bfa24097617ca75e066f027b91589b91f5e4b/lib/serialize/ComponentConstructor.ts#L121-L123 If it is wrong, that might mean the this.pathDestination object is wrong, which has the following values:

{
  packageRootDirectory: 'C:\\projects\\comunica\\comunica/packages/actor-abstract-mediatyped',
  originalPath: 'C:\\projects\\comunica\\comunica/packages/actor-abstract-mediatyped/lib',
  replacementPath: 'C:\\projects\\comunica\\comunica/packages/actor-abstract-mediatyped/components'
}

or the absolutePath, which is 'C:\\projects\\comunica\\comunica\\packages\\actor-abstract-mediatyped\\lib\\ActorAbstractMediaTyped'.

I tried a quick fix of making sure all paths in this process only have forward slashes but that didn't seem to fix it so I have no idea what is wrong here, as it all depends on what values are expected in the above functions.

rubensworks commented 1 year ago

I don't have an immediate idea what could be causing this. The lsd:module: true logic might be producing things that are not Windows-safe (which would explain why you're not running into it in CSS).

This might also be a potential clue to this issue: https://github.com/LinkedSoftwareDependencies/Components.js/issues/111#issuecomment-1368811736

joachimvh commented 1 year ago

When using "lsd:module": true, where are the generated components files expected to appear? In the lib folder next to the TS files, or in the components/config folder? I would assume not the lib folder as that is not one of the generated import paths but that is what it seems to be trying to do.

joachimvh commented 1 year ago

Found it, the issue is this line: https://github.com/LinkedSoftwareDependencies/Components-Generator.js/blob/d58bfa24097617ca75e066f027b91589b91f5e4b/lib/serialize/ComponentConstructor.ts#L156

So same thing, some path normalization is required.

rubensworks commented 1 year ago

Ah nice, good catch!