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

Fastboot does not run with Babel browser polyfill #55

Closed
topaxi opened this issue Aug 13, 2015 · 9 comments
Closed

Fastboot does not run with Babel browser polyfill #55

topaxi opened this issue Aug 13, 2015 · 9 comments

Comments

@topaxi
Copy link

topaxi commented Aug 13, 2015

Trying to run fastboot (master) with the babel-browser-polyfill crashes with:

TypeError: Cannot read property 'prototype' of undefined
    at Object.58../$ (<anonymous>:2132:25)
    at s (<anonymous>:13:255)
    at <anonymous>:13:306
    at Object.93../modules/$ (<anonymous>:3269:1)
    at s (<anonymous>:13:255)
    at <anonymous>:13:306
    at Object.<anonymous> (<anonymous>:21:1)
    at Object.1../tools/protect.js (<anonymous>:33:4)
    at s (<anonymous>:13:255)
    at e (<anonymous>:13:426)

My ember-cli-build.js looks roughly like this:

var EmberApp = require('ember-cli/lib/broccoli/ember-app')

module.exports = function(defaults) {
  var app = new EmberApp(defaults, {
    babel: {
      optional: [ 'es7.asyncFunctions' ]
    }
  })

  app.import('vendor/babel-polyfill.js', { prepend: true })

  return app.toTree()
}

I'm not experienced enough with fastboot and contextify to debug this.

@tomdale
Copy link
Contributor

tomdale commented Aug 13, 2015

Probably related to #57. I'm assuming based on the name that babel-browser-polyfill relies on browser features that aren't available in Node.

@tomdale
Copy link
Contributor

tomdale commented Aug 13, 2015

@topaxi Surely there's a version of the Babel polyfill designed to work in Node? Do you know which line you're getting the exception from?

@tomdale
Copy link
Contributor

tomdale commented Aug 13, 2015

Any idea @thejameskyle?

@jamiebuilds
Copy link

@tomdale The only difference between the "node" polyfill and the "browser" one is that the browser one has been compiled with browserify. So it should be working fine.

@topaxi Can you share the code that is causing this error?

@topaxi
Copy link
Author

topaxi commented Aug 14, 2015

I setup a minimal clean repository here: https://github.com/topaxi/fastboot-test
(Edit: I accidentally amended instead of creating a new commit on top of the ember created commit...)

All I did was:

ember new fastboot-test
ember install tildeio/ember-cli-fastboot#master
cp node_modules/ember-cli-babel/node_modules/broccoli-babel-transpiler/node_modules/babel-core/browser-polyfill.js vendor/babel-browser-polyfill.js

And updated the ember-cli-build.js and then ran:

ember fastboot

Which leads to:

version: 1.13.8
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/user-guide/#watchman for more info.
Built project successfully. Stored in "fastboot-dist".
DEPRECATION: `ember-cli/lib/errors/silent.js` is deprecated, use `silent-error` instead.
DEPRECATION: `ember-cli/lib/errors/silent.js` is deprecated, use `silent-error` instead.
DEPRECATION: `ember-cli/lib/errors/silent.js` is deprecated, use `silent-error` instead.
Cannot read property 'prototype' of undefined
TypeError: Cannot read property 'prototype' of undefined
    at Object.56../$ (<anonymous>:1906:25)
    at s (<anonymous>:13:255)
    at <anonymous>:13:306
    at Object.91../modules/$ (<anonymous>:3043:1)
    at s (<anonymous>:13:255)
    at <anonymous>:13:306
    at Object.<anonymous> (<anonymous>:109:1)
    at Object.2.core-js/shim (<anonymous>:117:4)
    at s (<anonymous>:13:255)
    at e (<anonymous>:13:426)

Tested using iojs 2.4.0 and nodejs 0.12.4

@jamiebuilds
Copy link

Could you just like share the code that's causing the error in like a code snippet? I'm on a phone and a whole repo is not very minimal.

@topaxi
Copy link
Author

topaxi commented Aug 14, 2015

I'm not a 100% sure, but I think it is here: https://github.com/topaxi/fastboot-test/blob/master/vendor/babel-browser-polyfill.js#L1894

// ...
},{"./$.def":13}],56:[function(require,module,exports){
'use strict';
var $          = require('./$')
  , isObject   = $.isObject
  , isFunction = $.isFunction
  , NUMBER     = 'Number'
  , $Number    = $.g[NUMBER]
  , Base       = $Number
  , proto      = $Number.prototype; // <- This line right here!
function toPrimitive(it){
  var fn, val;
  if(isFunction(fn = it.valueOf) && !isObject(val = fn.call(it)))return val;
  if(isFunction(fn = it.toString) && !isObject(val = fn.call(it)))return val;
  throw TypeError("Can't convert object to number");
}
// ...

@tomdale
Copy link
Contributor

tomdale commented Jan 27, 2016

@topaxi Have you had a chance to look into this more?

@tomdale
Copy link
Contributor

tomdale commented Feb 24, 2016

Gonna close due to inactivity. Please continue the conversation if there are more details.

@tomdale tomdale closed this as completed Feb 24, 2016
arjansingh pushed a commit to arjansingh/ember-cli-fastboot that referenced this issue Oct 29, 2016
…cument-title

Deprecate setting title via `document.title`
xg-wang pushed a commit to xg-wang/ember-cli-fastboot that referenced this issue Nov 16, 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

3 participants