Skip to content

Commit

Permalink
feat: rewrite package to esmodules (#2)
Browse files Browse the repository at this point in the history
* feat: rewrite package to esmodules

BREAKING CHANGE: The package won't support CJS anymore.
  • Loading branch information
dziraf authored Apr 18, 2023
1 parent 3cad87b commit 154c36b
Show file tree
Hide file tree
Showing 21 changed files with 4,392 additions and 3,259 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 11,
ecmaVersion: 20,
sourceType: 'module',
},
plugins: ['react', '@typescript-eslint'],
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
- name: Setup
uses: actions/setup-node@v2
with:
node-version: '16'
- uses: actions/cache@v1
node-version: '18'
- uses: actions/cache@v2
id: yarn-cache
with:
path: node_modules
Expand All @@ -32,8 +32,8 @@ jobs:
- name: Setup
uses: actions/setup-node@v2
with:
node-version: '16'
- uses: actions/cache@v1
node-version: '18'
- uses: actions/cache@v2
id: yarn-cache
with:
path: node_modules
Expand All @@ -56,8 +56,8 @@ jobs:
- name: Setup
uses: actions/setup-node@v2
with:
node-version: '16'
- uses: actions/cache@v1
node-version: '18'
- uses: actions/cache@v2
id: yarn-cache
with:
path: node_modules
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
File renamed without changes.
22 changes: 11 additions & 11 deletions example-app/package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"name": "example-app",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"type": "module",
"scripts": {
"dev": "npx dotenv -c '.env' ts-node src/app.ts",
"build": "npx tsc -p tsconfig.json",
"knex": "npx knex --knexpath dist/example-app/src/models/index.js --knexfile dist/example-app/src/knexfile.js",
"migrate:up": "yarn knex migrate:latest"
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/node": "^16",
"dotenv": "^16.0.1",
"@types/express": "^4.17.17",
"@types/node": "^18",
"ts-node": "^10.9.1",
"typescript": "^4.8.2"
"typescript": "^4.9.5"
},
"dependencies": {
"@adminjs/express": "^5.0.0",
"adminjs": "^6.1.4",
"@adminjs/express": "^5.1.0",
"adminjs": "^6.8.7",
"ajv-formats": "^2.1.1",
"express": "^4.18.1",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"express-formidable": "^1.2.0",
"express-session": "^1.17.3",
"knex": "^2.2.0",
"knex": "^2.4.2",
"objection": "^3.0.1",
"pg": "^8.8.0",
"tslib": "^2.4.0"
"pg": "^8.10.0",
"tslib": "^2.5.0"
}
}
4 changes: 2 additions & 2 deletions example-app/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import express from 'express';
import AdminJS from 'adminjs';
import AdminJSExpress from '@adminjs/express';

import * as AdminJSObjection from '../../src';
import { ManagerResource, OfficeResource } from './resources';
import * as AdminJSObjection from '../../src/index.js';
import { ManagerResource, OfficeResource } from './resources/index.js';

AdminJS.registerAdapter(AdminJSObjection);

Expand Down
10 changes: 5 additions & 5 deletions example-app/src/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Knex from 'knex';
import { knex as Knex } from 'knex';

import knexConfig from '../knexfile';
import Office from './office.entity';
import Manager from './manager.entity';
import { BaseModel } from '../base-model';
import knexConfig from '../knexfile.js';
import Office from './office.entity.js';
import Manager from './manager.entity.js';
import { BaseModel } from '../base-model.js';

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

Expand Down
5 changes: 2 additions & 3 deletions example-app/src/models/manager.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BaseModel } from '../base-model';

import Office from './office.entity';
import { BaseModel } from '../base-model.js';
import Office from './office.entity.js';

class Manager extends BaseModel {
id: number;
Expand Down
4 changes: 2 additions & 2 deletions example-app/src/models/office.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseModel } from '../base-model';
import { BaseModel } from '../base-model.js';

import Manager from './manager.entity';
import Manager from './manager.entity.js';

export interface OfficeAddress {
street: string;
Expand Down
7 changes: 4 additions & 3 deletions example-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"module": "nodenext",
"moduleResolution": "nodenext",
"target": "esnext",
"lib": [
"es2018",
"esnext",
"DOM"
],
"skipLibCheck": true,
Expand Down
Loading

0 comments on commit 154c36b

Please sign in to comment.