Skip to content
angular challenges logo Angular Challenges

๐ŸŸข Static vs Dynamic Import

Challenge #42

Created by Thomas Laforge

Information

If you are using Nx, you might have encountered this error:

Static imports of lazy-loaded libraries are forbidden.
Library "users" is lazy-loaded in these files:
- apps/nx/static-dynamic-import/src/app/app.config.ts eslint@nx/enforce-module-boundaries

This error is part of the ESLint rule embedded by Nx to prevent people from mixing lazy-loading and eagerly-loading code from the same library. Although this error will not break at runtime or build time, it can lead to consequences for bundle size. The lazy-loaded code will end up in the main bundle, nullifying all the benefits of lazy-loading a library.

Statement

The goal of this challenge is to improve the code architecture to eliminate this ESLint error.

You will learn how to create a library and how to rearrange code.

Contributors

Thanks to all the contributors who have helped make this documentation better!

  • tomalaforge