Git Product home page Git Product logo

Comments (19)

buschtoens avatar buschtoens commented on June 2, 2024 3

While we are waiting for #440 to be released, you can use the following hotfix. I'm not proud of that code, but I don't know an easier way to hack into the module system.

/* eslint-disable no-global-assign, func-names, vars-on-top */

if (/Edge\/\d/.test(window.navigator.userAgent)) {
  (function(modDecorator, modFieldDescriptor) {
    var _define = window.define;
    window.define = function define(id, deps, callback) {
      _define(id, deps, callback);
      if (id === modDecorator) {
        window.define = _define;

        var mod = window.require(modDecorator);
        var _decorator = mod.decorator;
        var isDescriptor = window.require(modFieldDescriptor).isDescriptor;

        mod.decorator = function decorator(fn) {
          return Object.setPrototypeOf(_decorator(fn), Function.prototype);
        };

        mod.decoratorWithParams = function(fn) {
          return function() {
            var params = Array.prototype.slice.call(arguments);
            if (isDescriptor(params)) {
              return mod.decorator(fn).apply(undefined, params);
            }
            return mod.decorator(function(desc) {
              return fn(desc, params);
            });
          };
        };
      }
    };
  })(
    '@ember-decorators/utils/decorator',
    '@ember-decorators/utils/-private/class-field-descriptor'
  );
}
// ember-cli-build.js
const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  const app = new EmberApp(defaults, {});
  app.import('vendor/decorators-hotfix.js');
  return app.toTree();
};

from ember-decorators.

elgordino avatar elgordino commented on June 2, 2024 2

Thank you for the hotfix @buschtoens, you saved my day!

from ember-decorators.

mike-north avatar mike-north commented on June 2, 2024 1

Since this is fixed in 2.0 and would likely require some significant digging into legacy ember-cli-typescript and ember-decorators versions, I'll mark this as "won't fix".

If we can identify that a lot of folks are affected by this, we can absolutely reopen this bug and evaluate a 1.x patch

from ember-decorators.

mike-north avatar mike-north commented on June 2, 2024

Now that ember-cli-typescript@2 has been released, and decorators are transformed the same way regardless of whether original source is JS or TS, this should be re-evaluated.

@mfeckie can you upgrade e-cli-ts and let us know whether this Edge issue still exists?

from ember-decorators.

mfeckie avatar mfeckie commented on June 2, 2024

This is not an issue when using e-cli-ts@2, only on 1.5

We've migrated our codebase to use 2.x now, so the problem is gone for us, but it was a non trivial feat to upgrade because we also had to convert everything to use decorators (computeds and tasks).

from ember-decorators.

mfeckie avatar mfeckie commented on June 2, 2024

Getting this issue again, but this time it's with [email protected]

from ember-decorators.

pzuraq avatar pzuraq commented on June 2, 2024

Can you add which versions of ember-decorators and the babel transforms you're using? I'd recommend getting off the stage 2 transforms, and updating to v6, using the polyfill. The stage 1 transforms packaged with ember-cli-babel could help.

from ember-decorators.

mfeckie avatar mfeckie commented on June 2, 2024

Will give it a trry

from ember-decorators.

mfeckie avatar mfeckie commented on June 2, 2024

If I remove the transforms, I can't get the server to start because it seems to break ember-concurrency-decorators.

I'm on ember-decorators v6
ember-cli-babel 7.7.3

from ember-decorators.

donaldwasserman avatar donaldwasserman commented on June 2, 2024

So I'm experiencing this issue, and like @mfeckie, I don't really see way out of this, because I can't quite figure out the matrix of:

  • ember-decorators
  • ember-cli-typescript
  • ember-cli-babel-polyfills

that work to solve this problem.

Using
-ember-decorators 6.0.0

  • ember-cli-babel 7.7.3
  • ember-concurrency-decorators 0.6.0
  • No @ember-decorators/babel-transforms

Gets the server to start, but errors whenever the app comes across the first decorators.

from ember-decorators.

buschtoens avatar buschtoens commented on June 2, 2024

No @ember-decorators/babel-transforms

I'm currently on mobile, but please use the latest e-c-d beta. It's compatible with stage 1 decorators.

from ember-decorators.

buschtoens avatar buschtoens commented on June 2, 2024

lol, I'm now also running into this bug, with the latest and greatest of all dependencies and without @ember-decorators/babel-transforms.

I'm experiencing the same issue using these dependencies:

    "@ember-decorators/babel-transforms": "^5.1.4",
    "@ember-intl/decorators": "^0.4.0",
    "ember-cli-babel": "^7.7.3",
    "ember-cli-typescript": "^2.0.1",
    "ember-concurrency": "^0.9.0",
    "ember-concurrency-decorators": "^0.6.0",

I'll investigate and keep this issue open until I know, where the bug is coming from.

from ember-decorators.

buschtoens avatar buschtoens commented on June 2, 2024

I found the cause.

export function decoratorWithParams(fn) {
return function(...params) {
// determine if user called as @computed('blah', 'blah') or @computed
if (isDescriptor(params)) {
return decorator(fn)(...params);
} else {
return decorator(desc => fn(desc, params));
}
};
}

L73 gets transpiled to:

return decorator(fn).apply(void 0, params);

decorator(fn) appears to return something weird that is logged as [object Function]. Inspecting that thing shows that its prototype is set to Object. You can achieve this manually via Object.setPrototype(function() {}, Object.prototype).

I don't know yet, why this only happens for Edge and not for any other browser, including IE11 ironically. I would assume that it's a bug somewhere between ember-concurrency-decorators and ember-decorators. I'll dig further.

from ember-decorators.

buschtoens avatar buschtoens commented on June 2, 2024

Okay, it's broken in ember-decorators. I checked out v5.2.0, enabled the IE 11 browser in targets.js and tried running the test suite. It fails with the same error.

Since I personally can't switch to stage 1 / legacy decorators just yet in all applications I maintain (and others as well), I have a vested interest in fixing this. 😄

from ember-decorators.

donaldwasserman avatar donaldwasserman commented on June 2, 2024

@buschtoens - I don't understand how the underlying transpilation works (however, I am happy to make uninformed guesses!), but this is the exact same behavior I see.

To add some more confusion, this bug only happens on edge 18 (edge 17 and 16 work as intended).

I'm not sure if this is helpful or not, but I don't think it's e-c-decorators, since we don't have any of those in parts of the app that are initially throwing the error.

from ember-decorators.

donaldwasserman avatar donaldwasserman commented on June 2, 2024

@buschtoens Just saw your latest comment. I'd be happy to help/test things out in whatever way I can. I suspect like you, I've coded myself into a corner and this is the only way out.

from ember-decorators.

mfeckie avatar mfeckie commented on June 2, 2024

Not happy that others are having the same issue, but happy that some solutions may be in the pipeline 😄

from ember-decorators.

buschtoens avatar buschtoens commented on June 2, 2024

I'll keep reporting in #e-decorators to not wreck everybody's inboxes :D

from ember-decorators.

mfeckie avatar mfeckie commented on June 2, 2024

Nice work. I can wait for the PR to be merged thankfully :)

from ember-decorators.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.