[英]JSPM bundle with relative imports
I'm working on converting an existing app to using JSPM. 我正在将现有的应用程序转换为使用JSPM。 I really appreciate using paths relative to the baseUrl so I don't have to do this
../../../../vendor/...
nonsense but I did like being able to import from ./siblingModule
to import from something in the same part of the hierarchy. 我真的很喜欢使用相对于baseUrl的路径,所以我不必这样做
../../../../vendor/...
废话,但我确实希望能够从./siblingModule
导入来自层次结构中相同部分的内容。 When trying to use jspm bundle that does currently use relative imports I get 当尝试使用当前不使用相对导入的jspm捆绑包时,我得到了
Error: ENOENT: no such file or directory, open '<project path + baseUrl>\siblingModule.js'
at Error (native)
Is there a way to configure JSPM to use relative paths for module resolution alongside baseUrl resolution? 有没有一种方法可以配置JSPM以将相对路径用于模块解析和baseUrl解析?
Ideally - 理想地-
module/submodule
checks for any valid paths entries and then checks baseUrl/module/submodule
module/submodule
检查所有有效路径条目,然后检查baseUrl/module/submodule
./module/submodule
checks in currentPath/module/submodule
./module/submodule
检查currentPath/module/submodule
/module/submodule
checks in baseUrl/module/submodule
/module/submodule
检查baseUrl/module/submodule
As far as I can tell this isn't ambiguous, though please correct me if I'm wrong. 据我所知这并不是模棱两可的,但是如果我错了,请纠正我。
ps using jspm 0.16.45 ps使用jspm 0.16.45
The baseUrl is used to resolve paths. baseUrl用于解析路径。
You can configure mapping and paths in config.json
, to import from these paths. 您可以在
config.json
配置映射和路径,以从这些路径导入。
But nothing prevents you to use these kind of import: import module from './otherModule/file.js';
但是没有什么可以阻止您使用这种类型的导入:
import module from './otherModule/file.js';
If you have a problem using import, it is probably something wrong in your configuration. 如果您在使用导入时遇到问题,则可能是您的配置有问题。
See documentation: https://github.com/systemjs/systemjs/blob/master/docs/getting-started.md 查看文档: https : //github.com/systemjs/systemjs/blob/master/docs/getting-started.md
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.