forked from magento/pwa-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature]: Lazy Load/trim unused bytes in main routes (magento#2988)
* Remove unused templates directory Signed-off-by: sirugh <[email protected]> * Lazy load components and modals that arent necessary on first render Signed-off-by: sirugh <[email protected]> * Add react-lazy mock so we can keep using snapshot testing to assert Signed-off-by: sirugh <[email protected]> * remove instanbul... Signed-off-by: sirugh <[email protected]> * add comment Signed-off-by: sirugh <[email protected]> * Update snaps and tostring code to just pull out component import Signed-off-by: sirugh <[email protected]> * Add loading indicator to cart accordion blocks for slow network Signed-off-by: sirugh <[email protected]> * fix snap Signed-off-by: sirugh <[email protected]> Co-authored-by: Devagouda <[email protected]>
- Loading branch information
1 parent
9c08247
commit 9c4e558
Showing
47 changed files
with
444 additions
and
490 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
|
||
// React.lazy compiles the "import" to a "require". | ||
const lazyImportPathRegex = new RegExp(/require\('.*?'\)/); | ||
|
||
module.exports = { | ||
...React, | ||
lazy: fn => { | ||
// Rather than just return the entire stringified function, we want to | ||
// return the component imported. We do this "toString" contains | ||
// coverage instrumentation comments. | ||
const fnString = fn.toString(); | ||
const match = fnString.match(lazyImportPathRegex); | ||
return match ? match[0] : fnString; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ Array [ | |
item="3" | ||
/> | ||
</ul>, | ||
<EditModal />, | ||
<require('./EditModal') />, | ||
] | ||
`; | ||
|
||
|
Oops, something went wrong.