Skip to content

Commit 154c36b

Browse files
authored
feat: rewrite package to esmodules (#2)
* feat: rewrite package to esmodules BREAKING CHANGE: The package won't support CJS anymore.
1 parent 3cad87b commit 154c36b

21 files changed

+4392
-3259
lines changed

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
ecmaFeatures: {
1414
jsx: true,
1515
},
16-
ecmaVersion: 11,
16+
ecmaVersion: 20,
1717
sourceType: 'module',
1818
},
1919
plugins: ['react', '@typescript-eslint'],

.github/workflows/push.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
- name: Setup
1111
uses: actions/setup-node@v2
1212
with:
13-
node-version: '16'
14-
- uses: actions/cache@v1
13+
node-version: '18'
14+
- uses: actions/cache@v2
1515
id: yarn-cache
1616
with:
1717
path: node_modules
@@ -32,8 +32,8 @@ jobs:
3232
- name: Setup
3333
uses: actions/setup-node@v2
3434
with:
35-
node-version: '16'
36-
- uses: actions/cache@v1
35+
node-version: '18'
36+
- uses: actions/cache@v2
3737
id: yarn-cache
3838
with:
3939
path: node_modules
@@ -56,8 +56,8 @@ jobs:
5656
- name: Setup
5757
uses: actions/setup-node@v2
5858
with:
59-
node-version: '16'
60-
- uses: actions/cache@v1
59+
node-version: '18'
60+
- uses: actions/cache@v2
6161
id: yarn-cache
6262
with:
6363
path: node_modules

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib"
3+
}
File renamed without changes.

example-app/package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
{
22
"name": "example-app",
33
"version": "1.0.0",
4-
"main": "index.js",
54
"license": "MIT",
5+
"type": "module",
66
"scripts": {
77
"dev": "npx dotenv -c '.env' ts-node src/app.ts",
88
"build": "npx tsc -p tsconfig.json",
99
"knex": "npx knex --knexpath dist/example-app/src/models/index.js --knexfile dist/example-app/src/knexfile.js",
1010
"migrate:up": "yarn knex migrate:latest"
1111
},
1212
"devDependencies": {
13-
"@types/express": "^4.17.13",
14-
"@types/node": "^16",
15-
"dotenv": "^16.0.1",
13+
"@types/express": "^4.17.17",
14+
"@types/node": "^18",
1615
"ts-node": "^10.9.1",
17-
"typescript": "^4.8.2"
16+
"typescript": "^4.9.5"
1817
},
1918
"dependencies": {
20-
"@adminjs/express": "^5.0.0",
21-
"adminjs": "^6.1.4",
19+
"@adminjs/express": "^5.1.0",
20+
"adminjs": "^6.8.7",
2221
"ajv-formats": "^2.1.1",
23-
"express": "^4.18.1",
22+
"dotenv": "^16.0.3",
23+
"express": "^4.18.2",
2424
"express-formidable": "^1.2.0",
2525
"express-session": "^1.17.3",
26-
"knex": "^2.2.0",
26+
"knex": "^2.4.2",
2727
"objection": "^3.0.1",
28-
"pg": "^8.8.0",
29-
"tslib": "^2.4.0"
28+
"pg": "^8.10.0",
29+
"tslib": "^2.5.0"
3030
}
3131
}

example-app/src/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import express from 'express';
22
import AdminJS from 'adminjs';
33
import AdminJSExpress from '@adminjs/express';
44

5-
import * as AdminJSObjection from '../../src';
6-
import { ManagerResource, OfficeResource } from './resources';
5+
import * as AdminJSObjection from '../../src/index.js';
6+
import { ManagerResource, OfficeResource } from './resources/index.js';
77

88
AdminJS.registerAdapter(AdminJSObjection);
99

example-app/src/models/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import Knex from 'knex';
1+
import { knex as Knex } from 'knex';
22

3-
import knexConfig from '../knexfile';
4-
import Office from './office.entity';
5-
import Manager from './manager.entity';
6-
import { BaseModel } from '../base-model';
3+
import knexConfig from '../knexfile.js';
4+
import Office from './office.entity.js';
5+
import Manager from './manager.entity.js';
6+
import { BaseModel } from '../base-model.js';
77

88
const knex = BaseModel.knex(Knex(knexConfig[process.env.NODE_ENV ?? 'development']));
99

example-app/src/models/manager.entity.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { BaseModel } from '../base-model';
2-
3-
import Office from './office.entity';
1+
import { BaseModel } from '../base-model.js';
2+
import Office from './office.entity.js';
43

54
class Manager extends BaseModel {
65
id: number;

example-app/src/models/office.entity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { BaseModel } from '../base-model';
1+
import { BaseModel } from '../base-model.js';
22

3-
import Manager from './manager.entity';
3+
import Manager from './manager.entity.js';
44

55
export interface OfficeAddress {
66
street: string;

example-app/tsconfig.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"compilerOptions": {
3-
"module": "commonjs",
4-
"target": "es6",
3+
"module": "nodenext",
4+
"moduleResolution": "nodenext",
5+
"target": "esnext",
56
"lib": [
6-
"es2018",
7+
"esnext",
78
"DOM"
89
],
910
"skipLibCheck": true,

0 commit comments

Comments
 (0)