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 is the parent directory containing 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”
package.json about where all the magic happens is done using
import statements, I mean those that look like:
import foo from 'myhub/mylibbylib/bar/bar'; // => myhub/src/mylibbylib/bar/bar.js
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)
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
src/mylibbylib then your import statements would have to become:
import foo from 'myhub/bar/bar'; // => myhub/src/mylibbylib/bar/bar.js
import foo from '~/bar/bar'; // => myhub/src/mylibbylib/bar/bar.js
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
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 (
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
Not sure if that helps at all.
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
myhub (or whatever is the name of your app) will not work here.