insin / nwb

A toolkit for React, Preact, Inferno & vanilla JS apps, React libraries and other npm modules for the web, with no configuration (until you need it)
Other
5.57k stars 331 forks source link

Missing polyfill-ed prototypes when running in IE11. #324

Closed jstralko closed 7 years ago

jstralko commented 7 years ago

This issue is a:

I'm having trouble poly filling Array.from using nwb toolkit. I'm unsure who to configure nwb.config.js to tell Babel to polyfill it. Do I need to add a preset or plugin? It looks like fetch, Promise, and Object.assign work just fine, but Array.from and a few others are undefined when running my react application in IE11.

my nwb.config.js is very minimal:

    module.exports` = {
type: 'react-app',
webpack: {
    define: {
        VERSION: JSON.stringify(require('./package.json').version),
        HOSTNAME: JSON.stringify(process.env.NODE_ENV === 'production' ?
                  'https://xyz.azurewebsites.net' :
                  'http://10.0.2.2:8080')
    },
    rules: {
        babel: {
            test: /\.jsx?/
        }
    },
    extra: {
        resolve: {
            extensions: ['.jsx']
        },
        devtool: '#inline-source-map'
    },
    html: {
        favicon: 'src/img/favicon.ico'
    }
}

};

insin commented 7 years ago

You can add add additional polyfills as dependencies and import them before you kick your app off.

E.g. if you add core-js as a dependency, adding import 'core-js/fn/array/from' to the top of src/index.js should do the trick. Individual module polyfills are available too.

jstralko commented 7 years ago

Thanks for the help. This is exactly what I was looking for. Thank you for all your work on nwb.