Skip to content

AMD module built with webpack serve returns undefined (Webpack 5 only) #12085

@yvele

Description

@yvele

Bug report

What is the current behavior?

When using webpack serve the defaut AMD module returns undefined.

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

Webpack config is very simple:

const path = require("path");

module.exports = {
  entry : path.join(__dirname, "src/index.js"),
  output : {
    path : path.join(__dirname, "dist"),
    filename : "main.js",
    libraryTarget : "amd",
    libraryExport : "default"
  }
};

And main.js also:

export default {
  foo : "bar"
};

Clone https://github.com/yvele/webpack-5-amd-devserver

Then

npm install
npm run build
npm run start

The AMD module built with webpack works as expected.
The AMD module built with webpack serve return undefined.

image

I also tried to set inline to false and deactivate hot.. But still lots of code if injected and the AMD module returns undefined with webpack serve.

Note that I don't have the bug with Webpack 4.

What is the expected behavior?

webpack serve should build a valid AMD module.

Other relevant information:
webpack version: 5.8.0
webpack-cli version: 4.2.0
webpack-dev-server: 3.11.0
Node.js version: 12.19.0
Operating System: macOS 10.15.7
Additional tools:

  System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 1.84 GB / 16.00 GB
  Binaries:
    Node: 12.19.0 - ~/.nvm/versions/node/v12.19.0/bin/node
    npm: 6.14.8 - ~/.nvm/versions/node/v12.19.0/bin/npm
  Browsers:
    Chrome: 87.0.4280.67
    Firefox: 81.0.2
    Safari: 14.0

Metadata

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