Skip to content

Commit

Permalink
Add context option to webpack config
Browse files Browse the repository at this point in the history
For achieving deterministic builds
  • Loading branch information
samcic authored Dec 27, 2021
1 parent 6fc0e75 commit 3acee5c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/ember-auto-import/ts/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ export default class WebpackBundler extends Plugin implements Bundler {
let config: Configuration = {
mode: this.opts.environment === 'production' ? 'production' : 'development',
entry,
// Pursuant to the webpack docs (https://webpack.js.org/configuration/entry-context/#context),
// we follow the recommendation to set the context, i.e. the absolute path for resolving
// entry points and loaders from the configuration. By doing this, the config becomes
// independent of the current working directory, and importantly ensures that we get DETERMINISTIC
// builds (i.e. produced assets have invariant content across repeated identical builds).
// If we didn't do this, the module names that webpack considers for computing the deterministic
// "moduleIds" (using the default moduleIds: "deterministic" option) would end up being
// based on broccoli temp-directory paths, which aren't deterministic across builds, and would
// hence cause output assets to also be non-deterministic.
context: stagingDir,
performance: {
hints: false,
},
Expand Down

0 comments on commit 3acee5c

Please sign in to comment.