-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Improve support for modular javascript runtimes #429
Conversation
This comment has been minimized.
This comment has been minimized.
After some fiddling with file names, link locations, and TypeScript, it should now be possible for you to test this yourself:
|
Aside from downloading it over jsdelivr, you can also download it directly from the deno.land proxy: https://deno.land/x/gh:fluture-js:Fluture@dist2/dist/module.js |
This file can be consumed by any runtime that can load EcmaScript modules. Most prominently, web browsers, and Deno. As a bonus, Deno or other runtimes that support TypeScript will also see a reference for where to download the typings.
I believe this was added by mistake when the TypeScript types were introduced. I think it was probably copy pasted over from Tushar's personal TypeScript overrides for the 'fluture' module. It never caused any problems, because users have always been able to import Fluture from the 'fluture' module. However, this changes with Deno's dependency model. This commit removes the module declaration wrapper around the TypeScript types, forcing TypeScript to make the association with the relevant module in a different way. In particular, TypeScript should now make the association based either on the location of the file (when imported using Node's require algorithm), or based on a <reference> directive, such as the one used in dist/module.js.
const getPackageName = function (file) { | ||
return Future.node (function (done) { fs.readFile (file, 'utf8', done) }) | ||
.pipe (Future.chain (Future.encase (JSON.parse))) | ||
.pipe (Future.map (function (x) { return x.name })) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little strange to see const
alongside function expressions. Is there a reason to avoid arrow functions here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. You're right. This example was meant to illustrate what Fluture usage looks like in older runtimes. I guess I missed the const
.
Motivation
In particular, I'd like Fluture to be easy to use with Deno, but other runtimes, such as modern browsers, should also benefit from these changes.
Changes
I've added a pre-release build step to create a modular bundle alongside the already existing script bundle. I've also updated the documentation to draw more attention to the existence of these bundles, mention usage in Deno, and lower the emphasis on using the CommonJS version.