I think @justinbmeyer gave you the answer you were looking for, and you’re just misunderstanding some other things, however this may not be the case. Let me try and explain.
If you have a directory structure like:
myhub
├── package.json
└── src
├── mylibbylib
├── myapp.html
├── myapp.js
├── myapp.less
└── index.html
(where myhub is the parent directory containing the package.json)
The package.json has to be told that the src/ directory is where all the magic happens (everything above src/ is just boilerplate and won’t be needed to be looked at for “self” import statements).
Telling package.json about where all the magic happens is done using system.directories.lib within package.json like:
"directories": {
"lib": "src"
}
By “self” import statements, I mean those that look like:
import foo from 'myhub/mylibbylib/bar/bar'; // => myhub/src/mylibbylib/bar/bar.js
OR
import foo from '~/mylibbylib/bar/bar'; // => myhub/src/mylibbylib/bar/bar.js
(these import statements will work from within any .js file within your project)
So, essentially, ~/ and myhub/ point to myhub/src/ on the filesystem because that is how you set things up in your package.json using the system.directories.lib config. If, for instance, you changed system.directories.lib to src/mylibbylib then your import statements would have to become:
import foo from 'myhub/bar/bar'; // => myhub/src/mylibbylib/bar/bar.js
OR
import foo from '~/bar/bar'; // => myhub/src/mylibbylib/bar/bar.js
The directory myhub/src/mylibbylib would become the new main root for import because you’re sepcifying “name of your app” (myhub) points to here. In this case you would lose some flexibility as everything would have to be inside mylibbylib now, at least to maintain sane imports.
Another (final) example would be if you renamed src/ to blah/. You would need to update package.json, because now StealJS doesn’t know where to look when encountering an import statement that starts with the name of your package (myhub):
"directories": {
"lib": "blah"
}
Once you did this, you would not have to change your import statements; the following would continue to work:
import foo from 'myhub/mylibbylib/bar/bar'; // => myhub/blah/mylibbylib/bar/bar.js
Because you updated the package.json to tell StealJS about the new main root location for imports.
Not sure if that helps at all.
Edit:
Additionally, regarding your question:
Will this path structure work for both import and the paths option?
It is my understanding that paths for the system.paths option in package.json must be actual paths, and wildcard expansion of things like ~ and myhub (or whatever is the name of your app) will not work here.