Firebase serve not working with module import (polymer 3)
See original GitHub issueI’m trying to create a polymer 3 app and have it hosted using firebase hosting, and for my dev im using firebase tool in order to try test thing up locally before production. When i try to serve my app using firebase serve
command everything is appearing to work okay:
Serving from '/Users/Terence/Desktop/BaseScholar'...
- i hosting: Serving hosting files from: public
- ✔ hosting: Local server: http://localhost:5000
When I open the browser nothing is showing, and in my console
im getting this error:
Uncaught TypeError: Failed to resolve module specifier "@polymer/polymer/polymer-element.js". Relative references must start with either "/", "./", or "../".
Part of the code in my index.hmtl
file:
<html lang="en">
<head>
<title>BaseScholar</title>
<script src="https://www.gstatic.com/firebasejs/5.0.4/firebase.js"></script>
<script>
// initialize firebase app
var config = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
projectId: "<PROJECT_ID>",
storageBucket: "<BUCKET>.appspot.com",
messagingSenderId: "<SENDER_ID>"
};
firebase.initializeApp(config);
</script>
<!-- Load webcomponents-loader.js to check and load any polyfills your browser needs -->
<script src="node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
<script src="node_modules/web-animations-js/web-animations-next-lite.min.js"></script>
<script type="module" src="src/elements/basescholar-app.js"></script>
<!-- Add any global styles for body, document, etc. -->
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body unresolved>
<!-- Instantiate the BaseScholar app: -->
<basescholar-app></basescholar-app>
<noscript>
Please enable Javascript in order access the application
</noscript>
</body>
</html>
I’m building and running the app on MacOS High Sierra. Browser (Google Chrome v67).
How can I resolve this?
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (2 by maintainers)
So I built the app as @CaptainCodeman advised and got rid of the
**/node_modules/*
according to @yanchespenda and everything starts working perfectly fine now - I can now deploy my app to firebase, problem solved!!. Thanks very much guys@mbleigh I understand that the server is not opinionated about stacks. However, the ground issue here is simply the use of NPM packages in front-end dev environnements. And this is not just limited to one specific stack. We should be able to specify import resolution to use NodeJs resolution
My approach for now is to take a look at how
firebase serve
and superstatic are working. As of now it seems to me that it does not provide as much middleware insertion point as I wanted (but it may need more investigation with the express + superstatics as middleware approach).The big pain point is that my whole app is built on Firebase + Polymer tech, and taking advantage of the new releases is not really possible without the hot reloading we currently enjoy with
firebase serve
. Well, maybe that meant I was relying too much upon once tool…