Skip to content

Commit

Permalink
Fix modules resolution (#23)
Browse files Browse the repository at this point in the history
# Fix modules resolution

## ♻️ Current situation & Problem
Currently modules aren't properly resolved. There is a mix between two
approaches. We have build process and package.json link of local file,
but result of this operation isn't used. Actually, TS alias is used,
which in the end works exactly like if we just imported relatively from
`packages` directory.


## ⚙️ Release Notes 
* Fix modules resolution


## 📚 Documentation
This PR changes from TS alias to import of the actual package. Now, this
resembles using 3rd party package, but it's stored in monorepo. It makes
it bulletproof to move a package to separate repo without a lot of
modifications.


### Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
arkadiuszbachorski authored Jun 4, 2024
1 parent aaaa9cb commit c2bb4e7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 19 deletions.
17 changes: 11 additions & 6 deletions package-lock.json

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

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@
"scripts": {
"dev": "concurrently \"next dev\" \"npm --prefix packages/example-package run watch\"",
"prebuild": "npm --prefix packages/example-package run build",
"buildTypes": "npm --prefix packages/example-package run buildTypes",
"build": "next build",
"start": "next start",
"lint": "eslint .",
"lint:fix": "eslint . --fix & prettier --write .",
"lint:ci": "npm run buildTypes && eslint --output-file eslint_report.json --format json .",
"lint:ci": "npm run prebuild && eslint --output-file eslint_report.json --format json .",
"pretest": "npm --prefix packages/example-package run build",
"test": "jest",
"docs": "typedoc",
"docs:ci": "typedoc --out ./out/docs --githubPages true"
},
"dependencies": {
"@stanfordbdhg/example-package": "file:../packages/example-package",
"@stanfordbdhg/example-package": "file:./packages/example-package",
"next": "^14",
"prettier-plugin-tailwindcss": "^0.5.14",
"react": "^18",
Expand Down
3 changes: 2 additions & 1 deletion packages/example-package/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
# SPDX-License-Identifier: MIT
#

dist
dist
node_modules
6 changes: 4 additions & 2 deletions packages/example-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"name": "@stanfordbdhg/example-package",
"version": "0.1.0",
"private": true,
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"buildTypes": "tsc --emitDeclarationOnly",
"watch": "tsc -w"
},
"types": "dist/index.d.ts",
"exports": {
".": "./dist/index.js"
}
}
15 changes: 11 additions & 4 deletions packages/example-package/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{
"include": ["src"],
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
"module": "commonjs",
"target": "es6",
"lib": ["esnext"],
"jsx": "preserve",
"rootDir": "src",
"outDir": "dist",
"declaration": true,
"declarationMap": true
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
},
"include": ["src"],
"typedocOptions": {
"includeVersion": true,
"entryPoints": ["src/index.ts"]
Expand Down
3 changes: 0 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
"name": "next"
}
],
"paths": {
"@stanfordbdhg/example-package": ["./packages/example-package/dist"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"],
Expand Down

0 comments on commit c2bb4e7

Please sign in to comment.