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

Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set. #1146

Open
lohrm-stabl opened this issue Dec 4, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@lohrm-stabl
Copy link

Hello,

I get the following error:

ncc: Version 0.38.1
ncc: Compiling file index.js into ESM
ncc: Using [email protected] (local user-provided)
Error: [tsl] ERROR
      TS5096: Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set.
    at /workspaces/SBC-Device-API/node_modules/@vercel/ncc/dist/ncc/index.js.cache.js:38:1896272
    at /workspaces/SBC-Device-API/node_modules/@vercel/ncc/dist/ncc/index.js.cache.js:38:396262
    at _done (eval at create (/workspaces/SBC-Device-API/node_modules/@vercel/ncc/dist/ncc/index.js.cache.js:21:75523), <anonymous>:9:1)
    at eval (eval at create (/workspaces/SBC-Device-API/node_modules/@vercel/ncc/dist/ncc/index.js.cache.js:21:75523), <anonymous>:34:22)
error: "ncc" exited with code 1 (SIGHUP)

While I have both "allowImportingTsExtensions": true, and noEmit: true in my tsconfig.

Full config:

// https://gist.github.com/slavafomin/cd7a54035eff5dc1c7c2eff096b23b6b
{
  "$schema": "https://json.schemastore.org/tsconfig",
  "compilerOptions": {
    // From: https://github.com/tsconfig/bases/blob/main/bases/node20.json
    "lib": [
      "es2023"
    ],
    "module": "node16",
    "target": "es2022",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "moduleResolution": "node16",
    "allowSyntheticDefaultImports": true,
    // Most from: https://github.com/tsconfig/bases/blob/main/bases/strictest.json
    "allowUnusedLabels": false,
    "allowUnreachableCode": false,
    "exactOptionalPropertyTypes": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitOverride": true,
    "noImplicitReturns": true,
    "noPropertyAccessFromIndexSignature": true, // Conflicts with https://eslint.org/docs/latest/rules/dot-notation
    "noUncheckedIndexedAccess": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "isolatedModules": true,
    "checkJs": true,
    // Custom
    "baseUrl": "./",
    "rootDir": "./src",
    "noEmit": true, // We use ncc to build our code
    "preserveConstEnums": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "allowImportingTsExtensions": true,
    "typeRoots": [
      "./node_modules/@types",
    ],
    "types": [
      "node"
    ]
  },
  "include": [
    "./src/**/*.ts"
  ],
  "exclude": [
    "./src/public/",
    "build.cjs",
    "dist/*"
  ],
  "ts-node": {
    "esm": true,
    "experimentalSpecifierResolution": "node",
  }
}
@styfle styfle added the bug Something isn't working label Jan 3, 2024
@ejkg
Copy link

ejkg commented Apr 24, 2024

I am also experiencing this same issue and I have a much simpler tsconfig.

{
  "extends": "@tsconfig/node20/tsconfig.json",
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "emitDeclarationOnly": true,
    "composite": true,
    "esModuleInterop": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "outDir": "dist",
    "rootDir": "../../",
    "baseUrl": ".",
  }
}

When I run:

$ pnpm build

I get this error:

ncc: Version 0.38.1
ncc: Compiling file index.js into ESM
ncc: Using [email protected] (local user-provided)
Error: Module build failed (from ../../node_modules/.pnpm/@[email protected]/node_modules/@vercel/ncc/dist/ncc/loaders/ts-loader.js):
Error: TypeScript emitted no output for /path/to/entry/index.ts.

Here is a sample of my package.json as well.

{
  "name": "package-namespace/a",
  "main": "dist/index.js",
  "type": "module",
  "version": "0.0.0",
  "scripts": {
    "build": "ncc build index.ts --out dist --no-cache --debug"
  },
  "dependencies": {
    "library-namespace/a": "workspace:*",
    "library-namespace/b": "workspace:*",
    "library-namespace/c": "workspace:*"
  },
  "devDependencies": {
    "@tsconfig/node20": "^20.1.4",
    "@types/node": "^20.12.4",
    "typescript": "^5.4.4"
  }
}

peps1 added a commit to peps1/srrup that referenced this issue Oct 20, 2024
* replace prompt-sync with @inquirer/prompts
* apply linting and deno format fixes
* fix logger typing errors
* bump version to 2.2.0

Known Issue: ncc not compatible yet with tsconfig allowImportTsExtensions option, see: vercel/ncc#1146
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants