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

Fix integrity error when currentAsset is undefined 🐛 #10

Merged
merged 2 commits into from
Apr 16, 2019

Conversation

ngocphuongnb
Copy link
Contributor

Description

Fix error: Cannot read property 'integrity' of undefined

Why

In case of using react-loadable-ssr-addon with dynamic imported component; when a component is removed from the project, react-loadable-ssr-addon throw error because currentAsset file is missing, we need to check currentAsset variable before getting it's integrity

my-project/node_modules/react-loadable-ssr-addon/lib/ReactLoadableSSRAddon.js:193
            integrity: currentAsset[_this.options.integrityPropertyName]
                                   ^

TypeError: Cannot read property 'integrity' of undefined
    at my-project/node_modules/react-loadable-ssr-addon/lib/ReactLoadableSSRAddon.js:193:36
    at Map.forEach (<anonymous>)
    at ReactLoadableSSRAddon.processAssets (my-project/node_modules/react-loadable-ssr-addon/lib/ReactLoadableSSRAddon.js:151:23)
    at ReactLoadableSSRAddon.handleEmit (my-project/node_modules/react-loadable-ssr-addon/lib/ReactLoadableSSRAddon.js:140:10)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (my-project/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:7:1)
    at Compiler.emitAssets (my-project/node_modules/webpack/lib/Compiler.js:441:19)
    at onCompiled (my-project/node_modules/webpack/lib/Watching.js:50:19)
    at hooks.afterCompile.callAsync.err (my-project/node_modules/webpack/lib/Compiler.js:630:14)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (my-project/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
    at compilation.seal.err (my-project/node_modules/webpack/lib/Compiler.js:627:30)

@ngocphuongnb ngocphuongnb changed the title Fix integrity error when currentAsset is undefined 🐛 Fix integrity error when currentAsset is undefined 🐛 Apr 12, 2019
@ngocphuongnb ngocphuongnb reopened this Apr 12, 2019
@themgoncalves themgoncalves self-requested a review April 12, 2019 07:56
@themgoncalves themgoncalves added the bug Something isn't working label Apr 12, 2019
Copy link
Owner

@themgoncalves themgoncalves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nguyenngocphuongnb thanks for the contribution, you bough for us an interesting fix.

I just suggested another and simpler approach to this issue, could you please update as requested and test again?

source/ReactLoadableSSRAddon.js Outdated Show resolved Hide resolved
Copy link
Owner

@themgoncalves themgoncalves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@themgoncalves themgoncalves merged commit 43c325e into themgoncalves:master Apr 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants