Tools: Build fails if the application has polymerfire elements.

Created on 23 Aug 2016  路  17Comments  路  Source: Polymer/tools

Description

Build permanently fails once I add any polymerfire element into the app.

Versions & Environment

  • Polymer CLI: 0.15.0; 0.14.0
  • node: v4.4.7
  • Operating System: OS X El Capitan 10.11.6 (15G31)
Users-MacBook-Pro-2:test_app User$ node -v
v4.4.7
Users-MacBook-Pro-2:test_app User$ polymer --version
0.15.0
Users-MacBook-Pro-2:test_app User$ bower --version
1.7.9

Steps to Reproduce

1) mkdir test_app && cd test_app && polymer init application && bower install --save firebase/polymerfire
2) open src/test_app-app/test_app-app.html and copy-paste this (firebase credentials not needed)

<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/polymerfire/firebase-app.html">

<dom-module id="test_app-app">
    <template>
        <firebase-app>
        </firebase-app>
    </template>

    <script>
        Polymer({
            is: 'test_app-app'
        });
    </script>
</dom-module>

3) Run polymer build

Expected Results

Successful build

Actual Results

OUTPUT

Users-MacBook-Pro-2:test_app User$ polymer build
info:    Building application...
info:    Generating build/unbundled...
info:    Generating build/bundled...
error:   Promise rejection: Error: file path is not in root: /bower_components/firebase/firebase.js (/Users/User/Documents/WebCopilot/test_app/test_app)
error:   Error: file path is not in root: /bower_components/firebase/firebase.js (/Users/User/Documents/WebCopilot/test_app/test_app)
    at Object.urlFromPath (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/path-transformers.js:41:15)
    at StreamAnalyzer.getFile (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:107:39)
    at StreamResolver.accept (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:210:34)
    at FileLoader.request (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/lib/loader/file-loader.js:64:27)
    at Object.<anonymous> (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/vulcanize/lib/vulcan.js:318:26)
    at Array.map (native)
    at Object.inlineScripts (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/vulcanize/lib/vulcan.js:311:34)
    at Object.<anonymous> (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/vulcanize/lib/vulcan.js:458:21)
    at run (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:87:22)
    at /usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:100:28
error:   Promise rejection: Error: file path is not in root: /bower_components/firebase/firebase.js (/Users/User/Documents/WebCopilot/test_app/test_app)
error:   Error: file path is not in root: /bower_components/firebase/firebase.js (/Users/User/Documents/WebCopilot/test_app/test_app)
    at Object.urlFromPath (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/path-transformers.js:41:15)
    at StreamAnalyzer.getFile (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:107:39)
    at StreamResolver.accept (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:210:34)
    at FileLoader.request (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/lib/loader/file-loader.js:64:27)
    at Object.<anonymous> (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/vulcanize/lib/vulcan.js:318:26)
    at Array.map (native)
    at Object.inlineScripts (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/vulcanize/lib/vulcan.js:311:34)
    at Object.<anonymous> (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/vulcanize/lib/vulcan.js:458:21)
    at run (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:87:22)
    at /usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:100:28
Users-MacBook-Pro-2:test_app User$ 
cli wontfix

Most helpful comment

WORKAROUND

Actually I noticed the same as @ergo here. If in index.html you change main app import path to relative, it works fine.

<!--not working-->
<link rel="import" href="/src/test_app-app/test_app-app.html">
<!--works-->
<link rel="import" href="src/test_app-app/test_app-app.html">

All 17 comments

Hmm, it looks like someone reported a similar error but then realized that the problem was caused elsewhere. Maybe the error is somewhere else? @craftyc0der what did you do to fix #248?

@iSuslov Could you rerun with the --verbose flag and post the full output here?

I believe I had the incorrect configuration in the json for that defines the build. Basically I did two things at once and thought it was polymerfire.

@FredKSchott sure, here it is:

