serverless-typescript-starter icon indicating copy to clipboard operation
serverless-typescript-starter copied to clipboard

Webpack Error: "Cannot read property 'tap' of undefined"

Open johndanek opened this issue 4 years ago • 1 comments

Hello! I'm trying to use serverless-bundle for typescript in my project. I cloned the typescript starter project. This project is part of a workspace, and it extends a base tsconfig.

I can run tsc just fine, but when I try to invoke a serverless function or start the server, I get a cryptic error that I've been trying to fix for hours now:

sls invoke local --function hello

serverless-bundle: CommonJS, ES3, or ES5 are not supported
Serverless: Bundling with Webpack...

ERROR in /Users/{user}/work/next/packages/cloud/lincoln/new-new-api/src/handler.ts
Module build failed (from /Users/{user}/work/next/node_modules/ts-loader/index.js):
TypeError: Cannot read property 'tap' of undefined
    at makeAssetsCallback (/Users/{user}/work/next/node_modules/ts-loader/dist/instances.js:218:50)
    at addAssetHooks (/Users/{user}/work/next/node_modules/ts-loader/dist/instances.js:224:9)
    at Object.initializeInstance (/Users/{user}/work/next/node_modules/ts-loader/dist/instances.js:266:13)
    at successLoader (/Users/{user}/work/next/node_modules/ts-loader/dist/index.js:26:17)
    at Object.loader (/Users/{user}/work/next/node_modules/ts-loader/dist/index.js:23:5)

 Error ---------------------------------------------------

  Error: Webpack compilation error, see stats above
      at /Users/{user}/work/next/node_modules/serverless-bundle/node_modules/serverless-webpack/lib/compile.js:32:15

I can find no leads in debugging as to what I need to fix. Any suggestions? I dug into node_modules and the undefined object attempting to access a .tap function is compilation.hooks.afterProcessAssets.

johndanek avatar Mar 19 '21 00:03 johndanek

Still haven't solved this, but upon further investigation I realized that the error appears only when I reference another workspace proejct in .tsconfig, and when I include it as a dependency in package.json. Hmm.

johndanek avatar Mar 19 '21 19:03 johndanek