moxie/webpack-build

Webpack & the Lambda bundle

The Lambda artifact is a single JS bundle produced by Webpack (build/configs/webpack.js). There is no node_modules on the Lambda host — everything needed at runtime must be included in the bundle or available via AWS SDK (v3 clients are dependencies and get bundled).

TypeScript

  • ts-loader (and related plugins) transpile src/**/*.ts to CommonJS compatible with Node 22.x runtime.
  • Strict mode is off in tsconfig.json, but new code should still be typed clearly.

Path alias: @app

  • @app./src — use in imports: import x from '@app/frameworks/jsonapi'.

doT templates

  • .dot files compile to functions at build time via dot-loader — template endpoints do not read .dot from disk at runtime in Lambda.

Environments

  • yarn build, yarn build:dev, yarn build:stage select webpack mode and env injection appropriate to the target deploy (see scripts in package.json).
  • :debug variants produce unminified bundles for local profiling.

Output

  • Bundles land under build/dist/ (gitignored on master; follow your branch’s conventions).
  • CI uploads the built artifact to Lambda per Terraform pipeline.

Common issues

  • Forgot to import a dependency used only dynamically — Webpack may tree-shake it away; fix with explicit imports or webpack config exceptions (rare).
  • Binary / non-JS assets — ensure asset loaders or copy patterns if you add new file types.