This entry is answer for @MikroOrm's Tweet.
Abstract
- As a result Everything works fine.
- But I do not know the cause, but works fine(Can not reproduce ... sorry).
- MikroORM works very well!
- Thanks for your advice!
Logs
Phase 1. Next.js with MikroORM works fine.
I researched MikroORM and Next.js. And found following repository which I refer to.
github.com
It works fine.
(I couldn't reach following entry, but same author's lecture. Nice entry!)
medium.com
Phase 2. Configuration.PLATFORMS require all driver ( Can not reproduce)
I wrote any code and refactoring( I think that detail of this is important, but I could'nt find it ).
I saw an error as require @mikro-orm/mariadb but not found
. I used Postgresql, and already installed @mikro-orm/postgresql worked fine on Phase 1.
I tried installing @mikro-orm/mariadb, but another driver required.
Error line is Configuration.PLATFORMS
Configuration.PLATFORMS = {
mongo: { className: 'MongoDriver', module: () => require('@mikro-orm/mongodb') },
mysql: { className: 'MySqlDriver', module: () => require('@mikro-orm/mysql') },
mariadb: { className: 'MariaDbDriver', module: () => require('@mikro-orm/mariadb') },
postgresql: { className: 'PostgreSqlDriver', module: () => require('@mikro-orm/postgresql') },
sqlite: { className: 'SqliteDriver', module: () => require('@mikro-orm/sqlite') },
};
I could not solve this.
Phase 3. I realized "Error occured by entity's Decorator on build for client"
I tried creating interface for client(not importing MikroORM's Decorators), Errors not occured!
I thought that errors are solved by changing build config for client/server( Following Tweet )
Phase 4. Omit Decorators and Use EntitySchema helper
Well, MicroORM provide EntitySchema helper as another method of creating schema.
https://mikro-orm.io/docs/defining-entities#entityschema-helper
I tried and It works fine.
Finally, EntitySchema helper's entity is few dependency and more simple code!
Phase 5. @MicroOrm's advice
Thanks for your kindness.
I tried My problem reproducing from my past commit. But no errors occured. It works very well(I'm confused it).
Unfortunately, I could not provide good report for this problem.
So MikroORM's developer's experience is very good. Thanks for your great work!
My package.json(save my versions)
{
"name": "myapp",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"test": "env TS_NODE_PROJECT=\"tsconfig.test.json\" mocha './test/**/*.spec.ts'",
"test-single": "env TS_NODE_PROJECT=\"tsconfig.test.json\" mocha $@"
},
"dependencies": {
"@babel/core": "^7.12.10",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-decorators": "^7.12.12",
"@material-ui/core": "^4.11.2",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.57",
"@material-ui/pickers": "3.x.x",
"@mikro-orm/core": "^4.3.4",
"@mikro-orm/postgresql": "^4.3.4",
"@mikro-orm/reflection": "^4.3.4",
"babel-plugin-transform-typescript-metadata": "^0.3.1",
"final-form": "^4.20.1",
"firebase": "^8.1.1",
"firebase-admin": "^9.4.2",
"mui-rff": "^3.0.3",
"next": "10.0.3",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-final-form": "^6.5.2",
"react-query": "^3.5.11",
"recoil": "^0.1.2",
"utility-types": "^3.10.0",
"yup": "^0.32.8"
},
"devDependencies": {
"@firebase/rules-unit-testing": "^1.1.6",
"@mikro-orm/cli": "^4.3.4",
"@types/chai": "^4.2.14",
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.10",
"@types/react": "^17.0.0",
"chai": "^4.2.0",
"mocha": "^8.2.1",
"ts-node": "^9.1.1",
"typescript": "^4.1.2"
},
"mikro-orm": {
"useTsNode": true,
"tsConfigPath": "./tsconfig.orm.json",
"configPaths": [
"./db/mikro-orm.config.ts"
]
}
}