miguelcobain / ember-paper

The Ember approach to Material Design.
http://miguelcobain.github.io/ember-paper
MIT License
889 stars 332 forks source link

Does not install with Ember 4.1.0 #1202

Open mattsimpson01 opened 2 years ago

mattsimpson01 commented 2 years ago

Issue: Ember server crashes after installing ember paper. Error message - this.registerPlugin is not a function

ember-cli: 4.1.0 node: 16.3.0 os: linux x64

Steps to reproduce

npm install -g ember-cli
ember new etest --lang en
ember install ember-paper
ember server

Log file ERROR Summary:

umitozturk commented 2 years ago

after ember v3.27.0 (May 3, 2021), registerPlugin / unregisterPlugin was deprecated. that's the reason why you're getting this error.

you can see in here: https://github.com/emberjs/ember.js/blob/master/CHANGELOG.md

xiaobeiswift commented 2 years ago

How to deal with it

locks commented 2 years ago

https://github.com/emberjs/ember.js/pull/19429#issuecomment-786403885 you can try pinning ember-cli-htmlbars to the suggested version.

jacobq commented 1 year ago

In case it's helpful for someone else able to make a PR, here's a start: https://github.com/jacobq/ember-paper/tree/fix-1202 Test suite is not passing, but it didn't pass when I tried to build on master or v1.0.0.-beta.36 either, and I am out of time to spend on this. If you want to do a quick check if it works in your application you can put this in your devDependencies:

    "ember-paper": "jacobq/ember-paper#1a041e10733ef5b3878e6fc3b68c023e6a73ad03",

I was able to get it to build with the following selective dependency resolution:

  "resolutions": {
    "ember-paper/ember-composability-tools": "^1.1.0"
  },

Without ember-composability-tools update I got "this.registerPlugin is not a function" (at one point I also had "ember-paper/ember-css-transitions": "^3.1.0" for some reason but didn't need for simple case).

But then Ember.libraries.register('Ember Paper', '1.0.0-beta.36') caused a runtime error even though it built OK (Tested with ember-source: ~4.7.0).

Uncaught Error: Could not find module ember-resolver imported from etest/app

Annoyingly, the docs still say that Ember.libraries.register(libraryName, libraryVersion); is OK, but some GitHub searching shows otherwise.

Modifying ember-paper's index.js as follows (hacky as it is) corrected that error:

 treeForVendor(tree) {
    let trees = [];

    let versionTree = writeFile(
      'ember-paper/register-version.js',
      //`Ember.libraries.register('Ember Paper', '${version}');`
      `let Ember;
try {
  Ember = requireModule('ember')['default'];
} catch {
  Ember = window.Ember;
}
Ember?.libraries?.register('Ember Paper', '${version}');`
    );

Update: It looks like ember-paper is relying on ParentMixin from the older version of ember-composability-tools being used, but that was removed during octane migration, so there is some breakage that results from this update that still needs to be fixed before things will work right.