-
Notifications
You must be signed in to change notification settings - Fork 105
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
feat: built-in web bundle #339
Conversation
Besided being called inside `bundle-all.sh`, `deno task bundle-web` can also be used to create the new bundle. Two files will be created inside the `out` folder: web.js and web.d.ts The `web.d.ts` file only re-exports everything from `out/mod.d.ts`. This file is needed because typescript refuses to search for types for the `web.js` file in anywhere other than a `web.d.ts` placed next to it. That behavior should be overriden by the `typesVersions` property in `package.json`, but for some reason it's not. The `typesVersions` property is necessary to make typescript detect the `/web` entrypoint, though.
Codecov ReportBase: 36.93% // Head: 36.93% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## main #339 +/- ##
=======================================
Coverage 36.93% 36.93%
=======================================
Files 17 17
Lines 4364 4364
Branches 157 157
=======================================
Hits 1612 1612
Misses 2750 2750
Partials 2 2 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
…writes feat: add web-specific code
@roziscoding LMK if you need help fixing up CI. I'll be back later today or maybe tomorrow. I'll also want to test everything thoroughly once more. |
Co-authored-by: Roz <[email protected]>
I guess we don't need to backport |
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.
LGTM but will test all possible combinations manually before approving.
- from npm tarball
- from npm link
- from GitHub install
and
- from a JS file
- from an MJS file
- from a CJS file
- from a TS file
- from TS build output
and
- in Deno
- in Node
-
in a browser script - in a browser module
- in a browser with Deno tooling
- in a browser with Node tooling
and
- compile time
- runtime
Will ESM work on browser scripts? |
No, that's one of the impossible combinations, I think. I'll test it. |
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.
Amazing changes! I tried this and one can now easily import { Bot } from "grammy/web"
with VuePress 2.0 in order to run a bot inside the browser. Thank you so much!
@all-contributors add @roziscoding for this idea! |
@roziscoding already contributed before to ideas |
if (specifier.endsWith(".deno.ts")) { | ||
const baseLength = specifier.length - ".deno.ts".length; | ||
specifier = specifier.substring(0, baseLength) + ".web.ts"; | ||
} | ||
return cache.load(specifier); |
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.
if (specifier.endsWith(".deno.ts")) { | |
const baseLength = specifier.length - ".deno.ts".length; | |
specifier = specifier.substring(0, baseLength) + ".web.ts"; | |
} | |
return cache.load(specifier); | |
return cache.load(specifier.replace(/\.deno\.ts$/, ".web.ts")); |
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.
Do you think that code is more readable?
oh … right, good |
Happy to see this merged! :D |
Besided being called inside
bundle-all.sh
,deno task bundle-web
can also be used to create the new bundle.Two files will be created inside the
out
folder: web.js and web.d.tsThe
web.d.ts
file only re-exports everything fromout/mod.d.ts
. Thisfile is needed because typescript refuses to search for types for the
web.js
file in anywhere other than aweb.d.ts
placed next to it.That behavior should be overriden by the
typesVersions
property inpackage.json
, but for some reason it's not. ThetypesVersions
property is necessary to make typescript detect the
/web
entrypoint,though.