Remove support for AMD by default in Webpack 2

I’m submitting a feature request

Webpack version:
2.x

Current behavior:
Webpack produces code which throws an error when it encounters define identifier in source code.

Expected/desired behavior:
Webpack doesn’t treat define identifier in any custom way and make no assumptions about it unless it is configured with AMDModulePlugin (or something like that).

What is the motivation / use case for changing the behavior?
AMD isn’t used widely anymore, most of the code is distributed through npm and is in the format of CommonJS modules. Therefore it does make sense to make AMD support opt-in rather than having it enabled by default.

Author: Fantashit

8 thoughts on “Remove support for AMD by default in Webpack 2

  1. I think it’s too early to remove AMD. Easy migration from requirejs codebase to webpack is (in my opinion) one mayor reason for people switching.

    But I would love to hear more opinions on this topic…

  2. Easy migration from requirejs codebase to webpack is (in my opinion) one mayor reason for people switching.

    My intuition speaks against it but it would be interesting to see the numbers of AMD usage.

    Anyway, we can provide a separate section in docs on how to migrate to AMD (just add a plugin, right?)—AMD is a legacy and supporting it by default don’t make much sense, I think.

  3. You can opt-out.

    module: {
      rules: [
        { parser: { amd: false } }
      ]
    }

    Feel free to include a include property to limit the scope.

  4. You can opt-out.

    Nice! I’ll recommend the opt-out path for users running into issues.
    Would an opt-in by default change be something that’s doable for v3?

  5. This should work:

      rules: [
        {
          parser: {
            amd: false,
          }
        },
        {
          test: /\.js$/,
          exclude: /node_modules/,
          loaders: ['babel-loader']
        },
        {
          test: /\.css$/,
          loaders: [ 'style-loader', 'css-loader' ]
        },
        {
          test: /\.vue$/,
          loader: 'vue-loader'
        }
      ]
    
  6. I hope this doesn’t happen. I work in a code base that has a lot of modules that load through AMD. If AMD support is removed, I can no longer upgrade webpack.
    Moving to import has been a slow process because of the large amount of modules we have in the code base that still use AMD and making those updates hasn’t been a product priority. Tis the nature of working in an enterprise product.
    webpack has monopolized bundling because it does an awesome job supporting all formats.
    Please don’t remove support for AMD.
    Sad Kitten

  7. Webpack 2 is long in the past and version 5 is coming. Is this a good time to revisit the defaults for that version?

Comments are closed.