Skip to content

Commit

Permalink
Make the Backend fully ESM compatible, remove Babel (#1332)
Browse files Browse the repository at this point in the history
* First step towards making Backend fully ESM-compatible:
- Necessary changes made in package.json
- Most other changes are due to a missing file extension in most imports.
- One small change was that __dirname isn't available when using ESM, so I changed the way we resolve path to the YAML specifications by using process.cwd(), as we do in other fs.* functions.
- I'm testing the VSCode-GitHub integration now, hence the branch name that does not follow our convention - sorry

* Removed Babel, etc:
- Removed Babel, including: 'compile' step in package.json and other commands, all dependencies and configuration file
- Replaced the 'compile' step with a basic copy of directory to dist/. The reasoning behind this is that it let's us continue using current Dockerfiles etc without any changes.
- Major cleanups in ESlint config. Seems good so far, check out the screenshot in this issue: https://github.com/hajkmap/Hajk/issues/1328\#issuecomment-1517542129
- Moved Prettier's config to an own file
- Prettier seems fine too, see screenshot above
- If this works as intended, we have a much cleaner toolchain. NodeJS 16+ is now required but it shouldn't be a major problem.

* Added missing definition, no idea how it got lost.

* New lock file after clean deps install. Should close #1328.

* Workaround the fact that __dirname isn't available in ESM. This pretty much closes #1328.

* Ensure that the OpenApiValidator runs _after_ any async routes have been imported:
- This was discovered in #1332 but the problem first came up in #1309.
- OAV will only take care of routes that exists when the middleware runs. Hence, any async imports that haven't yet run will be unknown to the OAV and render a 404.
- This ugly setTimeout fix takes care of it but I'm open for a better solution (including discussing the future of OAV in our Backend).

* Minor fix in Prettier config to reflect that we use LF for new line throughout the project.
  • Loading branch information
jacobwod authored May 9, 2023
1 parent 3d5e076 commit e27680a
Show file tree
Hide file tree
Showing 41 changed files with 3,537 additions and 7,869 deletions.
12 changes: 0 additions & 12 deletions new-backend/.babelrc

This file was deleted.

34 changes: 6 additions & 28 deletions new-backend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,11 @@
{
"parser": "@babel/eslint-parser",
"parserOptions": {
"sourceType": "module",
"requireConfigFile": false
},
"extends": [
"eslint:recommended",
"plugin:node/recommended",
"plugin:prettier/recommended"
],
"env": {
"mocha": true,
"node": true
"es2022": true,
"node": true,
"mocha": true
},
"plugins": ["prettier", "node"],
"rules": {
"no-unused-vars": 2,
"node/no-unsupported-features/es-syntax": 0,
"node/no-unpublished-import": ["off"],
"prettier/prettier": [
"error",
{
"singleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"printWidth": 80,
"endOfLine": "auto"
}
]
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
}
}
9 changes: 9 additions & 0 deletions new-backend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tabWidth": 2,
"useTabs": false,
"singleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"printWidth": 80,
"endOfLine": "lf"
}
Loading

0 comments on commit e27680a

Please sign in to comment.