ember-cli-deprecation-workflow
ember-cli-deprecation-workflow copied to clipboard
Doesn't work under embroider
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.
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.
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.
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.
Is there any way to get Embroider apps to build with ember-cli-deprecation-workflow
? Or do I have to temporarily uninstall it?
This worked for us as a temporary solution
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