Skip to content

Production builds can result in a different import vs. execution order #11617

@thecrypticace

Description

@thecrypticace

Bug report

It's possible for the presence of imports in imported files to affect execution order in a production build. The mere addition or removal of imports can cause modules to be executed in an order different than they're specified in the source.

What is the current behavior?
A production build can execute modules in a different order than they are imported.

If the current behavior is a bug, please provide the steps to reproduce.
Reproduction Repo: https://github.com/thecrypticace/webpack-import-order-bug

What is the expected behavior?
Adding or removing imported dependencies from node_modules should not change execution order regardless of development mode versus production mode.
I would expect all the code in b.js to run and then the code in c.js when I write:

// a.js
import "./b"
import "./c"

Other relevant information:
webpack version: 5.0.0 RC 4
Node.js version: 14.13.1
Operating System: macOS Catalina 10.15.7
Additional tools: Yarn 1.22.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions