dethcrypto / dethcrypto/TypeChain
Types cannot be imported when packaged
- Dominant language
- TypeScript
- Stars
- 2.8k
- Forks
- 376
- PR merge metrics
- No merged PRs in 30d
Description
### Discussed in https://github.com/dethcrypto/TypeChain/discussions/755
Originally posted by **rtman** August 25, 2022
We're trying to make our typechain types reuseable by packaging them up as a private npm package. However this seems to cause issues like the following when in use in nextjs.
```
./node_modules/@scopeName/packageName/index.ts
Module parse failed: Unexpected token (6:12)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| /* eslint-disable */
> import type * as openzeppelin from "./@openzeppelin";
| import type * as uniswap from "./@uniswap";
| import type * as contracts from "./contracts";
```
Here's the package.json for the package:
```
{"name": "@scopeName/packageName", "version": "1.0.0-88d8202", "main": "index.ts"}
```
The root of the package is the output dir of typechain, containing all the types as well as the copied artifacts dir from hardhat.

I've seen a few related issues to this but no resolution yet https://github.com/dethcrypto/TypeChain/issues/609#issue-1113620678 https://github.com/dethcrypto/TypeChain/issues/278#issuecomment-743359593 , would be great to get some guidance here or a fix.
We're using `"@typechain/ethers-v5": "^10.0.0",`
Contributor guide
Assessment
This issue has not been assessed yet.