Skip to content

Commit d2e56d2

Browse files
build!: switch to esm
1 parent 6400703 commit d2e56d2

File tree

18 files changed

+88
-57
lines changed

18 files changed

+88
-57
lines changed

.devcontainer/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
FROM mcr.microsoft.com/devcontainers/javascript-node:20
1+
FROM mcr.microsoft.com/devcontainers/javascript-node:22
2+
3+
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
24

35
RUN corepack enable

.github/workflows/test.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,31 @@ jobs:
1111
with:
1212
node-version: 22
1313
cache: "yarn"
14-
- name: Install deps, build, then clear deps
14+
- name: Install deps and build
1515
run: |
1616
yarn install --immutable
1717
yarn build
1818
rm -rf node_modules
19-
- name: Test on Node 22
19+
20+
- name: test built package on node@22
21+
working-directory: ./package-test/
2022
run: |
23+
# CI implies --immutable
24+
yarn install --no-immutable
25+
2126
node -v
22-
node bin/test.js
23-
# Not using a matrix here since it's simpler
24-
# to just duplicate it and not spawn new instances
27+
node test.cjs
28+
node test.mjs
29+
30+
# Not using a matrix here since it's simpler
31+
# to just duplicate it and not spawn new instances
32+
2533
- uses: actions/setup-node@v4
2634
with:
2735
node-version: 20
28-
- name: Test on Node 20
36+
- name: test build package on node@20
37+
working-directory: ./package-test/
2938
run: |
3039
node -v
31-
node bin/test.js
32-
- uses: actions/setup-node@v4
33-
with:
34-
node-version: 18
35-
- name: Test on Node 18
36-
run: |
37-
node -v
38-
node bin/test.js
40+
node test.cjs
41+
node test.mjs

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"typescript.tsdk": "node_modules/typescript/lib",
23
"editor.formatOnSave": true,
34
"editor.defaultFormatter": "esbenp.prettier-vscode",
45
"editor.codeActionsOnSave": {

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@ yarn add pg-error-enum
1919

2020
### Usage
2121

22-
TypeScript or ES6 Modules
23-
2422
```ts
2523
import { PostgresError } from "pg-error-enum";
2624
```
2725

28-
JavaScript
26+
<details>
27+
<summary>Legacy CommonJS</summary>
2928

3029
```js
31-
const PostgresError = require("pg-error-enum").PostgresError;
30+
const { PostgresError } = require("pg-error-enum");
3231
```
3332

33+
</details>
34+
3435
Usage
3536

3637
```ts

bin/sync.mts renamed to bin/sync.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ const getEnum = async () => {
107107

108108
const writeEnum = (enumString: string) => {
109109
writeFileSync(
110-
new URL(
111-
"../src/PostgresError.ts",
112-
// @ts-expect-error requires package.json type: module
113-
import.meta.url,
114-
),
110+
new URL("../src/PostgresError.ts", import.meta.url),
115111
enumString,
116112
);
117113
};

eslint.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import tseslint from "typescript-eslint";
2+
3+
// eslint-disable-next-line import/extensions
4+
import sharedConfig from "@nihalgonsalves/esconfig/eslint.config.shared.js";
5+
6+
export default tseslint.config(
7+
{ ignores: ["package-test", "dist"] },
8+
...sharedConfig,
9+
{
10+
rules: {
11+
"@typescript-eslint/no-duplicate-enum-values": "off",
12+
"@typescript-eslint/restrict-template-expressions": [
13+
"error",
14+
{ allowNumber: true },
15+
],
16+
},
17+
},
18+
);

eslint.config.mjs

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

knip.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"$schema": "https://unpkg.com/knip@5/schema.json",
3-
"entry": ["src/index.ts!", "bin/sync.mts"],
3+
"entry": ["src/index.ts!", "bin/sync.ts"],
44
"project": ["**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}"],
55
}

package-test/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.yarn

package-test/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"devDependencies": {
3+
"pg-error-enum": "../"
4+
}
5+
}

0 commit comments

Comments
 (0)