Giter Site home page Giter Site logo

Comments (5)

hueniverse avatar hueniverse commented on July 26, 2024

You have to use webpack or something like it to adjust the code to the platforms you need to support. There is no one right answer here.

from nes.

ceisele-r avatar ceisele-r commented on July 26, 2024

@hueniverse we are experiencing the same error after updating from nes 7.0.3 to @hapi/nes 11.2.2 together with updating hapi from 18.1.0 to @hapi/hapi 18.4.0 and inert from 5.1.0 to @hapi/inert 5.2.2.
We have been using webpack before and after the update. Before, everything works in IE11 but after the update, the Arrow functions unfortunately are not transpiled.

Do you have any idea why this could be happening now after the update?
One thing we did was to apply the suggested fix mentioned in #294 (comment) because we ran in that issue. Could it be somehow related to this?

from nes.

iancamp avatar iancamp commented on July 26, 2024

I was able to get around this by adding babel-loader. See below.

Packages installed

    "@babel/core": "7.7.2",
    "@babel/polyfill": "7.7.0",
    "@babel/preset-env": "7.7.1",
    "babel-loader": "8.0.6"

babel.config.js

'use strict';

module.exports = function (api) {
    api.cache(true);

    const presets = [ '@babel/preset-env'];
    const plugins = [];

    return {
        presets,
        plugins
    };
}; 

Added this to my webpack.config.js

    module: {
        rules: [
            {
                test: /\.js$/,
                include: [ path.resolve('./node_modules/@hapi/nes') ],
                use: {
                    loader: 'babel-loader',
                    options: {
                        configFile: path.resolve('./babel.config.js')
                    }
                }
            }
        ]
    },

from nes.

ceisele-r avatar ceisele-r commented on July 26, 2024

@iancamp thank you. We have a similar setup, except that we do not use @babel/polyfill since it is deprecated.

I think I now proceeded some steps by adding @babel/plugin-transform-arrow-functions and including it as plugin to babel-loader:

use: {
          loader: "babel-loader",
          options: {
            presets: [
              [
                "@babel/preset-env",
                {
                  "useBuiltIns": "usage",
                  "corejs": 3,
                  "debug": true,
                  "targets": {
                    "chrome": "58",
                    "ie": "11"
                  }
                }
              ],
              ["@babel/preset-react"]
            ],
            plugins: [
              ...
              "@babel/plugin-transform-runtime",
              "@babel/plugin-transform-arrow-functions"
            ],
          }
        }

I am wondering whether adding @babel/plugin-transform-arrow-functions should be necessary or has any downsides.
At least it seems to somehow be working like this in IE11 again at the first look. I still have to see if it really works since I did quite some changes around this when trying to solve the issue and therefore a lot of stuff is mixed together now.

from nes.

iancamp avatar iancamp commented on July 26, 2024

Oh, didn't realize @babel/polyfill is deprecated. Thanks for the heads up! I don't think it's necessary for the workaround, anyway.

from nes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.