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 [serve] --lazy fails to load an async bundle under certain conditions #8816

Closed
rayinaway opened this issue Feb 6, 2023 · 1 comment

Comments

@rayinaway
Copy link

rayinaway commented Feb 6, 2023

🐛 bug report

parcel [serve] fails to load an async bundle under the following conditions:

  • --lazy flag is set.
  • Along with the async bundle, the parent module statically imports some other module.
  • Parcel cache has not been created yet.

These conditions seem exhaustive, a minimal repro below reflects that. After the cache is created, the next HMR invocation resolves the issue.

🎛 Configuration

Apart from the --lazy flag, out-of-the-box Parcel.

🤔 Expected Behavior

When the async bundle is requested, Parcel's development server responds with it.

😯 Current Behavior

When the async bundle is requested, the server responds with index.html as a fallback instead, and a SyntaxError from failed parsing is thrown.

dynamic.51313f62.js:1 Uncaught SyntaxError: Unexpected token '<'
index.63aff760.js:61 Uncaught (in promise) Error: Cannot find module 'kmWTC'
    at newRequire (index.63aff760.js:61:19)
    at Function.newRequire (index.63aff760.js:45:18)
    at runtime-647fb96160fc59b6.js:1:248

💁 Possible Solution

Might be related to how Parcel initializes the cache.

🔦 Context

Faced the issue when tried to dynamically import app-specific devtools under certain conditions only.

💻 Code Sample

https://github.com/rayinaway/lazy-serve-parcel-bug-repro

🌍 Your Environment

Software Version(s)
Parcel 2.8.3
Node 16.13.2
npm 8.1.2
Operating System Windows 10
@marcins
Copy link
Contributor

marcins commented Jul 31, 2023

This should be fixed by #9093.

@marcins marcins closed this as completed Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants