Skip to content

Commit

Permalink
Switch to ESM (allows .ts test files)
Browse files Browse the repository at this point in the history
  • Loading branch information
double-beep authored Jan 28, 2024
1 parent 8cc94cf commit b474711
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@
],
"spec": [
"test/**/*.spec.*"
],
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
]
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"description": "template repository for userscripters' projects",
"scripts": {
"test": "mocha",
"test": "TS_NODE_PROJECT='./test/tsconfig.json' mocha",
"lint": "eslint src --fix --ext .js,.ts",
"clean": "rm -rf dist",
"prebuild": "npm run lint && npm run clean",
Expand Down Expand Up @@ -62,5 +62,6 @@
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"uglify-js": "^3.17.4"
}
},
"type": "module"
}
File renamed without changes.
8 changes: 8 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "esnext",
"esModuleInterop": true
},
"include": ["."]
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"@userscripters/stackexchange-api-types",
"jquery",
"greasemonkey",
"tampermonkey"
"tampermonkey",
"mocha"
]
},
"exclude": ["dist"],
Expand Down

0 comments on commit b474711

Please sign in to comment.