Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failing tests on PhantomJS 2.1.1 - ReferenceError: Can't find variable: isCallableMarker #57

Closed
fzxt opened this issue Oct 2, 2020 · 6 comments

Comments

@fzxt
Copy link

fzxt commented Oct 2, 2020

I'm getting a weird reference error that points back to this module.

PhantomJS 2.1.1 (Linux 0.0.0) ERROR
  ReferenceError: Can't find variable: isCallableMarker
  at undefined:18

Weirdly, changing the webpack.config devtool seems to get past this (assigned the devtool to eval or even sourcemap will work)

Here is the generated bundle code, if it helps

/***/ "../../../../../../../nail/home/fahmad/pg/cool/node_modules/is-callable/index.js":
/*!************************************************************************!*\
  !*** /nail/home/fahmad/pg/cool/node_modules/is-callable/index.js ***!
  \************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nvar fnToStr = Function.prototype.toString;\nvar reflectApply = typeof Reflect === 'object' && Reflect !== null && Reflect.apply;\nvar badArrayLike;\nvar isCallableMarker;\nif (typeof reflectApply === 'function' && typeof Object.defineProperty === 'function') {\n\ttry {\n\t\tbadArrayLike = Object.defineProperty({}, 'length', {\n\t\t\tget: function () {\n\t\t\t\tthrow isCallableMarker;\n\t\t\t}\n\t\t});\n\t\tisCallableMarker = {};\n\t\t// eslint-disable-next-line no-throw-literal\n\t\treflectApply(function () { throw 42; }, null, badArrayLike);\n\t} catch (_) {\n\t\tif (_ !== isCallableMarker) {\n\t\t\treflectApply = null;\n\t\t}\n\t}\n} else {\n\treflectApply = null;\n}\n\nvar constructorRegex = /^\\s*class\\b/;\nvar isES6ClassFn = function isES6ClassFunction(value) {\n\ttry {\n\t\tvar fnStr = fnToStr.call(value);\n\t\treturn constructorRegex.test(fnStr);\n\t} catch (e) {\n\t\treturn false; // not a function\n\t}\n};\n\nvar tryFunctionObject = function tryFunctionToStr(value) {\n\ttry {\n\t\tif (isES6ClassFn(value)) { return false; }\n\t\tfnToStr.call(value);\n\t\treturn true;\n\t} catch (e) {\n\t\treturn false;\n\t}\n};\nvar toStr = Object.prototype.toString;\nvar fnClass = '[object Function]';\nvar genClass = '[object GeneratorFunction]';\nvar hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';\n\nmodule.exports = reflectApply\n\t? function isCallable(value) {\n\t\tif (!value) { return false; }\n\t\tif (typeof value !== 'function' && typeof value !== 'object') { return false; }\n\t\tif (typeof value === 'function' && !value.prototype) { return true; }\n\t\ttry {\n\t\t\treflectApply(value, null, badArrayLike);\n\t\t} catch (e) {\n\t\t\tif (e !== isCallableMarker) { return false; }\n\t\t}\n\t\treturn !isES6ClassFn(value);\n\t}\n\t: function isCallable(value) {\n\t\tif (!value) { return false; }\n\t\tif (typeof value !== 'function' && typeof value !== 'object') { return false; }\n\t\tif (typeof value === 'function' && !value.prototype) { return true; }\n\t\tif (hasToStringTag) { return tryFunctionObject(value); }\n\t\tif (isES6ClassFn(value)) { return false; }\n\t\tvar strClass = toStr.call(value);\n\t\treturn strClass === fnClass || strClass === genClass;\n\t};\n\n\n//# sourceURL=webpack:////nail/home/fahmad/pg/cool/node_modules/is-callable/index.js?");
/***/ }),
@ljharb
Copy link
Member

ljharb commented Oct 2, 2020

