denoland / dnt

Deno to npm package build tool.
MIT License
1.23k stars 38 forks source link

Improve README for node #134

Closed N8Brooks closed 2 years ago

N8Brooks commented 2 years ago

First off, awesome project!

Currently, the recommendation (#1, #2) is to use Deno.copyFileSync to transfer the README.md of the Deno module to the npm package.

TypeScript Deno examples and TypeScript node examples are similar, but not exactly 1:1.

For example, my use-case:

The examples like the following:

import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
import { combinations } from "https://deno.land/x/combinatorics/mod.ts";
const sequences = [...combinations([1, 2, 3, 4], 2)];
assertEquals(sequences, [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]);

Use Deno style imports even though that is not valid for node.

I'm tempted to use RegExp:

readme.replaceAll(/"https:\/\/deno.land\/(?:\w+\/)+(\w+)\.ts"/g, '"$1"');

, but I am wondering if there are any DNT solutions.

Side note: What is the node equivalent of the Deno std asserts module? I feel like that is a potential drawback of this solution.

dsherret commented 2 years ago

I personally put both in the readme. Example: https://github.com/dsherret/using_statement

I'm not sure this is something that dnt should handle as in most cases someone could do a simple string replace and it should work. In other scenarios like yours it's a bit more complicated and it would be very difficult for dnt to figure out the appropriate code for that. Maybe the examples could be changed to not do assertions.

N8Brooks commented 2 years ago

Hmmm, you're right. Thanks for the ideas. I'll close this issue.