Users-MacBook-Pro-2:test_app User$ polymer build --verbose
debug:   got args: 
{ args: [ 'build', '--verbose' ] }
debug:   config file not found 
{ path: 'polymer.json' }
debug:   got default config from file: 
{ config: {} }
debug:   adding command build
debug:   adding command help
debug:   adding command init
debug:   adding command lint
debug:   adding command serve
debug:   adding command test
debug:   running...
debug:   command 'build' found, parsing command args: 
{ args: [ '--verbose' ] }
debug:   command options parsed from args: 
{ 'sw-precache-config': 'sw-precache-config.js', verbose: true }
debug:   final project configuration generated: 
{ root: '/Users/User/Documents/WebCopilot/test_app',
  entrypoint: '/Users/User/Documents/WebCopilot/test_app/index.html',
  fragments: [],
  inputs: [ '/Users/User/Documents/WebCopilot/test_app/index.html' ] }
debug:   Running command...
debug:   building with options 
{ sources: undefined,
  includeDependencies: undefined,
  swPrecacheConfig: 'sw-precache-config.js',
  insertDependencyLinks: undefined,
  html: {},
  css: {},
  js: {} }
debug:   building via standard build()...
debug:   sourceGlobs: 
    /Users/User/Documents/WebCopilot/test_app/index.html
    /Users/User/Documents/WebCopilot/test_app/src/**/*
    /Users/User/Documents/WebCopilot/test_app/bower.json
debug:   root: /Users/User/Documents/WebCopilot/test_app
debug:   shell: undefined
debug:   entrypoint: /Users/User/Documents/WebCopilot/test_app/index.html
debug:   fragments: 
debug:   sources: /Users/User/Documents/WebCopilot/test_app/src/**/*,/Users/User/Documents/WebCopilot/test_app/bower.json
debug:   includeDependencies: 
info:    Building application...
debug:   Reading source files...
debug:   sourceGlobs: 
    /Users/User/Documents/WebCopilot/test_app/index.html
    /Users/User/Documents/WebCopilot/test_app/src/**/*
    /Users/User/Documents/WebCopilot/test_app/bower.json
