Tools: "Unable to resolve behavior" error with v0.18.0-alpha.9

Created on 6 Feb 2017  路  5Comments  路  Source: Polymer/tools

Description

I switched from 0.17.0 to 0.18.0-alpha.9 because of some issues integrating with web-component-tester-istanbul. However I then tried to integrate with polymer-redux and everything was going fine, polymer test is working, polymer serve is working, but polymer build fails.

I rolled back to 0.17.0 and the build succeeds just fine

Versions & Environment

  • Polymer CLI: 0.18.0.alpha.9
  • node: 6.9.4
  • Operating System: macOS Sierra 10.12.3

Steps to Reproduce

Create a PolymerRedux behavior

<link rel="import" href="../bower_components/polymer-redux/polymer-redux.html">
<link rel="import" href="./app.html">
<script>
  /** @polymerBehavior */
  ReduxBehavior = PolymerRedux(app.store);
</script>

Import and use the behavior in an app

<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="./redux-behavior.html">

<dom-module id="my-app">
  <template>
    <div class="user">[[currentUser]]</div>
  </template>
  <script>
    Polymer({
      is: 'my-app',
      behaviors: [ReduxBehavior],
      properties: {
        currentUser: {
          type: String,
          statePath: function(state) {
            var currentUser = state.currentUser;
            return currentUser === null ? 'null' : currentUser.displayName;
          }
        }
      }
    });
  </script>
</dom-module>

Run polymer build

Expected Results

Build succeeds

Actual Results

Build fails with the following error on 0.18.0-alpha.9 but succeeds on 0.17.0

error:   In src/my-app.html: [unknown-polymer-behavior] - Unable to resolve behavior `ReduxBehavior`. Did you import it? Is it annotated with @polymerBehavior?
error:   Promise rejection: Error: 1 error(s) occurred during build.
error:   Error: 1 error(s) occurred during build.
    at BuildAnalyzer._done (/Users/pghalliday/projects/github/pghalliday-boilerplate/polymer-firebase-boilerplate/app/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:201:25)
    at BuildAnalyzer.<anonymous> (/Users/pghalliday/projects/github/pghalliday-boilerplate/polymer-firebase-boilerplate/app/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:185:26)
    at next (native)
    at fulfilled (/Users/pghalliday/projects/github/pghalliday-boilerplate/polymer-firebase-boilerplate/app/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:17:58)
    at process._tickCallback (internal/process/next_tick.js:103:7)
Build cli High Available Bug wontfix

Most helpful comment

I just upgraded to 0.18.0-pre.10 and I still get this

EDIT: I've found a workaround, instead of :
````javascript
/**

  • Redux behavior
    *
  • @polymerBehavior
    */
    const ReduxBehavior = PolymerRedux(store)
    ````

try:
````javascript
/**

  • Redux behavior
    *
  • @polymerBehavior
    */
    const ReduxBehavior = Object.assign({}, PolymerRedux(store))
    ````

All 5 comments

I can reproduce, it looks like we may only be registering behaviors correctly when they are an object literal. @rictic can you take a look?

I just upgraded to 0.18.0-pre.10 and I still get this

EDIT: I've found a workaround, instead of :
````javascript
/**

  • Redux behavior
    *
  • @polymerBehavior
    */
    const ReduxBehavior = PolymerRedux(store)
    ````

try:
````javascript
/**

  • Redux behavior
    *
  • @polymerBehavior
    */
    const ReduxBehavior = Object.assign({}, PolymerRedux(store))
    ````

Is there a way to disable analyze when running polymer build?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings