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

Older target browsers break runtime #316

Closed
raido opened this issue Dec 20, 2019 · 4 comments · Fixed by #338
Closed

Older target browsers break runtime #316

raido opened this issue Dec 20, 2019 · 4 comments · Fixed by #338

Comments

@raido
Copy link

raido commented Dec 20, 2019

When setting target browsers in targets.js file like this:

const browsers = [
  'Android >= 4.1'
];

Build succeeds but app actually does no run and fails with error:

Uncaught ReferenceError: _EmberObject is not defined
    at Module.callback (index.js:137)
    at Module.exports (loader.js:106)
    at Module._reify (loader.js:143)
    at Module.reify (loader.js:130)
    at Module.exports (loader.js:104)
    at Module._reify (loader.js:143)
    at Module.reify (loader.js:130)
    at Module.exports (loader.js:104)
    at requireModule (loader.js:27)

However when I target browser is set to

const browsers = [
  'Android >= 4.4'
];

Build succeeds and also app runs perfectly on runtime.

This hints like some sort of Babel transforms mess something up but not sure where is it happening. Is it in this repository, in ember-source or some Babel plugin combinations simply break it.

I have an app in production which has Android >= 4.1 target + Babel v7.12.0 but it's no longer upgradeable as whenever some floating dependency gets bumped it breaks and which of the packages cause this is difficult understand.

How to reproduce

Simply create blank addon or app, set target to Android >= 4.1 and it will fail when trying to visit http://localhost:4200

@raido
Copy link
Author

raido commented Dec 21, 2019

I did some more debugging and here are some off the diffs:

Babel plugins:

diff plugins-android44.txt plugins-android41.txt 
29a30
> transform-reserved-words

Disabling transform-reserved-words plugin does not help, app is still broken.

App.js:

diff dummy-android41.js dummy-android44.js 
44c44
<   }(_EmberApplication2);
---
>   }(Ember.Application);
162c162
<   }(_EmberRouter2);
---
>   }(Ember.Router);

Vendor:js

diff vendor-android41.js vendor-android44.js
61213,61214c61213,61214
<   function isEqualCharSpec(spec, _char, negate) {
<     return spec.char === _char && spec.negate === negate;
---
>   function isEqualCharSpec(spec, char, negate) {
>     return spec.char === char && spec.negate === negate;
61233c61233
<   var State = function State(states, id, _char2, negate, repeat) {
---
>   var State = function State(states, id, char, negate, repeat) {
61236c61236
<     this.char = _char2;
---
>     this.char = char;
61253c61253
<   State.prototype.get = function get(_char3, negate) {
---
>   State.prototype.get = function get(char, negate) {
61265c61265
<         if (isEqualCharSpec(child, _char3, negate)) {
---
>         if (isEqualCharSpec(child, char, negate)) {
61272c61272
<       if (isEqualCharSpec(child$1, _char3, negate)) {
---
>       if (isEqualCharSpec(child$1, char, negate)) {
61278c61278
<   State.prototype.put = function put(_char4, negate, repeat) {
---
>   State.prototype.put = function put(char, negate, repeat) {
61282c61282
<     if (state = this.get(_char4, negate)) {
---
>     if (state = this.get(char, negate)) {
61288c61288
<     state = new State(states, states.length, _char4, negate, repeat);
---
>     state = new State(states, states.length, char, negate, repeat);
61333,61334c61333,61334
<   function isMatch(spec, _char5) {
<     return spec.negate ? spec.char !== _char5 && spec.char !== -1
---
>   function isMatch(spec, char) {
>     return spec.negate ? spec.char !== char && spec.char !== -1
61336c61336
<     : spec.char === _char5 || spec.char === -1
---
>     : spec.char === char || spec.char === -1
67107c67107
<   var CAPABILITIES = true ? _Ember_componentManagerCapabilities('3.13', {
---
>   var CAPABILITIES = true ? Ember._componentManagerCapabilities('3.13', {
67111c67111
<   }) : _Ember_componentManagerCapabilities('3.4', {
---
>   }) : Ember._componentManagerCapabilities('3.4', {
67143,67146c67143,67144
< 
<         _EmberRunSchedule('actions', component, component.willDestroy);
< 
<         _EmberRunSchedule('destroy', this, scheduledDestroyComponent, component, meta);
---
>         Ember.run.schedule('actions', component, component.willDestroy);
>         Ember.run.schedule('destroy', this, scheduledDestroyComponent, component, meta);
67151c67149
<   }((0, _baseComponentManager.default)(_EmberSetOwner, _EmberGetOwner, CAPABILITIES));
---
>   }((0, _baseComponentManager.default)(Ember.setOwner, Ember.getOwner, CAPABILITIES));
67179c67177
<       _EmberSet(component, 'args', argSnapshot);
---
>       Ember.set(component, 'args', argSnapshot);
67280c67278
<     _Ember_setComponentManager(function (owner) {
---
>     Ember._setComponentManager(function (owner) {
67284c67282
<     _Ember_setComponentManager('glimmer', GlimmerComponent);
---
>     Ember._setComponentManager('glimmer', GlimmerComponent);
67417c67415
<   var _default = _EmberContainerDebugAdapter.extend({
---
>   var _default = Ember.ContainerDebugAdapter.extend({
67467,67468c67465
<       var types = _EmberA();
< 
---
>       var types = Ember.A();
67599,67601c67596
< 
<     var namespace = _EmberGet(this, 'namespace');
< 
---
>     var namespace = Ember.get(this, 'namespace');
67613c67608
<       resolveMethodName: "resolve" + _EmberStringClassify(type)
---
>       resolveMethodName: "resolve" + Ember.String.classify(type)
67636c67631
<   var Resolver = _EmberObject.extend({
---
>   var Resolver = Ember.Object.extend({
67702c67697
<           return type + ':' + _EmberStringDasherize(split[1].replace(/\./g, '/'));
---
>           return type + ':' + Ember.String.dasherize(split[1].replace(/\./g, '/'));
67791c67786
<     moduleNameLookupPatterns: _EmberComputed(function () {
---
>     moduleNameLookupPatterns: Ember.computed(function () {
67821c67816
<       var underscoredModuleName = _EmberStringUnderscore(moduleName);
---
>       var underscoredModuleName = Ember.String.underscore(moduleName);
67854c67849
<           if (!alreadyWarned && this._moduleRegistry.has(_EmberStringDasherize(moduleName))) {
---
>           if (!alreadyWarned && this._moduleRegistry.has(Ember.String.dasherize(moduleName))) {
67857c67852
<             (true && Ember.warn('Attempted to lookup "' + parsedName.fullName + '" which ' + 'was not found. In previous versions of ember-resolver, a bug would have ' + 'caused the module at "' + _EmberStringDasherize(moduleName) + '" to be ' + 'returned for this camel case helper name. This has been fixed. ' + 'Use the dasherized name to resolve the module that would have been ' + 'returned in previous versions.', false, {
---
>             (true && Ember.warn('Attempted to lookup "' + parsedName.fullName + '" which ' + 'was not found. In previous versions of ember-resolver, a bug would have ' + 'caused the module at "' + Ember.String.dasherize(moduleName) + '" to be ' + 'returned for this camel case helper name. This has been fixed. ' + 'Use the dasherized name to resolve the module that would have been ' + 'returned in previous versions.', false, {
67949d67943
< 
68378c68372
<     _EmberTestRegisterWaiter(function () {
---
>     Ember.Test.registerWaiter(function () {
68552c68546
< /***/ "../../../../../private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/app.js":
---
> /***/ "../../../../../private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/app.js":
68554c68548
<   !*** /private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/app.js ***!
---
>   !*** /private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/app.js ***!
68559c68553
< eval("\nif (typeof document !== 'undefined') {\n  __webpack_require__.p = (function(){\n    var scripts = document.querySelectorAll('script');\n    return scripts[scripts.length - 1].src.replace(/\\/[^/]*$/, '/');\n  })();\n}\n\nmodule.exports = (function(){\n  var d = _eai_d;\n  var r = _eai_r;\n  window.emberAutoImportDynamic = function(specifier) {\n    return r('_eai_dyn_' + specifier);\n  };\n})();\n\n\n//# sourceURL=webpack://__ember_auto_import__//private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/app.js?");
---
> eval("\nif (typeof document !== 'undefined') {\n  __webpack_require__.p = (function(){\n    var scripts = document.querySelectorAll('script');\n    return scripts[scripts.length - 1].src.replace(/\\/[^/]*$/, '/');\n  })();\n}\n\nmodule.exports = (function(){\n  var d = _eai_d;\n  var r = _eai_r;\n  window.emberAutoImportDynamic = function(specifier) {\n    return r('_eai_dyn_' + specifier);\n  };\n})();\n\n\n//# sourceURL=webpack://__ember_auto_import__//private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/app.js?");
68563c68557
< /***/ "../../../../../private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/l.js":
---
> /***/ "../../../../../private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/l.js":
68565c68559
<   !*** /private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/l.js ***!
---
>   !*** /private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/l.js ***!
68570c68564
< eval("\nwindow._eai_r = require;\nwindow._eai_d = define;\n\n\n//# sourceURL=webpack://__ember_auto_import__//private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/l.js?");
---
> eval("\nwindow._eai_r = require;\nwindow._eai_d = define;\n\n\n//# sourceURL=webpack://__ember_auto_import__//private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/l.js?");
68576c68570
<   !*** multi /private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/l.js /private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/app.js ***!
---
>   !*** multi /private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/l.js /private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/app.js ***!
68581c68575
< eval("__webpack_require__(/*! /private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/l.js */\"../../../../../private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/l.js\");\nmodule.exports = __webpack_require__(/*! /private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/app.js */\"../../../../../private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/app.js\");\n\n\n//# sourceURL=webpack://__ember_auto_import__/multi_/private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/l.js_/private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3663GGs1lGV5Ym9F/cache-181-bundler/staging/app.js?");
---
> eval("__webpack_require__(/*! /private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/l.js */\"../../../../../private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/l.js\");\nmodule.exports = __webpack_require__(/*! /private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/app.js */\"../../../../../private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/app.js\");\n\n\n//# sourceURL=webpack://__ember_auto_import__/multi_/private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/l.js_/private/var/folders/jp/2wh258pj23xg7sqgdf8g7gnc0000gn/T/broccoli-3575n1OEqFHUoB9s/cache-181-bundler/staging/app.js?");

@rwjblue
Copy link
Member

rwjblue commented Dec 23, 2019

The actual bug is over in ember-cli/babel-plugin-ember-modules-api-polyfill#64 (which has some breadcrumbs about what is going on).

@raido
Copy link
Author

raido commented Dec 23, 2019

Thanks. Let’s keep this issue here open for awhile for others who might run into this.

@rwjblue
Copy link
Member

rwjblue commented May 29, 2020

ember-cli-babel@7.20.1 was just released, and should fix the underlying issue.

https://github.com/babel/ember-cli-babel/releases/tag/v7.20.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants