stealjs / system-bower

[DEPRECATED] SystemJS and StealJS Bower plugin
MIT License
2 stars 1 forks source link

Add rel_path test. #21

Closed matthewbauer closed 7 years ago

matthewbauer commented 9 years ago

rel_path test tries to import and AMD module that imports a relative module. Currently failing.

see issue #20.

matthewp commented 9 years ago

Thanks, i'll check it out.

justinbmeyer commented 9 years ago

@matthewp Isn't this the problem that the changes to ES module naming is try to fix by going url based instead of moduleName based?

The code is importing: "rel_path". And then that tries to load a relative module. This is one of those things that really shouldn't work. Does AMD support this?

If it does, I wonder if "rel_path" is actually being normalized to "rel_path/exports".

matthewp commented 9 years ago

AMD supports this with packages config. I think at one time system-bower would normalize rel_path to rel_path/exports but I removed it.

matthewbauer commented 9 years ago

Okay,

so doing System.import("rel_path/exports") works as it should. I guess coming from CJS world importing "rel_path" is the same as importing "rel_path/index.js".

I guess my question would be if this isn't expected behavior, how should an "exports.js" file reference files included within its directory? I suppose hardcoding /bower_components/rel_path/rel would work, but that locks in AMD modules into using "bower_components".

I know that usually bower dependencies would be minified into a single file- but I think at least for testing you would want the ability to load multi-file bower modules.

matthewp commented 9 years ago

@matthewbauer

I guess my question would be if this isn't expected behavior, how should an "exports.js" file reference files included within its directory?

This is only a problem if the module name doesn't contain a /. Any modules in nested folders can import relative without an issue.

As a workaround you can add a map in your code:

"map": {
  "rel_path": "rel_path/exports"
}

As for Steal we should add a packages config extension to Steal core and use that in system-bower. But I think it might be a little while before I can get around to this.

matthewbauer commented 9 years ago

Ok.

Alternatively, would something like this work? I'm sure there is a reason to use paths for resolving main but that has been working for me.

-EDIT: I think that will break direct imports like System.import('rel_path/exports.js.

matthewp commented 9 years ago

We used to have something like that but it breaks apps that import themselves by name, as I recall.

matthewp commented 9 years ago

Let's keep this open though, it highlights the need for a packages config.