Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Webpack lazy module evaluation reproduction

The application initializes its runtime configuration before loading a reports feature. The feature uses ESM settings and a CommonJS diagnostics utility.

See src/index.js for the expected execution order.

Run

npm ci
npm run build
npm start

The default configuration enables module concatenation (concatenateModules: true). Compilation succeeds, but running the bundle throws before the first initialization log:

Error: Feature configuration evaluated before app initialization

Expected behavior

Configuration should be initialized before the reports feature is loaded:

1. Configuration initialized
2. Loading the reports feature
3. Reports ready: https://api.example.test (API: https://api.example.test)

Compare without concatenation

In webpack.config.cjs, set concatenateModules: false, then rebuild and run. The bundle prints all three lines in the expected order.

Setting concatenateModules: { commonjs: false } also preserves the expected order.

Dependency graph

index.js
  -> require app.js, initialize configuration, then call app.start()
     -> require reports.js inside start()
        -> import settings.js
           -> import runtime-config.js, read the initialized configuration
        -> import legacy-diagnostics.cjs
           -> require settings.js inside describeSettings()

This uses synchronous require calls to defer module evaluation, not asynchronous code splitting. No framework, loaders, plugins, Babel, eval, or sideEffects metadata is involved.

The unminified output is dist/bundle.cjs.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages