ember-cli-deprecation-workflow icon indicating copy to clipboard operation
ember-cli-deprecation-workflow copied to clipboard

Doesn't work under embroider

Open NullVoxPopuli opened this issue 3 years ago • 6 comments

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.

NullVoxPopuli avatar Oct 03 '21 19:10 NullVoxPopuli

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.

ef4 avatar Jan 15 '22 22:01 ef4

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.

mixonic avatar Jan 15 '22 23:01 mixonic

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.

ef4 avatar Jan 16 '22 00:01 ef4

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

amk221 avatar Jan 19 '24 10:01 amk221

This worked for us as a temporary solution

aklkv avatar Jan 19 '24 10:01 aklkv

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:

  • https://github.com/lolmaus/ember-cli-deprecation-workflow/blob/ember-debug/tests/dummy/app/deprecation-workflow.js
  • https://github.com/lolmaus/ember-cli-deprecation-workflow/blob/ember-debug/tests/dummy/app/app.js#L5

enspandi avatar Jan 19 '24 10:01 enspandi