miguelcobain / ember-paper

The Ember approach to Material Design.

Home Page:http://miguelcobain.github.io/ember-paper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not install with Ember 4.1.0

mattsimpson01 opened this issue · comments

commented

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:

  • broccoliBuilderErrorStack: [undefined]
  • code: [undefined]
  • codeFrame: [undefined]
  • errorMessage: this.registerPlugin is not a function
  • errorType: [undefined]
  • location:
    • column: [undefined]
    • file: [undefined]
    • line: [undefined]
  • message: this.registerPlugin is not a function
  • name: TypeError
  • nodeAnnotation: [undefined]
  • nodeName: [undefined]
  • originalErrorMessage: [undefined]
  • stack: TypeError: this.registerPlugin is not a function
    at TemplateCompiler.registerPlugins (/home/matt/dev/_current/ember/etest/node_modules/ember-composability-tools/node_modules/ember-cli-htmlbars/index.js:63:16)
    at new TemplateCompiler (/home/matt/dev/_current/ember/etest/node_modules/ember-composability-tools/node_modules/ember-cli-htmlbars/index.js:42:10)
    at Object.toTree (/home/matt/dev/_current/ember/etest/node_modules/ember-composability-tools/node_modules/ember-cli-htmlbars/ember-addon-main.js:47:16)
    at /home/matt/dev/_current/ember/etest/node_modules/ember-cli-preprocess-registry/preprocessors.js:188:26
    at Array.forEach ()
    at processPlugins (/home/matt/dev/_current/ember/etest/node_modules/ember-cli-preprocess-registry/preprocessors.js:186:11)
    at module.exports.preprocessTemplates (/home/matt/dev/_current/ember/etest/node_modules/ember-cli-preprocess-registry/preprocessors.js:169:10)
    at Class.compileTemplates (/home/matt/dev/_current/ember/etest/node_modules/ember-cli/lib/models/addon.js:1138:35)
    at Class.compileAddon (/home/matt/dev/_current/ember/etest/node_modules/ember-cli/lib/models/addon.js:1200:42)
    at Class.treeForAddon (/home/matt/dev/_current/ember/etest/node_modules/ember-cli/lib/models/addon.js:856:26)

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

How to deal with it

emberjs/ember.js#19429 (comment) you can try pinning ember-cli-htmlbars to the suggested version.

commented

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.