Skip to content
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

tshy fails to build a basic project #98

Open
aqeelat opened this issue Dec 12, 2024 · 0 comments
Open

tshy fails to build a basic project #98

aqeelat opened this issue Dec 12, 2024 · 0 comments

Comments

@aqeelat
Copy link

aqeelat commented Dec 12, 2024

I have a ts project that is very simple.
However, running yarn dlx tshy results in a bunch of

src/user/notification.ts:2:40 - error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.

2 import { NotificationTypeConfig } from './dto/notifications'
                                         ~~~~~~~~~~~~~~~~~~~~~

src/user/user.ts:1:40 - error TS2307: Cannot find module '../response.dto' or its corresponding type declarations.

1 import { ICommonSuccessResponse } from '../response.dto'
                                         ~~~~~~~~~~~~~~~~~

and then prints

writing tsconfig files...
using existing tsconfig.json
building /Users/aqeelat/sawi/monorepo/schemas
tshy config {
  exports: { './package.json': './package.json', '.': './src/index.ts' }
}
exports {
  './package.json': './package.json',
  '.': {
    import: { types: './dist/esm/index.d.ts', default: './dist/esm/index.js' },
    require: {
      types: './dist/commonjs/index.d.ts',
      default: './dist/commonjs/index.js'
    }
  }
}
set dialect { where: 'src', mode: 'esm' }
building esm
build failed

Our initial setup was based on: https://thesametech.com/how-to-build-typescript-project/ and it works fine.
I also tried tsup and it worked without any problem.

package.json

{
  "name": "schemas",
  "packageManager": "[email protected]",
  "main": "./dist/cjs/index.js",
  "types": "./dist/types/index.js",
  "module": "./dist/esm/index.js",
  "exports": {
    ".": {
      "import": "./dist/esm/index.js",
      "require": "./dist/cjs/index.js",
      "types": "./dist/types/index.js"
    }
  },
  "scripts": {
    "build": "rimraf ./dist; tsc -b ./tsconfig.cjs.json ./tsconfig.esm.json ./tsconfig.types.json && node ./scripts/prepare",
    "format": "prettier --write \"src/**/*.ts\"",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
  },
  "devDependencies": {
    "@eslint/js": "^9.15.0",
    "@types/eslint": "^9.6.1",
    "@types/eslint__js": "^8.42.3",
    "eslint": "^9.15.0",
    "eslint-plugin-prettier": "^5.2.1",
    "prettier": "^3.3.3",
    "rimraf": "^6.0.1",
    "typescript": "^5.6.3",
    "typescript-eslint": "^8.15.0"
  },
  "dependencies": {
    "date-fns": "^3.6.0",
    "zod": "^3.23.8"
  },
  "nx": {
    "name": "schemas"
  }
}

tsconfig.json

{
  "exclude": ["node_modules"],
  "include": ["src"],
  "compilerOptions": {
    "target": "ES2022",
    "useDefineForClassFields": true,
    "lib": ["ES5", "ES6", "ES2020", "ES2022"],
    "skipLibCheck": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "sourceMap": true,
    "resolveJsonModule": true,
    "moduleResolution": "node",
    "experimentalDecorators": true
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant