Tools: Failing to find behaviors after switching to 0.5.1

Created on 6 Dec 2016  路  29Comments  路  Source: Polymer/tools

Description

After switching from 0.5.0 to 0.5.1 I have following errors:

init_1   | error:   In vendor/neon-animation/neon-animation-runner-behavior.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.NeonAnimatableBehavior`. Did you import it? Is it annotated with @polymerBehavior?
init_1   | error:   In vendor/neon-animation/animations/fade-in-animation.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.NeonAnimationBehavior`. Did you import it? Is it annotated with @polymerBehavior?
init_1   | error:   In vendor/neon-animation/animations/fade-out-animation.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.NeonAnimationBehavior`. Did you import it? Is it annotated with @polymerBehavior?
init_1   | error:   In vendor/iron-selector/iron-multi-selectable.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.IronSelectableBehavior`. Did you import it? Is it annotated with @polymerBehavior?
init_1   | error:   In vendor/neon-animation/animations/opaque-animation.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.NeonAnimationBehavior`. Did you import it? Is it annotated with @polymerBehavior?
init_1   | error:   In vendor/paper-menu-button/paper-menu-button-animations.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.NeonAnimationBehavior`. Did you import it? Is it annotated with @polymerBehavior?
init_1   | error:   In vendor/paper-menu-button/paper-menu-button-animations.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.NeonAnimationBehavior`. Did you import it? Is it annotated with @polymerBehavior?
init_1   | error:   In vendor/paper-menu-button/paper-menu-button-animations.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.NeonAnimationBehavior`. Did you import it? Is it annotated with @polymerBehavior?
init_1   | error:   In vendor/paper-menu-button/paper-menu-button-animations.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.NeonAnimationBehavior`. Did you import it? Is it annotated with @polymerBehavior?
init_1   | error:   In vendor/paper-input/paper-input.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.IronFormElementBehavior`. Did you import it? Is it annotated with @polymerBehavior?
init_1   | error:   In vendor/paper-input/paper-input.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.PaperInputBehavior`. Did you import it? Is it annotated with @polymerBehavior?
init_1   | error:   In vendor/iron-lazy-pages/iron-lazy-pages.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.IronLazyPagesBehavior`. Did you import it? Is it annotated with @polymerBehavior?
init_1   | error:   In vendor/paper-dialog/paper-dialog.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.PaperDialogBehavior`. Did you import it? Is it annotated with @polymerBehavior?
init_1   | error:   In vendor/paper-input/paper-input-error.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.PaperInputAddonBehavior`. Did you import it? Is it annotated with @polymerBehavior?

Project structure:

src/
  index.html
vendor/             # bower_components
bower.json

polymer.json:

{
    "entrypoint": "src/index.html",
    "shell": "src/components/app/bi-app/bi-app.html",
    "fragments": [
        "src/components/pages/bi-404/bi-404-page.html", # etc
        ...
    ],
    "sources": [
        "src/**/*"
    ]
}

Versions & Environment

  • polymer-build: 0.5.1
  • node: 6.9.1
  • Operating System: Mac OS El Capitan 10.11.5

Please pay attention that vendor (bower components dir) is outside of src. Not sure if this is the reason. In local env, I mount both directories into docker container as volumes, and I have a symlink src/vendor which points to vendor.

Adding bower.json to sources doesn't help.

build

All 29 comments

UPD: modifying sources fixed the issue.

    "sources": [
        "vendor/**/*",
        "src/components/**/*"
    ]

For now I'll keep this opened, please close if this is not a build / analyzer issue (e. g. my previous config was wrong and my build only used to pass by accident).

I bet it's that you're using vendor rather than bower_components. Not sure that we've threaded through a components dir setting yet.

Good point. Looks like the config from .bowerrc should be passed here.
BTW adding whole vendor dir to sources significantly increased build time (around 30 more seconds), becasue we are installing whole paper-elements while really using only a subset.

Yea, by including the entire vendor directory in sources or extraDependencies will cause the entire directory to be included in build, including all metadata (READMEs, tests, etc).

vendor instead of bower_components should not be an issue, since you're application imports explicitly point to vendor, right?

The only thing that changed between 0.5.0->0.5.1 is an update to polymer-analyzer. The CHANGELOG mentions a few behavior-related fixes, my guess is that a regression was introduced there (possibly here). /cc @rictic

@web-padawan is the application available anywhere for us to test on? Do you have a simple reproduction case that you can share?

Yes, my app imports from vendor using relative paths.
Code is not public, but I'll try to make a small reproduction this week.

@web-padawan can you remove js minification from your build pipeline and try again? 0.5.x currently has a problem where minification removes type annotations from your final application.

Arg, I can reproduce this now. Confirmed that the analyzer is incorrectly reporting missing behavior annotations when they do exist , as of v0.5.1.

I'll look into this in polymer-analyzer now. /cc @rictic

Update: @rictic already has a fix in progress, we are working on getting it merged now.

I have the same issue! Any news on this? :)

@abdonrd yes! This was fixed on master with the analyze-first work. It's available today via the next tag (npm install poylmer-build@next --save-dev), and we hope to get it pushed out broadly in the next few days.

/cc @web-padawan as well

Need to stamp polymer-analyzer 2.0.0-alpha20 and polymer-build 0.6.0 to have this fixed, right?

It's fixed in the polymer-build v0.6.0 prerelease, available today via npm i polymer-build@next. We'll be stamping v0.6.0 soon.

Thanks! Will upgrade once it will be stamped.
Right now, installing npm i polymer-build@next still resolves to [email protected].

Yup, but it should be fixed anyway. The polymer-analyzer issue had to do with parallel analysis, which we removed from polymer-build in v0.6.0. Try running again and let me know if you're still seeing issues resolving behaviors.

FYI, even after installing _polymer-build@next_ I'm still seeing issues resolving behaviors. Specifically, I'm using app-localize-behavior in many of my custom elements. Also, I'm still using Polymer 1.0+, not Polymer 2.0 elements.

@Sinjins Do you have a link to a file/project that's giving that warning?

@rictic code isn't public, but I'm using GULP, and an exact replica of gulpfile.js used by https://github.com/PolymerElements/generator-polymer-init-custom-build
Only difference is that my elements also happen to use app-localize-behavior

Hm, tricky to remote debug without the code or a public repro. Do the elements import app-localize-behavior.html? Do they reference it as anything other than PolymerAppLocalizeBehavior?

@rictic yes, sorry bout that. Each of the elements do indeed import app-localize-behavior, and then implement the behavior as follows:

<link rel="import" href="../bower_components/app-localize-behavior/app-localize-behavior.html">

behaviors: [ Polymer.AppLocalizeBehavior ]

attached: function () { this.loadResources(this.resolveUrl(localesFile)); },

FYI, I just updated to the latest polymer-build (v 0.8.1) and now I receive the following 'warning' messages during gulp build (for each of elements that use app-localize-behavior):

[could-not-determine-behavior-name] - Could not determine behavior name from expression of type CallExpression

[unknown-polymer-behavior] - Unable to resolve behavior Polymer.NeonAnimatableBehavior. Did you import it? Is it annotated with @polymerBehavior?

I Have been facing this issue while making the build.Can any one help me.

@Bunny2242 you're probably using an old version of the CLI, or you aren't properly importing that behavior.

Join the #general or #tools channels on Slack if you're interested in more help using Polymer & Polymer tools.

@FredKSchott
I have included like mentioned below. is this wrong?.

Polymer({
is: 'my-app',
behaviors: [
Polymer.NeonAnimatableBehavior,
Polymer.NeonAnimationBehavior,
Polymer.NeonAnimationRunnerBehavior,
]
});

@Bunny2242 That should work, provided that you have imports for the proper files in your element. Something like the following:

<link rel="import" href="../neon-animation/neon-animatable-behavior.html">
<link rel="import" href="../neon-animation/neon-animation-behavior.html">
<link rel="import" href="../neon-animation/neon-animation-runner-behavior.html">

For those who are making a custom behavior and still get this error although they are importing the corresponding .html file:

<script>
    /**
     * @polymerBehavior
     */
    Polymer.MyCustomBehavior = {};
</script>

Just add @polymerBehavior in a comment directly above the behavior declaration. This fixed the polymer lint errors for me.

@tsvetan-ganev

You also need to include the behaviour name in the annotation:

<script>
    /**
     * @polymerBehavior MyCustomBehavior
     */
    Polymer.MyCustomBehavior = {};
</script>

Also for some strange reason including newlines between the annotation and the definition throws lint warnings [unknown-polymer-behavior]. I'm guessing it's a bit more strict than it should?

@nicholaswmin there used to be a bug in analyzer which treated not related comments, e. g eslint instructions, like behaviors annotations. It was fixed in 2.2.0 by assuming that no newline should present there.

Any fix for this? I still get these warnings on polymer-cli 1.5.4.

Including the behavior name in the annotation didn't fix it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Westbrook picture Westbrook  路  4Comments

ankon picture ankon  路  4Comments

pmaudsley picture pmaudsley  路  3Comments

idoshamun picture idoshamun  路  3Comments

MaKleSoft picture MaKleSoft  路  3Comments