ember-cli / ember-cli-deprecation-workflow

MIT License
165 stars 43 forks source link

Doesn't work when enabling Embroider's new `staticEmberSource` option #156

Closed bertdeblock closed 2 months ago

bertdeblock commented 1 year ago

The inline if on this LOC evaluates to false, after which an error is thrown, because the Ember global is no longer available.

bertdeblock commented 1 year ago

At the moment, we ditched ember-cli-deprecation-workflow in favour of a custom / smaller / more vanilla setup:

// app/app.js

import { importSync, isDevelopingApp, macroCondition } from '@embroider/macros';

if (macroCondition(isDevelopingApp())) {
  importSync('module-prefix/deprecation-workflow');
}
// app/deprecation-workflow.js

import { registerDeprecationHandler } from '@ember/debug';
import config from 'module-prefix/config/environment';

const SHOULD_THROW = config.environment !== 'production';
const SILENCED_DEPRECATIONS = [
  // Add ids of deprecations you temporarily want to silence here.
];

registerDeprecationHandler((message, options, next) => {
  if (SILENCED_DEPRECATIONS.includes(options.id)) {
    return;
  } else if (SHOULD_THROW) {
    throw new Error(message);
  }

  next(message, options);
});

I think this is a direction ember-cli-deprecation-workflow could go in as well.

jrjohnson commented 1 year ago

THANK YOU @bertdeblock, I was exploring something with an initializer, but this is a way more complete solution.

NullVoxPopuli commented 8 months ago

favour of a custom / smaller / more vanilla setup:

should we make this default in ember and not bother with another dep? it's so few lines

jrjohnson commented 8 months ago

That makes a lot of sense to me @NullVoxPopuli. I can't imagine using an ember app without this functionality.

elwayman02 commented 5 months ago

It would be great to get a release of ember-cli-deprecation-workflow that supports this, as a short-term bridge to @NullVoxPopuli's suggestion of supporting it more formally in Ember.

mansona commented 2 months ago

This has been fixed in https://github.com/ember-cli/ember-cli-deprecation-workflow/releases/tag/v3.0.0-ember-cli-deprecation-workflow 🎉