Skip to content

Commit

Permalink
build: Install kolmafia-types w/o alias
Browse files Browse the repository at this point in the history
Due to a bug in NPM v7, `npm outdated` fails when kolmafia-types is
aliased. To work around this, we install `kolmafia-types` by its name,
and TypeScript's `compilerOptions.paths` field is used to resolve
`kolmafia` to `kolmafia-types`.

We also install:

- kolmafia-types 0.1.1 (updated)
- tsconfig-paths which is needed to run tests with Jasmine + ts-node

See also:

- GitHub issue for the NPM v7 bug:
  npm/cli#2800
- Description of the workaround:
  https://github.com/pastelmind/kolmafia-types/tree/v0.1.1#method-2-use-a-custom-path-to-resolve-kolmafia
  • Loading branch information
pastelmind committed Jun 14, 2021
1 parent 56d0026 commit 7e3e787
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 20 deletions.
111 changes: 93 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "gts lint",
"prerelease": "npm run clean && npm run build",
"release": "ts-node ./node-scripts/release-to-branch.ts",
"test": "jasmine --require=ts-node/register",
"test": "jasmine --require=tsconfig-paths/register --require=ts-node/register",
"posttest": "npm run lint"
},
"repository": {
Expand Down Expand Up @@ -41,13 +41,14 @@
"fs-extra": "^9.1.0",
"gts": "^3.1.0",
"jasmine": "^3.6.4",
"kolmafia": "npm:[email protected]",
"kolmafia-stubs": "^0.1.0",
"kolmafia-types": "^0.1.1",
"mock-require": "^3.0.3",
"rollup": "^2.41.2",
"rollup-plugin-copy": "^3.4.0",
"simple-git": "^2.36.2",
"ts-node": "^9.1.1",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.2.3"
},
"dependencies": {
Expand Down
5 changes: 5 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
{
"extends": "./node_modules/gts/tsconfig-google.json",
"compilerOptions": {
// Needed for paths field
"baseUrl": ".",
"composite": true,
// Import CommonJS modules using standard ESM syntax
"esModuleInterop": true,
Expand All @@ -11,6 +13,9 @@
"jsxFactory": "h",
"jsxFragmentFactory": "null",
"outDir": "build",
"paths": {
"kolmafia": ["./node_modules/kolmafia-types"]
},
"rootDir": "."
}
}

0 comments on commit 7e3e787

Please sign in to comment.