Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement tree import of modules. #497

Closed
ariznaf opened this issue Nov 17, 2020 · 17 comments
Closed

Implement tree import of modules. #497

ariznaf opened this issue Nov 17, 2020 · 17 comments
Labels
enhancement fixed - please verify Issue has been fixed. Please verify and close.

Comments

@ariznaf
Copy link

ariznaf commented Nov 17, 2020

It seems that you cannot use a path with more than one level (nested path) in the modules section of a manifest.

I mean something like:

{
    "modules": {
        "*": "./app",
        "aral/util/*": "../arallib/util/*"
    }
}

In order to be able to use imports in code like:

import Tool from "aral/util/tool"

If you try to use it, when you run mcrun you get an error (not very useful error, as it does not provide any hint about where it comes from).

d:\...\pruebasModdable\tests>mcrun -d -m -p esp32 ssid="myssid" password="***"
### Error: No such file or directory

It seems that mcrun does not interpret paths with more than one level.

A workaround (provided by @phoddie) is to use this instead:

{
    "modules": {
        "*": "./app",
        "aral_util/*": "../arallib/util/*"
    }
}

import Tool from "aral_util/tool"

But it is ugly not to have standard import paths.

@phoddie
Copy link
Collaborator

phoddie commented Nov 17, 2020

The tools now support multi-part paths. To use that, you will need to update the Moddable SDK and rebuild tools. The Keeping Up To Date document explains how to do that.

@phoddie phoddie added the fixed - please verify Issue has been fixed. Please verify and close. label Nov 17, 2020
@ariznaf
Copy link
Author

ariznaf commented Nov 18, 2020

Woww. that is eficiency.

I will see if I can upgrade this afternoon..

By the way ... does it import all the subtree or just one level?

I mean if I have aral/util and aral/componentes, would I need to create

{
    "modules": {
        "*": "./app",
        "aral/components/*": "../arallib/components/*"
        "aral/util/*": "../arallib/util/*"
    }
}

Or would it be enough with ...

{
    "modules": {
        "*": "./app",
        "aral/*": "../arallib/*"
    }
}

@phoddie
Copy link
Collaborator

phoddie commented Nov 18, 2020

Thanks for giving it a try.

FYI - The module wildcard applies to one level. It is not recursive. While it would be convenient to have recursive imports for very large projects, properly supporting them is not trivial and so we don't intend to support recursive imports at this time.

@ariznaf
Copy link
Author

ariznaf commented Nov 19, 2020

OK, it is no a problem to import each subdir. It may be even convenient (so you don't forget what you are exactly using).

I will try to update my moddable sdk install and a test it, and will feed back (I could not do it yesterday):

@ariznaf
Copy link
Author

ariznaf commented Nov 19, 2020

I have updated moddable using the instructions, pulling from git, deleting build bin and tmp content and rbuillt moddable.
But it did not work for me.

I have changed the manifest to this:

{
	"modules": {
		"*": [
			"./app"
		],
		"aral/util/*": "../arallib/util/*",
		"aral/components/*": "../arallib/components/*"
	}
}

and the import statement to this:

import Color from "aral/util/rgbcolor";

And got the eror again:
### Error: No such file or directory

@ariznaf
Copy link
Author

ariznaf commented Dec 5, 2020

Any update on this?

I have tried it but it does not work yet.
May be there is somthing broken in my install?

@phoddie
Copy link
Collaborator

phoddie commented Dec 5, 2020

The feature is working as expected. Please see the example here.

@ariznaf
Copy link
Author

ariznaf commented Dec 7, 2020

I am getting mad with this.

I have tried to test the example you provided, but I continue getting an error:
image

I have checked every thing I could think of.
I have reinstalled moddable sdk and the espressif tools.
I have tested helloworld from your book and from examples in moddablesdk and it is working.

May be it is a windows bug?
I have made a git proyecto in github here:
https://github.com/ariznaf/pruebasMoodable/tree/main/treeImport-issue497

I have tried your example using the host integrated in one file (in the app directory as in your example) and creating a host (extracted from ch1 of your book it is in host directory) and a separate app to run with mcrun (in the test directory).

Neither of them work.
Any idea or any test I can try to fix the problem?

UPDATED: Chris has confirmed that it does not work in his windows environment either (in a conversation in gitter).

@wilberforce
Copy link
Contributor

@ariznaf

It looks like the mcconfig can't be found. Have you updated the PATH environment variable? If you have you might need to start another cmd window to get that setting.

@ariznaf
Copy link
Author

ariznaf commented Dec 7, 2020

mcconfig?

mcconfig runs and flashes the firmware. I have run and flashed other software from the examples and the iot bood.

It is only when I try to use the import in multi level tree when there is an error, and it is thrown after mcconfig is launched and running, is the mcconfig process the one that trows the error.

In the Example proyect I have put, if I use multiple branch tree (in directory test) it does not work, If I use just one level it works (othertest).
That is exactly the same behaviour I have reported in the first first comment.

@phoddie
Copy link
Collaborator

phoddie commented Dec 7, 2020

Perhaps the change to mcconfig is working on macOS but not Windows. That would explain the difference in our results. Path handling is different on Windows. We'll investigate that possibility.

@ariznaf
Copy link
Author

ariznaf commented Dec 7, 2020

Yes, it seems it is platform related.

I suspect that the function you use may be using to detect the / is changing it by \ in windows or something like that (interpreting the string as a directory).

@cmidgley has tested it with the same results and he is using windows too.

I am stuck with this problem and the check module not been loaded.

@phoddie
Copy link
Collaborator

phoddie commented Dec 7, 2020

This issue is about multi-part module specifiers. The check module does not use that and so is unrelated to the topic of this issue.

@ariznaf
Copy link
Author

ariznaf commented Dec 7, 2020

Yes, you are right, sorry, it seems another problem (I am sure that the problem is my manifest, in that case).

@phoddie
Copy link
Collaborator

phoddie commented Dec 8, 2020

A fix has been committed for this on Windows.

To try it:

  • Update Moddable SDK sources
  • Rebuild Moddable SDK tools
  • clean your test project
  • build your test project

@ariznaf
Copy link
Author

ariznaf commented Dec 8, 2020

I have upgraded moddable and tried.
It now works OK.

Thank you very much for the fix. I close the issue now, as it is solved (I am not sure if I should close or I should let you that task).

@ariznaf ariznaf closed this as completed Dec 8, 2020
@phoddie
Copy link
Collaborator

phoddie commented Dec 8, 2020

Wahoo!

Thank you for your patience. The cross-platform differences sometimes obscure problems.

Once you have confirmed a problem is resolved, it is helpful to close the issue. Thanks for doing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement fixed - please verify Issue has been fixed. Please verify and close.
Projects
None yet
Development

No branches or pull requests

3 participants