ember-cli / ember-cli-deprecation-workflow

MIT License
165 stars 43 forks source link

Doesn't work under embroider #133

Open NullVoxPopuli opened 2 years ago

NullVoxPopuli commented 2 years ago

https://github.com/GavinJoyce/ember-headlessui/pull/93/checks?check_run_id=3783717513#step:7:180 The error in the github action run:

not ok 1 Chrome 94.0 - [undefined ms] - Global error: Uncaught ReferenceError: Ember is not defined at http://localhost:7357/assets/vendor.js, line 1053

The code that's causing it: https://github.com/mixonic/ember-cli-deprecation-workflow/blob/master/vendor/ember-cli-deprecation-workflow/main.js#L33

  let registerDeprecationHandler = require.has('@ember/debug') ? require('@ember/debug').registerDeprecationHandler : Ember.Debug.registerDeprecationHandler;

Why is the ember global accessed here? it needs to be imported.

ef4 commented 2 years ago

The easiest solution here is to drop support for old ember versions and say import { registerDeprecationHandler } from '@ember/debug';

Alternatively, instead of require.has use the dependencySatisfies from @embroider/macros.

mixonic commented 2 years ago

The file in question is not in the addon tree, and that is why a plain import cannot be used.

This pr https://github.com/mixonic/ember-cli-deprecation-workflow/pull/117 explored adding a setup step in app.js and using the addon tree. There are some tradeoffs with the approach to consider but I'm not against it.

I don't think you need to drop any Ember versions to do this.

ef4 commented 2 years ago

I mentioned ember version support because I assumed that's what this was doing. I guess this is in vendor so it runs early enough?

Accessing ember api from vendor scripts is problematic going forward. Not just because of embroider -- if we're going to follow the ES module spec then ember's modules need to be accessed as modules. So either statically imported from a module (not from a script) or dynamically imported.

Asking apps to import something from app.js is definitely one option. Another is to add a separate <script type="module"> before the app's.

amk221 commented 8 months ago

Is there any way to get Embroider apps to build with ember-cli-deprecation-workflow? Or do I have to temporarily uninstall it?

aklkv commented 8 months ago

This worked for us as a temporary solution

enspandi commented 8 months ago

We're working with this branch currently https://github.com/lolmaus/ember-cli-deprecation-workflow/tree/ember-debug

    "ember-cli-deprecation-workflow": "github:lolmaus/ember-cli-deprecation-workflow#ember-debug",

But it requires a few changes you can check in the dummy app: