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

Build failed: @types/aws-lambda #303

Open
NamesMT opened this issue Aug 20, 2023 · 6 comments
Open

Build failed: @types/aws-lambda #303

NamesMT opened this issue Aug 20, 2023 · 6 comments

Comments

@NamesMT
Copy link

NamesMT commented Aug 20, 2023

Environment

Node v18.14.0
unbuild v1.2.1

Caused by:
@types/aws-lambda v8.10.119

Reproduction

https://github.com/NamesMT/lambda-voie/tree/649142212e66e91c071389b6e57b224176d2369a

https://stackblitz.com/edit/github-5eousq?file=package.json
Enter the link above, install dependencies and run build.

Describe the bug

@types/aws-lambda have an export as namespace line that caused Syntax Error when building

Additional context

No response

Logs

~/projects/github-5eousq 1m 4s
❯ pnpm build

> lambda-voie@0.0.0 build /home/projects/github-5eousq
> unbuild

ℹ Building lambda-voie                                                                                           18:17:07
Error building /home/projects/github-5eousq: SyntaxError: Unexpected token (96:7) in /home/projects/github-5eousq/node_modules/.pnpm/@types+aws-lambda@8.10.119/node_modules/@types/aws-lambda/index.d.ts
SyntaxError: Unexpected token (96:7) in /home/projects/github-5eousq/node_modules/.pnpm/@types+aws-lambda@8.10.119/node_modules/@types/aws-lambda/index.d.ts
    at pp$4.raise (file:///home/projects/github-5eousq/node_modules/.pnpm/rollup@3.26.0/node_modules/rollup/dist/es/shared/node-entry.js:21421:13)
    at pp$9.unexpected (file:///home/projects/github-5eousq/node_modules/.pnpm/rollup@3.26.0/node_modules/rollup/dist/es/shared/node-entry.js:18632:8)
    at pp$9.expect (file:///home/projects/github-5eousq/node_modules/.pnpm/rollup@3.26.0/node_modules/rollup/dist/es/shared/node-entry.js:18626:26)
    at pp$8.parseExportSpecifiers (file:///home/projects/github-5eousq/node_modules/.pnpm/rollup@3.26.0/node_modules/rollup/dist/es/shared/node-entry.js:19680:8)
    at Parser.parseExport (file:///home/projects/github-5eousq/node_modules/.pnpm/rollup@3.26.0/node_modules/rollup/dist/es/shared/node-entry.js:25883:32)
    at pp$8.parseStatement (file:///home/projects/github-5eousq/node_modules/.pnpm/rollup@3.26.0/node_modules/rollup/dist/es/shared/node-entry.js:18808:74)
    at pp$8.parseTopLevel (file:///home/projects/github-5eousq/node_modules/.pnpm/rollup@3.26.0/node_modules/rollup/dist/es/shared/node-entry.js:18689:21)
    at Parser.parse (file:///home/projects/github-5eousq/node_modules/.pnpm/rollup@3.26.0/node_modules/rollup/dist/es/shared/node-entry.js:18461:15)
    at _0x35edf6.parse (file:///home/projects/github-5eousq/node_modules/.pnpm/rollup@3.26.0/node_modules/rollup/dist/es/shared/node-entry.js:18511:35)
    at Graph.contextParse (file:///home/projects/github-5eousq/node_modules/.pnpm/rollup@3.26.0/node_modules/rollup/dist/es/shared/node-entry.js:25547:38) {
  pos: 5039,
  loc: {
    column: 7,
    file: '/home/projects/github-5eousq/node_modules/.pnpm/@types+aws-lambda@8.10.119/node_modules/@types/aws-lambda/index.d.ts',
    line: 96
  },
  raisedAt: 5041,
  frame: "94: export * from './trigger/amplify-resolver';\n" +
    '95: \n' +
    '96: export as namespace AWSLambda;\n' +
    '           ^',
  id: '/home/projects/github-5eousq/node_modules/.pnpm/@types+aws-lambda@8.10.119/node_modules/@types/aws-lambda/index.d.ts',
  hook: 'resolveId',
  code: 'PLUGIN_ERROR',
  plugin: 'commonjs--resolver',
  watchFiles: [
    '/home/projects/github-5eousq/src/index.ts',
    '/home/projects/github-5eousq/src/logger.ts',
    '/home/projects/github-5eousq/src/utils.ts',
    '/home/projects/github-5eousq/node_modules/.pnpm/@types+aws-lambda@8.10.119/node_modules/@types/aws-lambda/index.d.ts'
  ]
}
 ELIFECYCLE  Command failed with exit code 1.
@NamesMT NamesMT changed the title Syntax error: export as namespace Build failed: @types/aws-lambda Sep 5, 2023
@NamesMT
Copy link
Author

NamesMT commented Sep 5, 2023

Updated reproduce URL.
Newest fork from unjs/template and only @types/aws-lambda installed results in build failure.
https://stackblitz.com/edit/github-7jr8pu?file=package.json
image

@itpropro
Copy link
Member

itpropro commented Nov 30, 2023

I have the exact same error in a pnpm monorepo with the h3 reference:

 ERROR  Error building /home/wsl/repos/project/common/core: SyntaxError: Unexpected token (8:5) in /home/wsl/repos/project/node_modules/.pnpm/h3@1.9.0/node_modules/h3/dist/index.d.ts                                     4:18:42 PM


 ERROR  Unexpected token (8:5) in /home/wsl/repos/project/node_modules/.pnpm/h3@1.9.0/node_modules/h3/dist/index.d.ts 

  at pp$4.raise (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:21621:13)
  at pp$9.unexpected (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:18829:8)
  at pp$9.semicolon (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:18806:66)
  at pp$8.parseExpressionStatement (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:19295:8)
  at pp$8.parseStatement (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:19022:24)
  at pp$8.parseTopLevel (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:18886:21)
  at Parser.parse (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:18658:15)
  at Function.parse (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:18708:35)
  at Graph.contextParse (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:25754:38)
  at tryParse (/home/wsl/repos/project/node_modules/.pnpm/@rollup+plugin-commonjs@25.0.7_rollup@3.29.4/node_modules/@rollup/plugin-commonjs/dist/es/index.js:17:12)
  at analyzeTopLevelStatements (/home/wsl/repos/project/node_modules/.pnpm/@rollup+plugin-commonjs@25.0.7_rollup@3.29.4/node_modules/@rollup/plugin-commonjs/dist/es/index.js:37:15)
  at Object.transformAndCheckExports (/home/wsl/repos/project/node_modules/.pnpm/@rollup+plugin-commonjs@25.0.7_rollup@3.29.4/node_modules/@rollup/plugin-commonjs/dist/es/index.js:2085:68)
  at Object.transform (/home/wsl/repos/project/node_modules/.pnpm/@rollup+plugin-commonjs@25.0.7_rollup@3.29.4/node_modules/@rollup/plugin-commonjs/dist/es/index.js:2285:41)
  at /home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:25544:40

@GodlessLiu
Copy link

I have the exact same error in a pnpm monorepo with the h3 reference:

 ERROR  Error building /home/wsl/repos/project/common/core: SyntaxError: Unexpected token (8:5) in /home/wsl/repos/project/node_modules/.pnpm/h3@1.9.0/node_modules/h3/dist/index.d.ts                                     4:18:42 PM


 ERROR  Unexpected token (8:5) in /home/wsl/repos/project/node_modules/.pnpm/h3@1.9.0/node_modules/h3/dist/index.d.ts 

  at pp$4.raise (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:21621:13)
  at pp$9.unexpected (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:18829:8)
  at pp$9.semicolon (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:18806:66)
  at pp$8.parseExpressionStatement (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:19295:8)
  at pp$8.parseStatement (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:19022:24)
  at pp$8.parseTopLevel (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:18886:21)
  at Parser.parse (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:18658:15)
  at Function.parse (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:18708:35)
  at Graph.contextParse (/home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:25754:38)
  at tryParse (/home/wsl/repos/project/node_modules/.pnpm/@rollup+plugin-commonjs@25.0.7_rollup@3.29.4/node_modules/@rollup/plugin-commonjs/dist/es/index.js:17:12)
  at analyzeTopLevelStatements (/home/wsl/repos/project/node_modules/.pnpm/@rollup+plugin-commonjs@25.0.7_rollup@3.29.4/node_modules/@rollup/plugin-commonjs/dist/es/index.js:37:15)
  at Object.transformAndCheckExports (/home/wsl/repos/project/node_modules/.pnpm/@rollup+plugin-commonjs@25.0.7_rollup@3.29.4/node_modules/@rollup/plugin-commonjs/dist/es/index.js:2085:68)
  at Object.transform (/home/wsl/repos/project/node_modules/.pnpm/@rollup+plugin-commonjs@25.0.7_rollup@3.29.4/node_modules/@rollup/plugin-commonjs/dist/es/index.js:2285:41)
  at /home/wsl/repos/project/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:25544:40

Do you know how to fix it? I encountered the same error while using Prettier.

@13OnTheCode
Copy link

If the type package is installed under devDependencies, it seems to cause a build failure.

@javierfernandesba
Copy link

I'm having a similar issue with @types/express and a transitive dependency.

npm run build

> pae-microservices-runtime-sdk@1.0.0 build
> unbuild

ℹ Automatically detected entries: src/index [esm] [cjs] [dts]                                                                                                            12:32:24 PM
ℹ Building pae-microservices-runtime-sdk                                                                                                                                 12:32:24 PM
ℹ Cleaning dist directory: ./dist                                                                                                                                        12:32:24 PM

[12:32:25 PM]  ERROR  Error building /Users/jfernandes/dev/platform/pae/pae-microservices-runtime-sdk: SyntaxError: Unexpected token (19:8) in /Users/jfernandes/dev/platform/pae/pae-microservices-runtime-sdk/node_modules/@types/express/index.d.ts


 ERROR  Unexpected token (19:8) in /Users/jfernandes/dev/platform/pae/pae-microservices-runtime-sdk/node_modules/@types/express/index.d.ts                                12:32:25 PM

  at pp$4.raise (node_modules/rollup/dist/es/shared/node-entry.js:21621:13)
  at pp$9.unexpected (node_modules/rollup/dist/es/shared/node-entry.js:18829:8)
  at pp$9.semicolon (node_modules/rollup/dist/es/shared/node-entry.js:18806:66)
  at pp$8.parseExpressionStatement (node_modules/rollup/dist/es/shared/node-entry.js:19295:8)
  at pp$8.parseStatement (node_modules/rollup/dist/es/shared/node-entry.js:19022:24)
  at pp$8.parseTopLevel (node_modules/rollup/dist/es/shared/node-entry.js:18886:21)
  at Parser.parse (node_modules/rollup/dist/es/shared/node-entry.js:18658:15)
  at Function.parse (node_modules/rollup/dist/es/shared/node-entry.js:18708:35)
  at Graph.contextParse (node_modules/rollup/dist/es/shared/node-entry.js:25754:38)
  at tryParse (node_modules/@rollup/plugin-commonjs/dist/es/index.js:17:12)



 ERROR  Unexpected token (19:8) in /Users/jfernandes/dev/platform/pae/pae-microservices-runtime-sdk/node_modules/@types/express/index.d.ts

I've tried moving the dependency from "devDependencies" but got the same error.
It seems to be a pretty straighforward build configuration

{
  "name": "pae-microservices-runtime-sdk",
  "version": "1.0.0",
  "type": "module",
  "exports": {
    ".": {
      "import": "./dist/index.mjs",
      "require": "./dist/index.cjs"
    }
  },
  "main": "./dist/index.cjs",
  "types": "./dist/index.d.ts",
  "files": ["dist"],
  "scripts": {
    "build": "unbuild"
  },
  "dependencies": {
    "ts-loader": "9.5.1",
    "typescript": "5.4.4"
  },
  "devDependencies": {
    "@types/express": "^4.17.21",
    "@types/node": "^20.12.6",
    "unbuild": "2.0.0"
  }
}

I'd appreciate any ideas or suggestions.
Thanks !

@GaborTorma
Copy link

If the type package is installed under devDependencies, it seems to cause a build failure.

Saved my day. Thanks!

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

6 participants