Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some script imports don't work when vulcanizing #706

Closed
lavelle opened this issue Aug 13, 2014 · 6 comments
Closed

Some script imports don't work when vulcanizing #706

lavelle opened this issue Aug 13, 2014 · 6 comments
Assignees
Labels

Comments

@lavelle
Copy link

lavelle commented Aug 13, 2014

This is the issue that lead to me discovering #705. When running a Polymer app through vulcanize with both the --csp and --inline flags, external scripts won't be imported into the component.

So, in a component,

<polymer-element name="my-foo">
    <script>
        Polymer('my-foo', {});
    </script>
</polymer-element>

will work, but

<polymer-element name="my-foo">
    <script src="my-foo.js"></script>
</polymer-element>

where my-foo.js contains

Polymer('my-foo', {});

will not work.

@lavelle
Copy link
Author

lavelle commented Aug 13, 2014

cc @jmuk

@arthurevans
Copy link

What are you trying to do? --csp pulls inline scripts out into separate scripts. --inline pulls separate scripts inline. So it seems like they'd be mutually exclusive.

@lavelle
Copy link
Author

lavelle commented Aug 13, 2014

According to the readme at https://github.com/Polymer/vulcanize, running with --inline --csp will "Bundle all javascript (inline and external) into <output file name>.js".

I'm making a Chrome extension, so external scripts need to be inlined to prevent CSP errors. However, there are still some inline scripts in my project too, and if you don't also have the --inline flag these will not be included in the generated build.js file.

@arthurevans
Copy link

Sorry, my mistake. So, if this isn't working, it sounds like either a bug or a problem with your project setup. Are the paths to the external files relative paths that vulcanize can resolve? I've noticed that if they're absolute paths that would resolve correctly through the webserver, vulcanize can't include them.

(That is, if you have my-site/components/my-foo.html that references /components/my-foo.js, vulcanize won't include the JS, because it doesn't know where the web root is.)

(BTW, I think it would be good if vulcanize logged a message whenever it skips an external file. It might also be nice if you could specify a relative root so that you don't have to change your paths to vulcanize a site.)

@arthurevans arthurevans assigned dfreedm and unassigned arthurevans Aug 14, 2014
@lavelle
Copy link
Author

lavelle commented Aug 14, 2014

Hmm, none of the paths are absolute, but they are outside the main project directory. Since it's an official Google project all the Polymer components have to be in third_party in the top level of the repo, but the Gruntfiles and index.htmls that import the components are in subfolders beneath that.

It would definitely be good for Vulcanize to show a warning when files are skipped.

@dfreedm dfreedm added the p1 label Aug 14, 2014
@tjsavage tjsavage added this to the beta milestone Aug 21, 2014
@tjsavage tjsavage added the 0.5 label May 21, 2015
@sorvell sorvell removed the p1 label Jun 25, 2015
@tjsavage
Copy link
Contributor

Closing this issue due to age and the release of version 1 of Polymer - please feel free to re-open if this is incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants