3 ms·
You can use webpack or JSPM to resolve directories at the top level. That way you can just import "web/X" even if the web/ directory isn't a sibling to your cur
by dismantlethesun 10y ago
You can use webpack or JSPM to resolve directories at the top level. That way you can just import "web/X" even if the web/ directory isn't a sibling to your current file.
It's not very helpful if you are distributing an NPM package, but for people who aren't authoring libraries, its a godsend.
- spankalee 10y agoDo you mean import '/web/X'? Import URLs have to start with a `/`, `./`, or `//`. Even so, that requires a build tool. I want to be able to load working sources directly out of my packages directory.
- dismantlethesun 10y ago> Do you mean import '/web/X'? Not if you use a build tool for your frontend. > Even so, that requires a build tool. That was basically what I was suggesting. I'm not sure what the other option really is. If you're working within the browser (implied by this being a frontend), then you have to use a build tool since javascript modules/imports haven't landed in any browser yet.
- spankalee 10y ago> If you're working within the browser (implied by this being a frontend), then you have to use a build tool since javascript modules/imports haven't landed in any browser yet. For now, but native JS module loading is right around the corner, and at that point I don't want to have a required tool to load my modules. Currently I use HTML Imports, which don't require tools because they use relative URLs. It works really well, so I hope to use that pattern with JS modules.