New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading pure typescript packages #720
Comments
Yes, unfortunately these types of package configurations don't currently share on installing dependencies, and does require manually copying the package config in. This is being worked on for jspm 0.17 to support these properties in the package.json. |
Good stuff, tell me when you have a beta with that in it if you want some testing done or if there is something else I can do. |
BTW, just to work around until then (and see that there is no other problem with my setup), what should be copied where? Something into .jspm.json or what? |
Try using a configuration like - packages: {
"github:OptimalBPM/mbe-nodes@x.y.z": {
"defaultExtension": "ts"
}
} |
I have tried that, I have used an index.js, index.ts, rewritten mbe-nodes@0.4.9 and all kinds of stuff, and still it persists in trying to get the .ts.js if I write It is like that isn't happening in the same context as the rest of the loading, as if it doesn't care about defaultExtension for external libraries. |
Ah, ok I guess the package config is being overridden by the map config here. Try adding it to a separate System.config({
"github:OptimalBPM/mbe-nodes@x.y.z": {
"defaultExtension": "ts",
"map": {...whatever is in the config.js map for this package if anything...}
}
}); We should probably ensure that a package config always composes instead of replacing. |
Hmm actually package configs do already compose so that shouldn't be the issue. The way to debug this is to check that |
No, it didn't work, I'll do that and get back to you. |
I am trying to wrap my head around the code, and find out where what happens, but there is lots of it. It struck me that SystemJS is exactly the kind of application that would benefit greatly from being converted into TypeScript, for structure and readability. Just had to say it. Not that you wanted to hear it. :-) |
Are the paths loaded as |
I think I have found it. I missed that the 404 is not for OptimalBPM/mbe-nodes, but for: The reason is that the index.js-file in the mbe-nodes package seems to be parsed relative to the parent folder, not the package folder, so this doesn't work: But this does: However, the second variant is really cumbersome, as that means one more place to update the version information in the package. Interestingly, removing the "./": I used an index.js-file, as that seemed to be the only way to load it properly. |
Are you saying that the file at |
Yes, that is what I am saying. Running that in the index.html script tag yields: |
Not sure if that is relevant, but running it without the "./" returns |
Yes - that would be the baseURL then. Are you sure there isn't another require to |
I searched through the entire project "dist/nodes", and outside gulpfile.js, of course, I only find TypeScript imports, but even if they are transpiled into requires, they are inside the package. And as per above, it starts working if I change index.js into: So it would appear that the error is actually from there. |
That is very strange. Is there anyway at all you can share this test case for me to take a look? |
It kind of sucks, but the code is not in a public repo yet. I will see if I can provide some example. |
Is the "normalize" hook the normalizeSync-implementation, and what is used to find the correct path throughout? |
|
This is what fails:
..returns: |
That normalization is actually correct. Are you saying the file at |
Btw it is here it is being called: Line 61 in 9bc693e
No, it is the /* */
"format cjs";
module.exports = require("./dist/nodes.ts"); |
If I change that to: /* */
"format cjs";
module.exports = require("./mbe-nodes@0.4.10/dist/nodes.ts"); ...it works. |
|
I don't understand what you mean now.. |
The issue as you've shown is that the parentName being normalized to is being seen as |
You are right. it returns the correct: |
I'll debug some, I'll be back. |
Ok. there is a difference between the other packages. Could this be related to |
It is. If I remove the defaultExtension: "js" for the package, it gets the proper load.name. |
That is great to hear you've found a change that fixes it. In order to work out the issue though I do still need a full description of the issue though. Here's what I've got so far: You have a package that you installed via jspm, that is CommonJS, so the folder structure is:
As well as this you've then added custom SystemJS configuration: System.config({
packages: {
'github:package/name@x.y.z': {
defaultExtension: 'js'
}
}
}); To summarize the issue:
Does the above sound like it covers the full scenario? Are you able to reduce your test case to something similar, or do you think there are other factors at work here at all? |
Yes, except from some nitpicks: The jspm_packages/github/package/name@x.y.z.js is I am not running a System.Import, just a typescript import "mbe-nodes" (which I presume is transpiled into a ES6 import) in my main.ts(that initiates the application). But I suspect that should be the same. Yes, If I remove (I realize that I perhaps should rename nodes.ts to mbe-nodes.ts, but that is another matter) |
Thanks so much for your help tracking this down, I've added a possible fix in b7abc2c. Try running |
Well, almost, now it tries to load: If I rename (well there are some dependencies of the package that cannot be found, but that is probably something else) |
Ok great, try running |
Great work, that did it!! Now that that worked, it seems like the packages internal imports doesn't work properly, it doesn't seem like the deps of the package is checked, but that is possibly a completely different issue if one at all. Thanks!! |
👍 |
Hi,
I am writing a package that I want to keep in pure TypeScript.
The problem is that while it works well to load TypeScript files locally using package and defaultExtension, it becomes a different matter when I create a package and then install it using jspm.
Because then it feels like I lose control, specifying package extensions like this:
And "jspm_packages/github/OptimalBPM/mbe-nodes@0.4.9" or any other combinations I have tried doesn't help. It keeps trying to load the .ts.js either way.
NOTE: I am working against a local registry.
The text was updated successfully, but these errors were encountered: