Skip to content
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

suggestion: add guide on how to use the Standard Library in the browser #4586

Open
iuioiua opened this issue Apr 15, 2024 · 2 comments
Open
Labels
feedback welcome We want community's feedback on this issue or PR good first issue Good for newcomers PR welcome A pull request for this issue would be welcome

Comments

@iuioiua
Copy link
Contributor

iuioiua commented Apr 15, 2024

In other words, how to transpile and bundle code for the browser. This should:

  1. Be in the README.md.
  2. Include appropriate snippets using deno_emit. This may require further work in deno_emit. See Support jsr: specifiers deno_emit#167.
  3. Note any considerations one must make when doing so. E.g. a source file must contain the browser-compatible declaration. See https://github.com/denoland/deno_std/blob/main/_tools/check_browser_compat.ts.
@iuioiua iuioiua added good first issue Good for newcomers feedback welcome We want community's feedback on this issue or PR PR welcome A pull request for this issue would be welcome labels Apr 15, 2024
@kt3k
Copy link
Member

kt3k commented Apr 17, 2024

I think we should recommend esbuild with esbuild-deno-loader instead of deno_emit for bundling as deno_emit is no longer actively maintained. (esbuild-deno-loader already supports jsr:)

@RickeyWard
Copy link

@deno/emit is able to bundle a main.ts file with jsr import { parseArgs } from "jsr:@std/cli/parse-args"; with no issues.
so this not supporting JSR remark may be stale or incomplete, maybe it's just in some satiations?

what emit definitely doesn't support is what the eslint plugin is needed for which is using aliases defined in deno.json.

If anyone finds their way here looking for a useable example of deno emit to do basic bundling for offline use:

import { ensureDirSync } from "jsr:@std/fs@~0.218.2/ensure_dir";
import { bundle } from "jsr:@deno/emit";
const result = await bundle(
    new URL("./main.ts", import.meta.url)
);
const { code } = result;
ensureDirSync("dist");
await Deno.writeTextFile("dist/out.js", code); 

IMO Deno's biggest miss is only allowing you to pull in library code for offline use distribution is if you run "compile". you cant ship a folder of js scripts and one deno.exe because it will need internet access or an external bundler (even though since compile does it, it must still know how todo do it internally)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback welcome We want community's feedback on this issue or PR good first issue Good for newcomers PR welcome A pull request for this issue would be welcome
Projects
None yet
Development

No branches or pull requests

3 participants