ember-codemods / ember-modules-codemod

Codemod to upgrade Ember apps to JavaScript (ES6) modules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Correct place to report a bug?

toranb opened this issue · comments

@rwjblue I really like this project :) and greatly appreciate your involvement to move the community forward!

I started converting one of my addons today and found that when I destructure assert from @ember/debug the compiled output omits it for some odd reason. When I did some source diving I found what looks like a missing dependency (shown in the snippet at the bottom of this issue).

import { assert } from '@ember/debug';

enifed('ember-debug/index', ['exports', 'ember/features', 'ember-environment', 'ember-console', 'ember-debug/testing', 'ember-debug/error', 'ember-debug/features', 'ember-debug/deprecate', 'ember-debug/warn'], function (exports, _emberFeatures, _emberEnvironment, _emberConsole, _emberDebugTesting, _emberDebugError, _emberDebugFeatures, _emberDebugDeprecate, _emberDebugWarn) {
  'use strict';

  exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags;
  exports.getDebugFunction = getDebugFunction;
  exports.setDebugFunction = setDebugFunction;
  exports.assert = assert;
  exports.info = info;
  exports.warn = warn;

^^ In the above I see how warn would be injected/ and then wired up to the export but ... I don't see the same for assert. If this is the root cause, what project (or sub project) should land the PR to fix this so others can destructure assert without issue? Thank you in advance!

Firstly, the snippet you pasted was from Embers internal module registry (which is completely isolated from your apps modules).

A few things to review:

tldr; The assert import is supposed to be stripped in production builds. You may or may not have an issue, but we need to understand the actual circumstances a bit more first to diagnose.

Also, this will likely end up being an issue over on ember-cli-babel (not the "once and done" codemod).

Closing for now, hopefully my answer was helpful...

@rwjblue yup -thanks for the direction. At this time I think I'll need to open an issue w/ ember-cli-babel describing my use case (of assert) to better understand the path forward