debug:   Reading dependencies...
debug:   No service worker configuration found at /Users/User/Documents/WebCopilot/test_app/sw-precache-config.js, continuing with defaults
debug:   Analyzing build dependencies...
debug:   addFile: /Users/User/Documents/WebCopilot/test_app/index.html
info:    Generating build/unbundled...
info:    Generating build/bundled...
debug:   accept: index.html
debug:   accept: /bower_components/webcomponentsjs/webcomponents-lite.js
debug:   new dependency found, pushing into dependency stream... /Users/User/Documents/WebCopilot/test_app/bower_components/webcomponentsjs/webcomponents-lite.js
debug:   accept: /src/test_app-app/test_app-app.html
debug:   dependency is a source file, ignoring... 
{ dep: '/src/test_app-app/test_app-app.html' }
debug:   addFile: /Users/User/Documents/WebCopilot/test_app/src/test_app-app/test_app-app.html
debug:   accept: /bower_components/polymer/polymer.html
debug:   new dependency found, pushing into dependency stream... /Users/User/Documents/WebCopilot/test_app/bower_components/polymer/polymer.html
debug:   accept: /bower_components/polymerfire/firebase-app.html
debug:   new dependency found, pushing into dependency stream... /Users/User/Documents/WebCopilot/test_app/bower_components/polymerfire/firebase-app.html
debug:   addFile: /Users/User/Documents/WebCopilot/test_app/bower_components/webcomponentsjs/webcomponents-lite.js
debug:   addFile: /Users/User/Documents/WebCopilot/test_app/bower.json
debug:   addFile: /Users/User/Documents/WebCopilot/test_app/bower_components/polymer/polymer.html
debug:   accept: /bower_components/polymer/polymer-mini.html
debug:   new dependency found, pushing into dependency stream... /Users/User/Documents/WebCopilot/test_app/bower_components/polymer/polymer-mini.html
debug:   addFile: /Users/User/Documents/WebCopilot/test_app/bower_components/polymerfire/firebase-app.html
debug:   accept: /bower_components/polymerfire/firebase.html
debug:   new dependency found, pushing into dependency stream... /Users/User/Documents/WebCopilot/test_app/bower_components/polymerfire/firebase.html
debug:   addFile: /Users/User/Documents/WebCopilot/test_app/bower_components/polymer/polymer-mini.html
debug:   accept: /bower_components/polymer/polymer-micro.html
debug:   new dependency found, pushing into dependency stream... /Users/User/Documents/WebCopilot/test_app/bower_components/polymer/polymer-micro.html
debug:   addFile: /Users/User/Documents/WebCopilot/test_app/bower_components/polymerfire/firebase.html
debug:   addFile: /Users/User/Documents/WebCopilot/test_app/bower_components/polymer/polymer-micro.html
debug:   accept: /bower_components/firebase/firebase.js
debug:   new dependency found, pushing into dependency stream... /Users/User/Documents/WebCopilot/test_app/bower_components/firebase/firebase.js
debug:   addFile: /Users/User/Documents/WebCopilot/test_app/bower_components/firebase/firebase.js
debug:   dependency has already been pushed, ignoring... 
{ dep: 'bower_components/webcomponentsjs/webcomponents-lite.js' }
debug:   dependency has already been pushed, ignoring... 
{ dep: '/bower_components/firebase/firebase.js' }
debug:   dependency has already been pushed, ignoring... 
{ dep: '/src/test_app-app/test_app-app.html' }
debug:   dependency has already been pushed, ignoring... 
{ dep: '/bower_components/polymer/polymer.html' }
debug:   dependency has already been pushed, ignoring... 
{ dep: '/bower_components/polymer/polymer-mini.html' }
debug:   dependency has already been pushed, ignoring... 
{ dep: '/bower_components/polymer/polymer-micro.html' }
debug:   dependency has already been pushed, ignoring... 
{ dep: '/bower_components/polymerfire/firebase-app.html' }
debug:   dependency has already been pushed, ignoring... 
{ dep: '/bower_components/polymerfire/firebase.html' }
debug:   accept: index.html
debug:   accept: /bower_components/webcomponentsjs/webcomponents-lite.js
debug:   accept: /src/test_app-app/test_app-app.html
debug:   accept: /bower_components/polymer/polymer.html
debug:   accept: /bower_components/polymerfire/firebase-app.html
debug:   accept: /bower_components/polymer/polymer-mini.html
debug:   accept: /bower_components/polymerfire/firebase.html
debug:   accept: /bower_components/polymer/polymer-micro.html
debug:   accept: /bower_components/firebase/firebase.js
debug:   writing service worker... 
{ stripPrefix: 'build/unbundled',
  staticFileGlobs: 
   [ 'build/unbundled/index.html',
     'build/unbundled/src/test_app-app/test_app-app.html',
     'build/unbundled/bower_components/polymer/polymer.html',
     'build/unbundled/bower_components/polymer/polymer-mini.html',
     'build/unbundled/bower_components/polymer/polymer-micro.html',
     'build/unbundled/bower_components/polymerfire/firebase-app.html',
     'build/unbundled/bower_components/polymerfire/firebase.html',
     'build/unbundled/bower_components/webcomponentsjs/webcomponents-lite.js',
     'build/unbundled/bower_components/firebase/firebase.js' ],
  logger: [Function: bound _log] }
debug:   Total precache size is about 482.41 kB for 9 resources.
debug:   accept: ../../../../../bower_components/firebase/firebase.js
error:   Promise rejection: Error: file path is not in root: /bower_components/firebase/firebase.js (/Users/User/Documents/WebCopilot/test_app)
error:   Error: file path is not in root: /bower_components/firebase/firebase.js (/Users/User/Documents/WebCopilot/test_app)
    at Object.urlFromPath (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/path-transformers.js:41:15)
    at StreamAnalyzer.getFile (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:107:39)
    at StreamResolver.accept (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:210:34)
    at FileLoader.request (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/lib/loader/file-loader.js:64:27)
    at Object.<anonymous> (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/vulcanize/lib/vulcan.js:318:26)
    at Array.map (native)
    at Object.inlineScripts (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/vulcanize/lib/vulcan.js:311:34)
    at Object.<anonymous> (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/vulcanize/lib/vulcan.js:458:21)
    at run (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:87:22)
    at /usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:100:28
