Closed paulshen closed 2 years ago
@paulshen I just got around to taking a look at this. For the perf_hooks case if you use the JSPM generator via https://generator.jspm.io or via the API at https://github.com/jspm/generator it would be possible to add an import map entry like "perf_hooks": "./empty-module.js" to get this to work. We should better handle this case though in the main build I'm just unsure if the fix is to implement perf_hooks or not...
As for the TypeScript issue the problem here is that TypeScript isn't at the latest version because it has been timing out the build on JSPM. I'm currently trying to see if I can extend the build timeout to get TypeScript to build, will post back here if I make progress.
@guybedford Unfortunately, my use case is quite dynamic (JS playground) so I went down the rabbit hole of looking up dynamic import map issues (eg https://github.com/WICG/import-maps/issues/92). Thanks for pushing on these!
The TypeScript module is temporarily working for me yesterday but as of right now, I'm getting a problem related to perf_hooks
for TypeScript as well - understand a shim is needed. Thanks again for your work!
@paulshen I'm in the process of updating the JSPM core libs repo, and will include an empty perf_hooks shim with the next release to resolve this. It's going to be a few days yet while I test this release carefully though, will update here when it's done.
I noticed that perf_hooks
shim seems to be shipped! 🎉
Unfortunately, I'm still having trouble importing the typescript
package with jspm.dev. Ironically, typescript has a "is node-like" check and the shims make it pass. https://github.com/microsoft/TypeScript/blob/f9a3d85b00cd3c36130b253ec5381cf3b0265ed2/src/compiler/sys.ts#L1891-L1895
Because it passes this check, the browser import later fatals on os.platform
, which is missing in the shim. https://github.com/microsoft/TypeScript/blob/f9a3d85b00cd3c36130b253ec5381cf3b0265ed2/src/compiler/sys.ts#L1280
Maybe there's a way to define process.browser
? I don't know if that's a standard. Thanks for your work!
TypeScript has a specific issue to track in https://github.com/jspm/project/issues/119.
It is also recommended to use the generator.jspm.io version to be able to control the version lock and conditional environment.
It's a known problem though getting this all worked out, and I hope to get there it's just not the top priority just yet.
Hi! Thanks for making jspm! It looks great.
Trying it out, I ran into a couple issues trying to import the following libraries:
ts-morph
andtypescript
ts-morph
When trying to import
ts-morph
in the browser,https://jspm.dev/npm:@ts-morph/common@0.9!cjs
tries to fetchhttps://jspm.dev/npm:@jspm/core@2/nodelibs/perf_hooks
which returns 404The generator gives me the following error.
typescript
With
typescript
, I getLooks like it's related to NodeJS libraries. jspm seems to handle others fine so wanted to post here in case this was unexpected behavior. Thanks again!