serverless-bundle icon indicating copy to clipboard operation
serverless-bundle copied to clipboard

Don't use tsconfig-paths-webpack-plugin if no baseUrl defined

Open davidmfoley opened this issue 2 years ago • 0 comments

We have a typescript project with no baseUrl defined in compilerOptions, which causes errors like the following when bundling:

Packaging [redacted] for stage staging (us-east-1)
Failed to load /[redacted]/tsconfig.json: Missing baseUrl in compilerOptions
Bundling with Webpack...
tsconfig-paths-webpack-plugin: Found no baseUrl in tsconfig.json, not applying tsconfig-paths-webpack-plugin
tsconfig-paths-webpack-plugin: Found no baseUrl in tsconfig.json, not applying tsconfig-paths-webpack-plugin
tsconfig-paths-webpack-plugin: Found no baseUrl in tsconfig.json, not applying tsconfig-paths-webpack-plugin
...

This PR changes the webpack config to skip adding tsconfig-paths-webpack-plugin if no baseUrl is defined.

To test it, I added a flag to the runSlsCommand helper, that includes stderr output (as well as stdout) in the returned string. You might want to do something different there but this seemed like the smallest possible change.

davidmfoley avatar Aug 01 '22 20:08 davidmfoley