Skip to content

Commit

Permalink
refactor: rename js-import to jsimport
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 20, 2024
1 parent 3d3422f commit bc9a221
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 31 deletions.
24 changes: 12 additions & 12 deletions docs/2.generators/js-import.md → docs/2.generators/jsimport.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
# js-import
# jsimport

The `js-import` generator generates JavaScript usage example to be imported.
The `jsimport` generator generates JavaScript usage example to be imported.

<!-- automd:example cjs cdn generator=js-import name=pkg imports="foo,bar" -->
<!-- automd:example cjs cdn generator=jsimport name=pkg imports="foo,bar" -->

## Example

### Input

<!-- automd:js-import cjs=true cdn=true name=pkg imports=foo,bar -->
<!-- automd:jsimport cjs=true cdn=true name=pkg imports=foo,bar -->
<!-- /automd -->

### Output

<!-- automd:js-import cjs=true cdn=true name=pkg imports=foo,bar -->
<!-- automd:jsimport cjs=true cdn=true name=pkg imports=foo,bar -->

**ESM** (Node.js, Bun)

```js
import {
foo,
bar,
} from "pkg";
```

**CommonJS** (Legacy Node.js)

```js
const {
foo,
bar,
} = require("pkg");
```

**CDN** (Deno, Bun and Browsers)

```js
import {
foo,
bar,
} from "https://esm.sh/pkg";
```

<!-- /automd -->

<!-- /automd -->
Expand Down
1 change: 0 additions & 1 deletion src/generators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ export default {
"pm-x": pmX,
fetch: _fetch,
jsimport,
"js-import": jsimport,
"with-automd": withAutomd,
} as Record<string, Generator>;
2 changes: 1 addition & 1 deletion src/generators/jsimport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { defineGenerator } from "../generator";
const DEFAULT_CDN = "https://esm.sh/";

export const jsimport = defineGenerator({
name: "js-import",
name: "jsimport",
async generate({ config, args }) {
const { name } = await getPkg(config.dir, args);

Expand Down
4 changes: 2 additions & 2 deletions test/fixture/INPUT.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
<!-- automd:fetch url="https://gist.github.com/pi0/c176defbba5568b6d06ea619a75f6104/raw" -->
<!-- /automd -->

## `js-import`
## `jsimport`

<!-- automd:js-import cjs=true cdn=true name=pkg imports=foo,bar -->
<!-- automd:jsimport cjs=true cdn=true name=pkg imports=foo,bar -->
<!-- /automd -->

## `with-automd`
Expand Down
20 changes: 5 additions & 15 deletions test/fixture/OUTPUT.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,38 +99,28 @@ When your code doesn't work, don't blame yourself. It's clearly the compiler's f

Why waste time solving problems when someone else has already done it for you? Stack Overflow is your best friend, your mentor, and your savior. Just make sure to upvote the answers that save your bacon.


<!-- /automd -->

## `js-import`
## `jsimport`

<!-- automd:js-import cjs=true cdn=true name=pkg imports=foo,bar -->
<!-- automd:jsimport cjs=true cdn=true name=pkg imports=foo,bar -->

**ESM** (Node.js, Bun)

```js
import {
foo,
bar,
} from "pkg";
import { foo, bar } from "pkg";
```

**CommonJS** (Legacy Node.js)

```js
const {
foo,
bar,
} = require("pkg");
const { foo, bar } = require("pkg");
```

**CDN** (Deno, Bun and Browsers)

```js
import {
foo,
bar,
} from "https://esm.sh/pkg";
import { foo, bar } from "https://esm.sh/pkg";
```

<!-- /automd -->
Expand Down

0 comments on commit bc9a221

Please sign in to comment.