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.

Async functions emit Rollup warning `this has been rewritten to undefined` -- can't repro

See original GitHub issue

When I try to build a file containing async functions, there’s the following warning:

this has been rewritten to undefined

Environment

  • node v10.16.0
  • rollup-plugin-node-resolve (^5.2.0)
  • rollup-plugin-typescript2 (^0.24.2)
  • rollup-plugin-babel (^4.3.3)
  • rollup-plugin-commonjs (^10.1.0)
  • rollup-plugin-terser (^5.1.2)

Versions

  • typescript: ^3.6.3
  • rollup: ^1.21.4
  • rollup-plugin-typescript2: ^0.24.2

rollup.config.js

import resolve from 'rollup-plugin-node-resolve'
import typescript from 'rollup-plugin-typescript2'
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import { terser } from 'rollup-plugin-terser'

import pkg from './package.json'

const extensions = ['.js', '.jsx', '.ts', '.tsx']

export default {
  input: ['src/index.ts'],
  output: {
    file: pkg.main,
    format: 'cjs'
  },
  external: ['@slack/client', 'dlv', 'dotenv', 'googleapis', 'micro'],
  plugins: [
    resolve({ extensions }),
    typescript({
      useTsconfigDeclarationDir: true
    }),
    babel(),
    commonjs(),
    terser()
  ]
}

tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "moduleResolution": "node",
    "target": "es2015",
    "module": "es2015",
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "declaration": true
  },
  "include": ["src/**/*.ts"],
  "types": ["node"]
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bastienrobertcommented, Sep 26, 2019

Alright, I think I’m just going crazy. The error has disappeared, I can not re-create it. Well… so i’m closing this 🤷🏻‍♂️ Sorry for making you waste time @ezolenko

1reaction
ezolenkocommented, Sep 26, 2019

I think this is a problem with your code, read the description at that rollup link: https://rollupjs.org/guide/en/#error-this-is-undefined

Read more comments on GitHub >

github_iconTop Results From Across the Web

[rollup/module/async]: `this` has been rewritten to `undefined`
The warning came from an await shim from typescript. I'm not sure why it's there but fiddling around the typescript configuration should help ......
Read more >
rollupjs - How to avoid "`this` has been rewritten to `undefined ...
When building the project with rollup I get the warning. this has been rewritten to undefined. With pointing at last line of code...
Read more >
Cleaning up Async Functions in React's useEffect Hook ...
Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application....
Read more >
2 Server Error Message Reference - MySQL :: Developer Zone
Message: The update log is deprecated and replaced by the binary log; SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN.
Read more >
Rollup-plugin-regenerator - npm.io
I have a warning by Rollup: The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has...
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