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

Parcel 2.0.0 not reloading page on change anymore (Parcel 2.0.0-rc.0 still works fine) #7241

Closed
ayebear opened this issue Nov 3, 2021 · 9 comments · Fixed by #7514
Closed
Assignees
Labels

Comments

@ayebear
Copy link

ayebear commented Nov 3, 2021

🐛 bug report

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

.parcelrc

{
  "extends": [
    "@parcel/config-default"
  ],
  "reporters": [
    "...",
    "parcel-reporter-static-files-copy"
  ],
  "resolvers": [
    "@parcel/resolver-glob",
    "..."
  ],
  "transformers": {
    "*.{js,mjs,jsx,cjs,ts,tsx}": [
      "@parcel/transformer-js"
    ]
  }
}

package.json relevant lines

"@parcel/core": "^2.0.0",
"@parcel/resolver-glob": "^2.0.0",
"@parcel/transformer-image": "^2.0.0",
"parcel": "^2.0.0",
"parcel-reporter-static-files-copy": "^1.3.0",

🤔 Expected Behavior

Page should reload when editing a file.

😯 Current Behavior

Nothing changes, but the browser console gets cleared. No new code gets injected. Have to manually refresh to see code changes.

💁 Possible Solution

No idea how to fix this, but I suspect it's related to this if statement branching differently between 2.0.0 and 2.0.0-rc.0:
https://github.com/parcel-bundler/parcel/blob/v2.0.0/packages/runtimes/hmr/src/loaders/hmr-runtime.js#L113

Downgrading my packages to 2.0.0-rc.0 corrects the issue for me.

🔦 Context

This is for a pixi.js game project.

💻 Code Sample

I'll try to make a minimal example later that reproduces this issue.

🌍 Your Environment

Software Version(s)
Parcel 2.0.0
Node 16.12.0
Yarn 1.22.15
Operating System Linux Mint
@ayebear
Copy link
Author

ayebear commented Nov 3, 2021

Looks like #6685 is similar, however, there are no errors, even when preserving the log, just console cleared.

@Warry
Copy link
Contributor

Warry commented Nov 3, 2021

I have the same behaviour (using a proxyrc file and commonJs require() in the project) since I upgraded to 2.0.0 from rc and these plugins:

        "@parcel/plugin": "^2.0.0",
        "@parcel/transformer-elm": "^2.0.0",
        "@parcel/transformer-image": "^2.0.0",

no error, it silently fails.

@JaredSartin
Copy link

Same, it's rather annoying.

"@parcel/core": "2.0.0",
"@parcel/resolver-glob": "2.0.0",
"parcel": "2.0.0",

@ayebear
Copy link
Author

ayebear commented Nov 5, 2021

The changes made to the hmrAcceptCheck function in this commit are a bit sus: 7468864#diff-fa61a8f9c88b99c211b1544b5549ddc7137a02632c9fa8486875101aba57c356R337

But I am not 100% certain, there are many other factors that could affect it.

@ideaOwl
Copy link

ideaOwl commented Nov 10, 2021

I'm having this same problem too. Running the RC gets reloading to work again, though other issues arise.

Parcel 2.0.1 is what I currently have, and I've noticed that including classic JS files (not ES modules) is what causes reloading to not happen anymore. Trying this (#1591 (comment)) gets reloading to work, but I don't want to have to rewrite my code to get things to work again.

@devongovett devongovett added the HMR Hot Module Reloading label Nov 16, 2021
@devongovett devongovett self-assigned this Nov 16, 2021
@megaphonecolin
Copy link

megaphonecolin commented Nov 23, 2021

We are also having this problem. Like ideaOwl commented, we have classic JavaScript files linked with type="text/javascript" in our main entry point (index.html). The linked .js files are, however, from a third party, so we cannot add any code to them. Furthermore, our app is not compiled correctly by Parcel 2.0.0-rc.0, so I can't determine whether this issue occurs for us in rc.0. When rc.0 compiles our app, the objects created in our classic .js files are not found at runtime.

Thanks in advance for any help/fix.

@GeorgeFlorian
Copy link

GeorgeFlorian commented Nov 30, 2021

I can confirm that this does not work for me as well.
I'm using "parcel": "^2.0.1" on VSC, on Ubuntu 20.04 LTS on a very simple and bare-boned structure.

{
  "name": "forkify-app",
  "version": "1.0.0",
  "description": "",
  "default": "index.html",
  "scripts": {
    "start": "parcel index.html",
    "build": "parcel build index.html"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/GeorgeFlorian/Forkify-App.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/GeorgeFlorian/Forkify-App/issues"
  },
  "homepage": "https://github.com/GeorgeFlorian/Forkify-App#readme",
  "devDependencies": {
    "@parcel/transformer-sass": "^2.0.1",
    "parcel": "^2.0.1"
  }
}

I have first tried running the script with the --no-cache option but to no avail.

I have changed from <script defer src="src/js/controller.js"</script> to <script defer src="src/js/controller.js" type="module"></script> and it started working for just one .js file.

Then I've created new .js files that I import inside controller.js. Changes made in those files do not reflect in the page. I have to manually reload the page in order to see the changes.

This bug kills productivity when you're trying to watch tutorials and you do the exact same things as the tutor, but it doesn't work as expected and then you have to search endlessly for a solution.

@ayebear
Copy link
Author

ayebear commented Dec 6, 2021

I ended up upgrading to parcel 2.0.1 and just including this in my main js file:

if (module.hot) {
  module.hot.accept(() => {
    location.reload()
  })
}

Which works for now. But, the default behavior should be either working HMR or page reload.

@megaphonecolin
Copy link

Any update on this issue? @ayebear's fix does not seem to work for us.

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

Successfully merging a pull request may close this issue.

8 participants