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

Page reload doesn't work with lit-element #2675

Closed
LasseRosenow opened this issue Feb 23, 2019 · 1 comment · Fixed by #2676
Closed

Page reload doesn't work with lit-element #2675

LasseRosenow opened this issue Feb 23, 2019 · 1 comment · Fixed by #2676
Labels
❔ Question HMR Hot Module Reloading

Comments

@LasseRosenow
Copy link

🐛 bug report

Im working on a simple single page application build with lit-element. I bundle everything together using parcel and that works pretty good. But in live development, whenever I change something inside of a custom element, the page won't refresh and I geht this issue:
"Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': this name has already been used with this registry"

🎛 Configuration (.babelrc, package.json, cli command)

{
  "scripts": {
    "dev": "parcel watch src/index.html",
    "start": "parcel src/index.html",
    "build": "parcel build src/index.html"
  },
  "dependencies": {
    "lit-element": "^2.0.1",
    "lit-element-router": "^1.0.0"
  },
  "devDependencies": {
    "parcel-bundler": "^1.11.0"
  },
  "browserslist": [
    "Chrome 72"
  ]
}

🤔 Expected Behavior

The custom element should be reloaded and I should just see the changes I made.

😯 Current Behavior

I get this error message instead:
"Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': this name has already been used with this registry"
And there is no reload. If I refresh the page myself, everything works just fine... until I change something else.

💁 Possible Solution

No idea :(

🔦 Context

I also tried out my project on webpack and everything works there, except I don't like how webpack manages assets etc.
So it seems to be a parcel issue.

💻 Code Sample

🌍 Your Environment

Software Version(s)
Parcel 1.11.0
Node 11.10.0
npm 6.7.0
Operating System Windows 10
@mischnic
Copy link
Member

I'm guessing you have a call like this somewhere in your project: customElements.define('popup-info', PopUpInfo); and don't have hot module reloading enabled in your webpack config.

I think webpack reloads the whole page by default while Parcel does hot reloading (in this case re-execute the Javascript). #289 (comment) describes how to setup your project to reload the page completely without HMR: add this

if (module.hot) {
  module.hot.accept(function () {
    window.location.reload();
  });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❔ Question HMR Hot Module Reloading
Projects
None yet
2 participants