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

[Feature request] provide more context for lastResortScript #37

Open
Rush opened this issue Dec 16, 2021 · 1 comment
Open

[Feature request] provide more context for lastResortScript #37

Rush opened this issue Dec 16, 2021 · 1 comment

Comments

@Rush
Copy link

Rush commented Dec 16, 2021

Thanks for building this plugin! My users suffer from intermittent issues loading the async chunks so this will provide some relief.

I just set the lastResetScript to the following.

      lastResortScript: `(${(function(chunkId: string) {
        alert('Sorry, we couldn\'t load required script \'' + chunkId + '\'. Please contact support if the issue persists');
      }).toString()})(chunkId);`,

But it seems only chunkId is available in the context. Some of my chunks are actually not critical if they fail, in such case I would like to provide an alternative message:

      lastResortScript: `(${(function(chunkId: string, chunkName: string) {
        if (chunkName.startsWith('opt-')) {
          // provide some softer error than alert
        } else
          alert('Sorry, we couldn\'t load required script \'' + chunkId + '\'. Please contact support if the issue persists');
        }
      }).toString()})(chunkId, chunkName);`,

Thanks again!

@lk77
Copy link

lk77 commented Jun 24, 2022

Hello,

i have the same issue, and there is actually more data you can access:

realSrc will give you the path of the chunks like : js/chunks/home.js
error will give you the string of the error as printed in the console.warn

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

No branches or pull requests

2 participants