1

I hope all is well with you. This is officially my first post in stackoverflow so I'd like to apologise in advance if I've not made anything clear.

I have recently created a vanillajs weather application and have had trouble deploying it to gh-pages on Github. I have built applications before and deployed them onto gh-pages with not much of a problem however, this weather application (first app using promises) has caused me a headache. The error I get once I deploy it to gh-pages is:

Uncaught ReferenceError: regeneratorRuntime is not defined

I've used webpack / npm to set up my folder structure:

//dist
----index.html
----main.js
----styles.css 
//node_modules 
//src
----index.js
----search.js
----switchTable.js 
package-lock.json 
package.json 
webpack.config.js

The following files which may be useful: package.json

{
  "name": "weather_application",
  "version": "1.0.0",
  "description": "",
  "private": true,
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "watch": "webpack --watch",
    "start": "webpack serve --open",
    "build": "webpack"
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": ""
  },
  "homepage": "",
  "devDependencies": {
    "@babel/core": "^7.16.12",
    "@babel/plugin-transform-runtime": "^7.16.10",
    "@babel/preset-env": "^7.16.11",
    "babel-loader": "^8.2.3",
    "webpack": "^5.67.0",
    "webpack-cli": "^4.9.2",
    "webpack-dev-server": "^4.7.3"
  },
  "dependencies": {
    "@babel/polyfill": "^7.12.1",
    "regenerator-runtime": "^0.13.9"
  }
}

and webpack.config.js:

const path = require('path');

module.exports = {
  mode: 'development',
  entry: ["@babel/polyfill", './src/index.js'],
  devtool: 'inline-source-map',
  devServer: {
    static: './dist',
  },
  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, 'dist'),
  },
  module: {
    rules: [{
      test: /\.m?js$/,
      exclude: /node_modules/,
      use: {
        loader: 'babel-loader',
        options: {
          presets: [
            ['@babel/preset-env', {
              targets: "defaults"
            }]
          ],
          plugins: ['@babel/plugin-transform-runtime']
        }
      }
    }]
  }
};

Please let me know if I can provide any more information that I may have missed out. Thank you.

Afsari
  • 11
  • 2
  • Hi and welcome to StackOverflow! A quick search lead me to the following answer for a Polyfill missing. Please check if that helps you out: https://stackoverflow.com/a/33527883/2915086 – Hecke29 Jan 31 '22 at 10:13
  • Thank you, I shortly afterwards saw that link and applied it and it thankfully worked! – Afsari Feb 03 '22 at 23:49

0 Answers0