What version of is-callable do you have? v1.2.2, the latest, is required to fix phantomJS (broke in v1.2.0 and v1.2.1, see #56.

@fzxt
Copy link
Author

fzxt commented Oct 2, 2020

on 1.2.2

=> Found "[email protected]"
info Reasons this module exists
   - "enzyme" depends on it
   - Hoisted from "enzyme#is-callable"
   - Hoisted from "es-abstract#is-callable"
   - Hoisted from "es-abstract#es-to-primitive#is-callable"
   - Hoisted from "enzyme#object.assign#es-abstract#is-callable"
info Disk size without dependencies: "72KB"
info Disk size with unique dependencies: "72KB"
info Disk size with transitive dependencies: "72KB"
info Number of shared dependencies: 0
Done in 1.22s.

@ljharb
Copy link
Member

ljharb commented Oct 2, 2020

I'm super confused how this error could happen; var isCallableMarker; is in the minified code.

@ljharb
Copy link
Member

ljharb commented Oct 2, 2020

What webpack config doesn't work?

@fzxt
Copy link
Author

fzxt commented Oct 2, 2020

it looks something like this:

{
  entry: {
    karma: '/nail/home/fahmad/pg/cool-main/cool/testing/js/webpack/entry.js'
  },
  target: 'web',
  output: {
    path: '/nail/home/fahmad/pg/cool-main/public',
    sourceMapFilename: '[file].map',
    filename: 'module_cool_main_[name].js',
    chunkFilename: '[name].chunk.js',
    publicPath: 'https://www.cool-main-uwsgi.dev.cool.com/cool_main/__public__/'
  },
  optimization: { splitChunks: { cacheGroups: [Object] } },
  mode: 'development',
  module: {
    strictExportPresence: true,
    rules: [ [Object], [Object], [Object], [Object], [Object], [Object] ]
  },
  plugins: [
    MiniCssExtractPlugin { options: [Object] },
    WebpackAssetsManifest {
      hooks: [Object],
      options: [Object],
      assets: [Object: null prototype] {},
      assetNames: Map {},
      currentAsset: null,
      compiler: null,
      stats: null,
      hmrRegex: null,
      apply: [Function: apply],
      [Symbol(isMerging)]: false
    },
    DefinePlugin { definitions: [Object] },
    DefinePlugin { definitions: [Object] },
    ContextReplacementPlugin {
      resourceRegExp: /moment[/\\]locale$/,
      newContentResource: undefined,
      newContentRecursive: undefined,
      newContentRegExp: /cs|da|de|en|es|fi|fr|it|ms|nb|nl|pl|sv|tr|zh|fil|ja/
    },
    LoadablePlugin {
      handleEmit: [Function],
      writeAssetsFile: [Function],
      opts: [Object],
      compiler: null
    },
    EmitEmptyCssBundlePlugin {},
    WebpackInjectPlugin { loader: [Function], options: [Object] },
    ProvidePlugin { definitions: [Object] }
  ],
  resolve: {
    alias: {
      '<PROJECT_ROOT>': '/nail/home/fahmad/pg/cool-main',
      react: '/nail/home/fahmad/pg/cool-main/node_modules/react',
      'react-dom': '/nail/home/fahmad/pg/cool-main/node_modules/react-dom',
      'react-apollo': '/nail/home/fahmad/pg/cool-main/node_modules/react-apollo',
      'cool-react-component-theme-context': '/nail/home/fahmad/pg/cool-main/node_modules/cool-react-component-theme-context',
      'cool-react-graphql-client': '/nail/home/fahmad/pg/cool-main/node_modules/cool-react-graphql-client',
      '@apollo/react-common': '/nail/home/fahmad/pg/cool-main/node_modules/@apollo/react-common',
      '@apollo/react-hooks': '/nail/home/fahmad/pg/cool-main/node_modules/@apollo/react-hooks',
      '@apollo/react-components': '/nail/home/fahmad/pg/cool-main/node_modules/@apollo/react-components',
      '@apollo/react-hoc': '/nail/home/fahmad/pg/cool-main/node_modules/@apollo/react-hoc',
      '@apollo/react-ssr': '/nail/home/fahmad/pg/cool-main/node_modules/@apollo/react-ssr',
      '@loadable/component': '/nail/home/fahmad/pg/cool-main/node_modules/@loadable/component'
    },
    symlinks: true,
    plugins: [ [DedupePackageResolutionsPlugin] ]
  },
  stats: { children: false },
  performance: { assetFilter: [Function: performanceAssetFilter] },
  bail: true,
  devtool: 'eval',
  externals: { jquery: 'jQuery' }
}

I actually just removed the devtool, tried running it again, and it seems to work. I can't make sense of it and I'm going to chalk it up to a flake on my end (or environment has a lot of custom things, its possible I got lost in the configuration and am unable to provide enough context to debug this properly). Feel free to close this issue.

@ljharb
Copy link
Member

ljharb commented Oct 2, 2020

Since we have #56 to cover adding phantomjs to CI, I'll close this, but I am still confused why that would break.

@ljharb ljharb closed this as completed Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants