Skip to content
This repository was archived by the owner on Aug 27, 2024. It is now read-only.

Partially-revert Deno-first structure #153

Open
bdarcus opened this issue Jun 23, 2023 · 0 comments
Open

Partially-revert Deno-first structure #153

bdarcus opened this issue Jun 23, 2023 · 0 comments

Comments

@bdarcus
Copy link
Owner

bdarcus commented Jun 23, 2023

I think recent Deno enhancements should make this feasible.

See:

https://www.susanpotter.net/snippets/basic-deno-development-workflow-that-generates-node-artifacts/

The strategy, I think, would mean making use of importmaps for import statements. With that, I think that will provide compatibility for deno, node, bun, AND browsers.

I had already added the maps to deno.json; just need to change the import statements to use them.

And then, of course, ditch the dnt-based strategy., and use esbuild to compile the typescript code.

Testing can be handled via CI.


Here's a simple example with deno, bun, and node compatibility.

cat test.ts
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: test.ts
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ import url from 'node:url';
   2   │ import edtf from 'npm:edtf@^4.4.1'
   3   │
   4   │ export function isValidSlug(slug: string): boolean {
   5   │   return slug.length > 0;
   6   │ }
   7   │
   8   │ export function isValidId(id: number): boolean {
   9   │   return id > 0;
  10   │ }
  11   │
  12   │ export function isValidTitle(title: string): boolean {
  13   │   return title.length > 0;
  14   │ }
  15   │
  16   │ export function isValidUrl(url: string): boolean {
  17   │   return url.parse(url).ok;
  18   │ }
  19   │
  20   │ console.log(isValidSlug("One two"));
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────bun run test.ts
truedeno run test.ts
trueesbuild --bundle ./*.ts --platform=node > test.jsnode test.js
true
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant