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.

Version X: prod build only - Uncaught TypeError: Object(...) is not a function

See original GitHub issue

Everything is working fine in dev but when I run a prod build I am seeing Uncaught TypeError: Object(...) is not a function. I think this is related to the move to preact createContext.

The error starts right after createContext in my build right around hereHt.createContext)(),fn=function(t){function e.

When I try to log out createContext it is undefined. I tried using import { Component, createContext } from 'preact'; and import { Component, createContext } from 'preact/compat';

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jaikathuriacommented, Oct 11, 2019

@JoviDeCroock I am also getting the same error for preact-router: 3.0.1 at /node_modules/preact-router/dist/preact-router.es.js:323:40

My dependency tree is

"devDependencies": {
    "eslint": "^5.14.1",
    "eslint-config-smallcase": "git+ssh://git@gitlab.com:smallcase/frontend/eslint-config-smallcase.git",
    "eslint-config-standard-preact": "^1.1.6",
    "eslint-plugin-import": "^2.16.0",
    "eslint-plugin-node": "^8.0.1",
    "eslint-plugin-promise": "^4.0.1",
    "eslint-plugin-react": "^7.12.4",
    "eslint-plugin-standard": "^4.0.0",
    "fast-async": "^6.3.8",
    "husky": "^1.3.1",
    "identity-obj-proxy": "^3.0.0",
    "jest": "^21.2.1",
    "lint-staged": "^8.1.4",
    "per-env": "^1.0.2",
    "preact-cli": "^2.2.1",
    "preact-render-spy": "^1.3.0",
    "superstatic": "^6.0.4"
  },
  "dependencies": {
    "axios": "^0.19.0",
    "preact": "^10.0.0",
    "preact-render-to-string": "^5.0.6",
    "preact-router": "^3.0.1"
  },

When I run:

pm i --save preact-cli@rc

My build starts giving an error in preact.config.js which is as follow:

import webpack from 'webpack';

// const publicPath = '/frame/';

export default (config, env, helpers) => {
  // config.output.publicPath = publicPath;

  // Make async work
  const babel = config.module.loaders.filter(loader => loader.loader === 'babel-loader')[0].options;
  // Blacklist regenerator within env preset:
  babel.presets[0][1].exclude.push('transform-async-to-generator');
  // Add fast-async
  babel.plugins.push([require.resolve('fast-async'), { spec: true }]);
};

With the following error TypeError: Cannot read property 'filter' of undefined

Any idea what I am doing wrong ?

0reactions
ostecommented, Jul 30, 2019

that fixed it, Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Object(...) is not a function error only in build version
I get this error only in my build version of project, in production it does not cause any errors TypeError: Object(...) is not...
Read more >
How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript TypeError: "x" is not a function occurs when calling a function on a value or object, which is not actually a...
Read more >
TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >
JavaScript: Uncaught TypeError: n is not a function
This is a standard JavaScript error when trying to call a function before it is defined. This error occurs if you try to...
Read more >
The 10 Most Common JavaScript Issues Developers Face
Uncaught TypeError : undefined is not a function ... With this version, BaseObject inherits the name property from its prototype object, where it...
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