Skip to content

Commit 4d623c2

Browse files
committed
1.0.0
1 parent 69c6f13 commit 4d623c2

File tree

9 files changed

+772
-46
lines changed

9 files changed

+772
-46
lines changed

.github/workflows/publish-npm.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Publish npm
2+
on:
3+
release:
4+
types: published
5+
workflow_dispatch:
6+
concurrency:
7+
group: ${{ github.workflow }}
8+
cancel-in-progress: true
9+
jobs:
10+
publish-npm:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-node@v3
15+
with:
16+
cache: npm
17+
registry-url: https://registry.npmjs.org/
18+
- run: npm ci
19+
- run: npm publish
20+
env:
21+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 98 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,101 @@
1-
# punycode
1+
# Punycode Node.js ponyfill
22

3-
💔 Deprecated node:punycode module as an npm package
3+
💔 Deprecated `node:punycode` module as an npm package
44

5-
TODO:
5+
<div align="center">
66

7-
- Improve readme
8-
- Add GitHub Actions
9-
- Add metadata to package.json
10-
- Publish a v1.0.0 when all that's done
7+
![](https://i.imgur.com/5feCEHR.png)
8+
9+
</div>
10+
11+
🏃‍♀️ Uses the native `node:punycode` module when using Node.js \
12+
📋 Delegates to the [punycode.js v2.0.1] implementation everywhere else \
13+
⏳ Still prints the deprecation warning everywhere
14+
15+
🛑 **The `node:punycode` module is deprecated in Node.js core.** Instead, it's
16+
recommended to use a user-land implementation like [punycode.js]. This package
17+
is provided solely for parity with `node:` APIs.
18+
19+
## Installation
20+
21+
![npm](https://img.shields.io/static/v1?style=for-the-badge&message=npm&color=CB3837&logo=npm&logoColor=FFFFFF&label=)
22+
![Yarn](https://img.shields.io/static/v1?style=for-the-badge&message=Yarn&color=2C8EBB&logo=Yarn&logoColor=FFFFFF&label=)
23+
![pnpm](https://img.shields.io/static/v1?style=for-the-badge&message=pnpm&color=222222&logo=pnpm&logoColor=F69220&label=)
24+
![jsDelivr](https://img.shields.io/static/v1?style=for-the-badge&message=jsDelivr&color=E84D3D&logo=jsDelivr&logoColor=FFFFFF&label=)
25+
26+
Install this package using npm, [Yarn], [pnpm], or your other favorite npm
27+
package manager. Here's a quick copy-paste for npm users:
28+
29+
```sh
30+
npm install @nodefill/punycode
31+
```
32+
33+
This package is also compatible with Deno via their compatibility layer. You can
34+
import the package directly using [the new `npm:` specifier], or a
35+
Deno-compatible ESM CDN like [esm.sh] or [jsDelivr].
36+
37+
```js
38+
import {} from "npm:@nodefill/punycode";
39+
import {} from "https://esm.sh/@nodefill/punycode";
40+
```
41+
42+
If you're using not using a build tool and you just want to use the package in
43+
your browser, you can use an ESM npm CDN like [esm.sh] or [jsDelivr].
44+
45+
```js
46+
import {} from "https://esm.sh/@nodefill/punycode";
47+
import {} from "https://esm.run/@nodefill/punycode";
48+
```
49+
50+
## Usage
51+
52+
![Node.js](https://img.shields.io/static/v1?style=for-the-badge&message=Node.js&color=339933&logo=Node.js&logoColor=FFFFFF&label=)
53+
![Deno](https://img.shields.io/static/v1?style=for-the-badge&message=Deno&color=000000&logo=Deno&logoColor=FFFFFF&label=)
54+
![Browser](https://img.shields.io/static/v1?style=for-the-badge&message=Browser&color=4285F4&logo=Google+Chrome&logoColor=FFFFFF&label=)
55+
![Bun](https://img.shields.io/static/v1?style=for-the-badge&message=Bun&color=000000&logo=Bun&logoColor=FFFFFF&label=)
56+
57+
No matter what environment you import this package in, you'll always be greeted
58+
with a warning (unless you pass `node --no-warnings`). This package is
59+
**deprecated** in Node.js core. Instead, it's recommended to use a user-land
60+
implementation like [punycode.js]. This package is provided solely for parity
61+
with `node:` APIs.
62+
63+
Here's a quick overview of the API:
64+
65+
```js
66+
import { toASCII, toUnicode } from "@nodefill/punycode";
67+
68+
console.log(toASCII("😀"));
69+
//=> 'xn--e28h'
70+
71+
console.log(toUnicode("xn--wp8h"));
72+
//=> 👋
73+
```
74+
75+
📚 You can find more docs on the [punycode.js v2.0.1 README] or the [Node.js
76+
`node:punycode` docs]!
77+
78+
## Development
79+
80+
![JavaScript](https://img.shields.io/static/v1?style=for-the-badge&message=JavaScript&color=222222&logo=JavaScript&logoColor=F7DF1E&label=)
81+
82+
Special thanks to [Mathias Bynens] for the [punycode.js v2.0.1] implementation!
83+
The code for the non-`node` targets is ripped straight from there (plus a
84+
warning message and explicit exports). As for types, you can thank TypeStrong
85+
and the DefinitelyTyped community for the `@types/node` definitions which,
86+
again, are copy-pasted into the `index-types.d.ts` file.
87+
88+
There's no tests and no TypeScript since this package is simple enough to not
89+
warrant those extra things.
90+
91+
**This package itself should be deprecated on npm if/when the `node:punycode`
92+
module is removed from Node.js core.** Until then, don't deprecate it. Why? So
93+
that it doesn't show a warning when you install it, 😅 and so that it appears in
94+
npm search results. 😎
95+
96+
<!-- prettier-ignore-start -->
97+
[mathias bynens]: https://mathiasbynens.be/
98+
[punycode.js v2.0.1]: https://github.com/mathiasbynens/punycode.js/blob/v2.0.1/punycode.js
99+
[punycode.js v2.0.1 readme]: https://github.com/mathiasbynens/punycode.js/tree/v2.0.1#api
100+
[node.js `node:punycode` docs]: https://nodejs.org/api/punycode.html
101+
<!-- prettier-ignore-end -->

index.d.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

index.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

package-lock.json

Lines changed: 20 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
11
{
2-
"type": "commonjs",
3-
"license": "MIT",
4-
"repository": "github:nodefill/punycode",
52
"name": "@nodefill/punycode",
6-
"version": "0.1.0",
3+
"version": "1.0.0",
4+
"description": "💔 Deprecated node:punycode module as an npm package",
5+
"keywords": [
6+
"punycode",
7+
"nodejs",
8+
"ponyfill",
9+
"polyfill",
10+
"deprecated"
11+
],
12+
"homepage": "https://github.com/nodefill/punycode#readme",
13+
"bugs": "https://github.com/nodefill/punycode/issues",
14+
"repository": "github:nodefill/punycode",
15+
"license": "MIT",
16+
"contributors": [
17+
"Jacob Hummer <[email protected]> (https://jcbhmr.me/)"
18+
],
19+
"type": "commonjs",
20+
"exports": {
21+
".": {
22+
"types": "./src/index-types.d.ts",
23+
"node": "./src/index-node.js",
24+
"default": "./src/index-default.js"
25+
},
26+
"./lib/*": null,
27+
"./*.js": "./src/*.js"
28+
},
729
"files": [
8-
"index.js",
9-
"index.d.ts"
30+
"src"
1031
],
11-
"exports": "./index.js",
12-
"dependencies": {
13-
"@types/punycode": "2.1.0",
14-
"punycode.js": "2.1.0"
32+
"scripts": {
33+
"lint": "prettier --ignore-path .gitignore -w ."
34+
},
35+
"devDependencies": {
36+
"@types/node": "^20.4.2",
37+
"prettier": "^3.0.0"
1538
}
1639
}

0 commit comments

Comments
 (0)