Skip to content

--sourcemap-output + async import() = Multiple assets emit different content to the same filename #701

Closed

Description

Environment

Haul 0.17.0

Description

Conflict: Multiple assets emit different content to the same filename ../../../../sourcemaps/react/OpenLearningClient/release/index.android.bundle.map

In webpack 4, this is a warning, but in webpack 5 it will be an error.

Reproducible Demo

yarn run haul bundle --platform android --sourcemap-output index.android.bundle

// index.android.js
import('./helper.js'); // Creates another chunk!

Happens because the import() statement creates another chunk by default, but the chunk has the same name index.android.bundle. So if the sourcemap name contains [file] as it does by default, everything is fine, but if --sourcemap-output is used to set it to something else, this error happens.

Workaround/fix

Using the following webpack plugin prevents multiple chunks from existing in the first place. Perhaps this should be added to the default configuration? Not sure how it interacts with RAM bundles or other code splitting methods for react-native though.

new webpack.optimize.LimitChunkCountPlugin({
  maxChunks: 1,
}),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions