Skip to content

Make Array.prototype.includes polyfill not enumerable #1133

Closed
@zwug

Description

@zwug
  • Operating System: macOS Sierra 10.12.6
  • Node Version: 4.8.4
  • NPM Version: 2.15.11
  • webpack Version: 2.7.0
  • webpack-dev-server Version: 2.9.1
  • This is a bug
  • This is a feature request
  • This is a modification request

My webpack build fails on stylus-loader, because stylus-loader uses for .. in loop to iterate through an array of files. And because includes property is enumerable, there is an iteration with it which causes failure. I have already created an issue in stylus-loader, but i think webpack-dev-server should change the polyfill property setting too. I can make a pull request with Object.defineProperty to fix this.

Code

...
{
  test: /\.styl$/,
  use: [
     { loader: 'style-loader', options: { sourceMap: true } },
     { loader: 'css-loader', options: { sourceMap: true } },
     { loader: 'postcss-loader', options: { sourceMap: true } },
     { loader: 'stylus-loader', options: { sourceMap: true } },
   ],
},
...
  // webpack.config.js

code in stylus-loader:

function normalizePaths(paths) {
  for(var i in paths) {
    paths[i] = path.normalize(paths[i]);
  }
  return paths;
}

webpack-dev-server polyfill setting:

if (!Array.prototype.includes) {
  Array.prototype.includes = require('array-includes');
}

Expected Behavior

Array.prototype.includes should not be enumerable

Actual Behavior

Array.prototype.includes is enumerable

For Bugs; How can we reproduce the behaviour?

node v4.8.4 + stylus-loader v3.0.1 should do it

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions