webpack: If both `providedExports` and `concatenateModules` are enabled, ES6 default import becomes `undefined`

Bug report

What is the current behavior?

If both providedExports and concatenateModules are enabled, ES6 default import becomes undefined.

// @SBrython/utils/generate.ts
console.warn("first");

export default function generate(code: string, results: Results) {
   // ...
}

console.warn("second", generate);

// import.ts
import generate from "@SBrython/utils/generate";

console.warn("here", generate);

Result:

first
second  function 7861(t, n)
here undefined

If the current behavior is a bug, please provide the steps to reproduce.

This is a big project I recently tried to build in production mode. Here the last version: https://github.com/denis-migdal/SimplerBrython/tree/cab862810b787fc088a3705389bb74bfa07e817c

What is the expected behavior?

The imported function should be properly imported, and not be undefined.

Other relevant information: webpack version: 5.98.0 Node.js version: v22.5.1 Operating System: Linux Additional tools: “circular-dependency-plugin” : no circular dependencies found.

Maybe related to ?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (6 by maintainers)

Most upvoted comments

  1. git clone --recurse-submodules https://github.com/denis-migdal/SimplerBrython.git
  2. cd SimplerBrython
  3. npm install
  4. Edit /build/WebpackFramework/src/skeleton.js
    • line 26 to add/remove “modern-module”.
    • line 50 to add/remove concatenateModule option.
  5. npm run build-prod
  6. Launch a webserver on /dist/prod, e.g. python3 -m http.server -d dist/prod/
  7. Open e.g. http://127.0.0.1:8000/Benchmark/
  8. In the browser console (I use FF) you should see the “TypeError: o.Ay is undefined” error.

Hum, I wonder if the bug might be due to the fact that I use swc-loader and fork-ts-checker-webpack-plugin.

Tested with ts-loader same issue.