Convert commonjs to esm (#877)

This PR converts everything (aside from electron) from CommonJS to ESM.
It is needed to reduce the changes that will happen during the migration
to Typescript (as TS does not play nice with CJS).

Basically:
- rewrite `require()` to `import`
- rewrite `module.exports` to `exports`
- introduce `ts-node` to run importers so we can convert them to TS too

Lastly, sorry for this larg-ish PR, not my preference but when I tried
to reduce its scope, I would end up with mixed commons/esm that was even
more tricky to handle.
This commit is contained in:
Alberto Gasparin
2023-04-11 05:40:40 +10:00
committed by GitHub
parent d7d5820c1c
commit cd00da76ef
112 changed files with 708 additions and 813 deletions

View File

@@ -3,23 +3,25 @@
"version": "5.1.2",
"license": "MIT",
"description": "An API for Actual",
"main": "index.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"app",
"dist",
"default-db.sqlite",
"index.js",
"injected.js",
"methods.js",
"migrations",
"utils.js"
"migrations"
],
"scripts": {
"lint": "eslint .",
"build": "yarn workspace loot-core build:api"
"build:app": "yarn workspace loot-core build:api",
"build:node": "tsc --p tsconfig.dist.json",
"build": "yarn run build:app && yarn run build:node"
},
"dependencies": {
"better-sqlite3": "^8.2.0",
"node-fetch": "^2.6.9",
"uuid": "3.3.2"
},
"devDependencies": {
"typescript": "^5.0.2"
}
}