question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module build failed: TypeError: this.setDynamic is not a function

See original GitHub issue

I’m submitting a bug report

Webpack Version: 3.10.0

Babel Core Version: 7.0.0-beta.36

Babel Loader Version: 8.0.0-beta.0

Please tell us about your environment: Windows 10

{
{
  "presets": ["@babel/preset-es2015",[
    "@babel/preset-env", {
      "target": {
        "browsers": [
          "last 2 versions",
          "safari >= 7"
        ]
      }
    }
  ], "@babel/preset-react"],
  "plugins": [
    ["transform-runtime", {
      "polyfill": true,
      "regenerator": true
    }],
    "transform-decorators-legacy",
    "transform-class-properties",
    "@babel/plugin-proposal-object-rest-spread",
    ["module-resolver", {
      "root": ["./src"],
      "alias": {
        "styles": "./styles"
      }
    }]
  ],
  "env": {
    "test": {
      "plugins": [
        "transform-decorators-legacy",
        "transform-class-properties"
      ]
    }
  }
}
}

Current behavior:

Module build failed: TypeError: this.setDynamic is not a function
    at PluginPass.pre (C:\proj\src\login\node_modules\babel-plugin-transform-runtime\lib\index.js:31:12)
    at transformFile (C:\proj\src\login\node_modules\@babel\core\lib\transformation\index.js:97:25)
    at runSync (C:\proj\src\login\node_modules\@babel\core\lib\transformation\index.js:35:3)
    at transformSync (C:\proj\src\login\node_modules\@babel\core\lib\transform-sync.js:15:38)
    at Object.transform (C:\proj\src\login\node_modules\@babel\core\lib\transform.js:20:65)
    at transpile (C:\proj\src\login\node_modules\babel-loader\lib\index.js:55:20)
    at Object.module.exports (C:\proj\src\login\node_modules\babel-loader\lib\index.js:179:20)

Fix Removing this part of the .babelrc

"plugins": [
    ["transform-runtime", {
      "polyfill": true,
      "regenerator": true
    }],

stops this error from happening but instead yields

Login.jsx?f401:32 Uncaught ReferenceError: regeneratorRuntime is not defined

in the browser

This is the babel-loader config

        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components|public\/)/,
        loader: 'babel-loader',
        options: {
            presets: ['@babel/preset-es2015','@babel/preset-env', "@babel/preset-react"]
        }
    }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:35
  • Comments:23 (5 by maintainers)

github_iconTop GitHub Comments

250reactions
loganfsmythcommented, Feb 4, 2018

If you’re using Babel 7’s Beta, you’ll need to install and use the Babel 7 version of the plugins too, e.g.

{
  "presets": [
    ["@babel/preset-env", {
      "useBuiltIns": false,
    }],
  ],
  "plugins": [
    "@babel/plugin-transform-runtime"
  ]
}
79reactions
kaspergyselinckcommented, Oct 10, 2018

I had the same problem. Solved by uninstalling babel-plugin-transform-runtime, and installing @babel/plugin-transform-runtime instead.

I also needed to install @babel/runtime when using this plugin because of some error in helper libraries.

My .babelrc file now looks like this:

{
    "presets": 
    [
        [
            "@babel/preset-env",
            {
                "targets": {
                    "browsers": ["last 2 versions"]
                },
                "debug": true
            }
        ]
    ],
    "plugins": ["@babel/transform-runtime"]
}

What really helped a lot was this resource: babel-plugin-transform-runtime

I hope this information helps you as much as it helped me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack babel-loader runtime: Module build failed: TypeError
After a struggle I've found the right way to do it. Tl;dr. If you install the new babel loader, you should load the...
Read more >
TypeError: this.setDynamic is not a function - 潇湘羽西- 博客园
Module build failed (from ./node_modules/_babel-loader@8.0.6@babel-loader/lib/index.js): TypeError: this.setDynamic is not a function.
Read more >
[Solved]-How to fix: this.setDynamic is not a function-babel.js
Module build failed (from ./node_modules/babel-loader/lib/index.js): · Gettting error ""Uncaught TypeError: Object.assign is not a function" in react app on ...
Read more >
Module build failed: TypeError: this.setDynamic is not a function
Module build failed : TypeError: this.setDynamic is not a function ; I'm submitting a bug report ; Webpack Version: 3.10.0 ; Babel Core...
Read more >
I still get an error after running the “npm install @babel/plugin ...
Here's the error I'm getting: in ./.nuxt/client.js. Module build failed: TypeError: this.setDynamic is not a function
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found