error:   Promise rejection: Error: file path is not in root: /bower_components/firebase/firebase.js (/Users/User/Documents/WebCopilot/test_app)
error:   Error: file path is not in root: /bower_components/firebase/firebase.js (/Users/User/Documents/WebCopilot/test_app)
    at Object.urlFromPath (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/path-transformers.js:41:15)
    at StreamAnalyzer.getFile (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:107:39)
    at StreamResolver.accept (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:210:34)
    at FileLoader.request (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/lib/loader/file-loader.js:64:27)
    at Object.<anonymous> (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/vulcanize/lib/vulcan.js:318:26)
    at Array.map (native)
    at Object.inlineScripts (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/vulcanize/lib/vulcan.js:311:34)
    at Object.<anonymous> (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/vulcanize/lib/vulcan.js:458:21)
    at run (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:87:22)
    at /usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:100:28
Users-MacBook-Pro-2:test_app User$ 

Hmm, this seems verrrrry similar to #369 (see accept: ../../../../../bower_components/firebase/firebase.js in the output above).

I'll spend a bit more time looking into this now that we have a new reproduction case, but as mentioned in that issue the error seems to be coming from hydrolosis/polymer-analyzer and not polymer-cli or polymer-build. That library is going through a major refactoring as we speak, so we may want to wait for that to land before fixing (and cross our fingers that the refactor fixes this automatically).

WORKAROUND

Actually I noticed the same as @ergo here. If in index.html you change main app import path to relative, it works fine.

<!--not working-->
<link rel="import" href="/src/test_app-app/test_app-app.html">
<!--works-->
<link rel="import" href="src/test_app-app/test_app-app.html">

@iSuslov See my response here: https://github.com/Polymer/polymer-cli/issues/369#issuecomment-241885235

If that's your index.html and you're serving that page from anywhere besides the website root path, you'll run into issues.

@iSuslov Same issue when using polymer init to create a blank application template. Build will succeed until I add my first import from bower_components, then I have to remove the / before src.

Update: we're still working on the new analyzer which should fix this issue.

@barkerb1: What is the聽URL of your "first import from bower_components" and where do you add it? Is it a non-polymerfire element?

/cc @garlicnation @usergenic

@iSuslov What's the directory layout of your application? Where is the file with the absolute/relative import stored relative to the main app import?

Nah it was just a toggle button I was importing.

@garlicnation Not sure I've got your question, but file with import is index.html that is generated by polymer init application

Jan 1 2017 with everything current - same problem - and same workaround works. FYI.

Even when I do the simplest login example per polycast 57 (https://www.youtube.com/watch?v=SkhCs-IDgS4&list=PLNYkxOF6rcIDdS7HWIC_BYRunV6MHs5xo) I can succeed at either 'polymer build' or 'polymer serve' but never both.

Given that the index references the landing page which in turn references the login element, somewhere all those relative paths try to force the build to look for the firebase.js in ../../../../../bower_components/firebase/firebase-app.js, which of course is two directories off. But I can't find a way to fix the build, without making polymer serve fail to serve up the login element.

I've only been trying different relative and absolute combinations for an hour or so, maybe there is some super magical combination that would allow both to work but I just haven't found it yet.

Hah! This is a convoluted journey, but it is the Polymer CLI, sorta, that's the problem. As follows.

Issue #369 explains that the problem is fixed by using the polymer.json file.

After trying to learn how to use this file in the docs, I found one already done. It was in the polymerCLI's Starter Kit generated file. (I had been using the simpler application generated file). Indeed it fixed the problem, as advertised.

Logic would suggest that including the appropriate polymer.json file in the "application" templates would solve the problem for folks such as myself that are starting with that template set.

Yup, unfortunately this was a pretty low-level issue that got caught up in our tooling rewrite. It is fixed in the 'next' version of the CLI ('npm install -g polymer-cli@next') and should be available on 'latest' soon.

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

Related issues

lpellegr picture lpellegr  路  4Comments

rasto68 picture rasto68  路  4Comments

davidmaxwaterman picture davidmaxwaterman  路  4Comments

emilbillberg picture emilbillberg  路  3Comments

web-padawan picture web-padawan  路  4Comments