ModuleConcatenation bailout: Module is not an ECMAScript module when inheriting exported based config

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
When inheriting from a base webpack config provided by an npm module and merging via webpack-merge, ModuleConcatenation fails to properly concatenate, giving the bailout warning ‘Module is not an ECMAScript module’ (despite the fact all files are indeed ECMAScript modules).

If the current behavior is a bug, please provide the steps to reproduce.
Created a simple repro repo here: https://github.com/jdb8/webpack-module-concat-repro. Instructions are detailed in README.md.

What is the expected behavior?
The output bundle should successfully concatenate the module with ModuleConcatenationPlugin. It shouldn’t matter whether the plugin is defined in the base or child config, or whether the base config is exported from an npm module.

If this is a feature request, what is motivation or use case for changing the behavior?
N/A

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
webpack@3.4.1, node@5.11.0

Author: Fantashit

1 thought on “ModuleConcatenation bailout: Module is not an ECMAScript module when inheriting exported based config

  1. Hmmm, seems like most of it was due to the entry point directly importing a single CommonJS module, which caused the not an ECMAScript module error to subsequently occur for almost every other imported module in the whole project.

    The error wasn’t so helpful, it seems to have told me a bunch of actually-es2015 modules were not es2015 modules.

    Then when I commented out the single import line — in my entry point which imported the CommonJS module — a bunch of stuff was able to concatenate and many of those not an ECMAScript module went away.

    Seems like error reporting could use some love in this area (I know, error message helpfulness is usually the last thing people have time for 😊). Hopefully this is of any help to anyone who stumbles here.

Comments are closed.