-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chore/upgrade chai #65
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm... as far as I remember this was a bit weird that we need to import from build rather than .ts and specify index file
Yes I need to have another look at the |
knex/knex#4793 does not look good |
I've managed to fix this using: {
"db:cmd": "node --import='data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' ./node_modules/.bin/knex",
"db:migrate": "npm run db:cmd -- migrate:latest --knexfile src/lib/db/knexfile.ts",
"db:rollback": "npm run db:cmd -- migrate:rollback --knexfile src/lib/db/knexfile.ts"
} |
Broadly speaking I dislike all the horribleness especially needing to wrap all node commands in essentially:
This is basically caused by ts-node being massively behind the curve TypeStrong/ts-node#1997. As they don't seem to be responding it might be worth looking for a ts-node alternative and the two best options I've seen are: I'm not sure I want to do this switch right now, but we can consider it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
closing in favour of #66 |
Upgrade chai to v5 and switch to esm output. This PR superceeds #55
This was a pretty horrible upgrade but it all boilds down to chai (and in the future other dependencies) no longer supporting commonjs modules. The logic of this PR is therefore something like:
chai
no longer supportscommonjs
modules so we need to change the module type by adding"type": "module"
topackage.json
tsconfig
to output in native module format so useESNext
tsc
won't mangle import names this necessitates adding.js
extensions to all local imports (yes typescript understands what this means)mocha
or usingnodemon
we need to now tell it how to load modules. Usually this involves adding--loader ts-node/esm
to any node invocations but this now generates a warning in node asking us to switch to the vastly more horrible--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
. Reading arround this seems to be where node is heading so 🤦♂️import
rather thanrequire
at runtime we can no longer loadjson
without generating an experimental warning so I've changed that to read the swagger file manually