Skip to content

Commit ee2c893

Browse files
committed
breaking(Build): Separate modernizr into a own bundle.
Since Patternslib 9.0.0-alpha.0 where we introduced webpack module federation for our bundles, Modernizr is loaded asynchronously and applying it's CSS classes a tick too late. For example, the change from the `no-js` to the `js` class was done while the tiles have already been drawn and visible on the screen, resulting in screen flickering. There are a number of projects which depend on Modernizr being applied early. This change now fixes the problem by separating the Modernizr build from the Patternslib bundle. If you depend on Modernzir, please include the new `modernizr.min.js` bundle in a script tag, preferably before the Patternslib bundle `bundle.min.js`.
1 parent a12d467 commit ee2c893

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/modernizr.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Include modernizr for a modernizr bundle.
2+
// To use it in your project, include the `modernizr.min.js` bundle in a script
3+
// tag. This is for projects where styles depend on specific modernizr features
4+
// like the change from a `no-js` class to a `js` class.
5+
import("modernizr");

src/patterns.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,4 @@ import "@patternslib/pat-upload";
7474
// Set to ``true`` to include core styles via JavaScript
7575
//window.__patternslib_import_styles = false;
7676

77-
// Include modernizr per default.
78-
// Most of our styles depend on it.
79-
// You might want to disable it for your project by setting:
80-
// window.__patternslib_disable_modernizr = true;
81-
if (!window.__patternslib_disable_modernizr) {
82-
import("modernizr");
83-
}
84-
8577
registry.init();

webpack/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = () => {
1010
let config = {
1111
entry: {
1212
"bundle.min": path.resolve(__dirname, "../src/index.js"),
13+
"modernizr.min": path.resolve(__dirname, "../src/modernizr.js"),
1314
},
1415
};
1516

0 commit comments

Comments
 (0)