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

SyntaxError: Cannot use import statement outside a module #115

Open
0xHendrix opened this issue Jul 19, 2023 · 1 comment
Open

SyntaxError: Cannot use import statement outside a module #115

0xHendrix opened this issue Jul 19, 2023 · 1 comment
Assignees

Comments

@0xHendrix
Copy link

0xHendrix commented Jul 19, 2023

Using @727-ventures/typechain-polkadot": "1.1.0" and running typechain-polkadot --in src/abi --out src/types I get the following error in a Monorepo setup using PNPM:

import {Abi} from "@polkadot/api-contract";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1178:20)
    at Module._compile (node:internal/modules/cjs/loader:1220:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Object.require.extensions.<computed> [as .ts]

tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": ".",
    "outDir": "dist",
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "node",
    "esModuleInterop": true,
    "lib": ["esnext"],
    "pretty": true,
    "allowJs": true,
    "skipLibCheck": true,
    "alwaysStrict": true,
    "strict": true,
    "strictNullChecks": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "incremental": true,
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noUnusedLocals": true,
    "isolatedModules": true,
    "jsx": "preserve"
  },
  "exclude": ["**/node_modules", "**/dist"]
}

package.json:

{
  "name": "@project/contracts",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "module": "./dist/index.js",
  "types": "./dist/index.d.ts",
  "exports": {
    ".": {
      "import": "./dist/index.js",
      "types": "./dist/index.d.ts"
    }
  },
  "scripts": {
    "build": "pnpm run generate:types",
    "lint": "eslint --fix",
    "format": "prettier --write src/*",
    "generate:types": "polkadot-types-from-chain --endpoint wss://ws.test.azero.dev --output src/types",
    "generate:client": "typechain-polkadot --in src/abi --out src/client"
  },
  "dependencies": {
    "@polkadot/api": "10.9.1"
  },
  "devDependencies": {
    "@727-ventures/typechain-polkadot": "1.1.0",
    "@polkadot/typegen": "10.9.1",
    "ts-node": "10.9.1",
    "typescript": "5.1.6"
  }
}

Does this package support an ESM based repo?

@wottpal
Copy link

wottpal commented Apr 10, 2024

Same issue

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

3 participants