sindresorhus / slugify

Slugify a string
MIT License
2.56k stars 81 forks source link

The library doesn't support IE 11 #32

Closed Max-Kuzomko closed 5 years ago

Max-Kuzomko commented 5 years ago

We got the following errors in IE11:

  1. Target is not iterable + TypeError
  2. Object does not support property or method "Symbol(Symbol.iterator
  3. Object does not support property or method "normalize""
ApacheEx commented 5 years ago

Candidates to replace:

1.for (const [key, value] of replacements) - can be rewritten to Object.keys

  1. new Map([ - can be used simple Object.
  2. string.normalize - looks like need to use https://github.com/walling/unorm/
sindresorhus commented 5 years ago

This module mainly targets Node.js, not the browser. It's up to you to transpile it with Babel if you want to use it in the browser. You can find a more detailed explanation here: https://github.com/sindresorhus/ama/issues/446

If you use Webpack, check out babel-engine-plugin, which transpiles only the dependencies that needs to be transpiled.

If you use Create React App, upgrade to Create React App v2. It supports automatic transpilation of dependencies, which will make this package just work.

ApacheEx commented 5 years ago

Thanks for replying. We already use "react-scripts": "3.0.1" with the following browserlist:

  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },

and somehow it still doesn't work properly. Also we have

import 'react-app-polyfill/ie11';

as first line of src/index.js