Skip to content

Commit 16ca0ad

Browse files
authored
Merge pull request #1115 from Patternslib/separate-modernizr
Separate modernizr
2 parents a12d467 + 2bc52dd commit 16ca0ad

File tree

7 files changed

+136
-229
lines changed

7 files changed

+136
-229
lines changed

.modernizrrc.js

Lines changed: 97 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1,167 +1,99 @@
11
module.exports = {
2-
"classPrefix": "",
3-
"options": [
4-
"addTest",
5-
"atRule",
6-
"domPrefixes",
7-
"hasEvent",
8-
"html5shiv",
9-
"html5printshiv",
10-
"load",
11-
"mq",
12-
"prefixed",
13-
"prefixes",
14-
"prefixedCSS",
15-
"setClasses",
16-
"testAllProps",
17-
"testProp",
18-
"testStyles"
19-
],
20-
"feature-detects": [
21-
"a/download",
22-
"applicationcache",
23-
"blob",
24-
"canvas",
25-
"canvas/blending",
26-
"canvas/todataurl",
27-
"canvas/winding",
28-
"canvastext",
29-
"contenteditable",
30-
"contextmenu",
31-
"cookies",
32-
"cors",
33-
"custom-elements",
34-
"css/all",
35-
"css/animations",
36-
"css/appearance",
37-
"css/backdropfilter",
38-
"css/backgroundblendmode",
39-
"css/backgroundcliptext",
40-
"css/backgroundposition-shorthand",
41-
"css/backgroundposition-xy",
42-
"css/backgroundrepeat",
43-
"css/backgroundsize",
44-
"css/backgroundsizecover",
45-
"css/borderimage",
46-
"css/borderradius",
47-
"css/boxshadow",
48-
"css/boxsizing",
49-
"css/calc",
50-
"css/checked",
51-
"css/chunit",
52-
"css/columns",
53-
"css/cssgrid",
54-
"css/cubicbezierrange",
55-
"css/displayrunin",
56-
"css/displaytable",
57-
"css/ellipsis",
58-
"css/escape",
59-
"css/exunit",
60-
"css/filters",
61-
"css/flexbox",
62-
"css/flexboxlegacy",
63-
"css/flexboxtweener",
64-
"css/flexwrap",
65-
"css/fontface",
66-
"css/generatedcontent",
67-
"css/gradients",
68-
"css/hairline",
69-
"css/hsla",
70-
"css/invalid",
71-
"css/lastchild",
72-
"css/mask",
73-
"css/mediaqueries",
74-
"css/multiplebgs",
75-
"css/nthchild",
76-
"css/objectfit",
77-
"css/opacity",
78-
"css/overflow-scrolling",
79-
"css/pointerevents",
80-
"css/positionsticky",
81-
"css/pseudoanimations",
82-
"css/pseudotransitions",
83-
"css/reflections",
84-
"css/regions",
85-
"css/remunit",
86-
"css/resize",
87-
"css/rgba",
88-
"css/scrollbars",
89-
"css/scrollsnappoints",
90-
"css/shapes",
91-
"css/siblinggeneral",
92-
"css/subpixelfont",
93-
"css/supports",
94-
"css/target",
95-
"css/textalignlast",
96-
"css/textshadow",
97-
"css/transforms",
98-
"css/transformslevel2",
99-
"css/transforms3d",
100-
"css/transformstylepreserve3d",
101-
"css/transitions",
102-
"css/userselect",
103-
"css/valid",
104-
"css/vhunit",
105-
"css/vmaxunit",
106-
"css/vminunit",
107-
"css/vwunit",
108-
"css/will-change",
109-
"css/wrapflow",
110-
"dom/classlist",
111-
"dom/createElement-attrs",
112-
"dom/dataset",
113-
"dom/documentfragment",
114-
"dom/hidden",
115-
"dom/microdata",
116-
"dom/mutationObserver",
117-
"dom/passiveeventlisteners",
118-
"event/deviceorientation-motion",
119-
"event/oninput",
120-
"eventlistener",
121-
"exif-orientation",
122-
"forms/capture",
123-
"forms/fileinput",
124-
"forms/fileinputdirectory",
125-
"forms/formattribute",
126-
"forms/placeholder",
127-
"forms/requestautocomplete",
128-
"forms/validation",
129-
"inputtypes",
130-
"fullscreen-api",
131-
"hashchange",
132-
"hiddenscroll",
133-
"history",
134-
"htmlimports",
135-
"iframe/sandbox",
136-
"iframe/seamless",
137-
"iframe/srcdoc",
138-
"json",
139-
"mediaquery/hovermq",
140-
"mediaquery/pointermq",
141-
"notification",
142-
"pagevisibility-api",
143-
"performance",
144-
"postmessage",
145-
"proximity",
146-
"queryselector",
147-
"requestanimationframe",
148-
"storage/localstorage",
149-
"storage/sessionstorage",
150-
"storage/websqldatabase",
151-
"touchevents",
152-
"unicode",
153-
"unicode-range",
154-
"url/bloburls",
155-
"url/data-uri",
156-
"url/parser",
157-
"url/urlsearchparams",
158-
"userdata",
159-
"vibration",
160-
"video",
161-
"video/autoplay",
162-
"video/crossorigin",
163-
"video/loop",
164-
"video/preload",
165-
"xdomainrequest"
166-
]
2+
"classPrefix": "",
3+
"enableClasses": true,
4+
"enableJSClass": true,
5+
"options": ["setClasses"],
6+
"feature-detects": [
7+
"a/download",
8+
"css/all",
9+
"css/animations",
10+
"css/appearance",
11+
"css/backdropfilter",
12+
"css/backgroundblendmode",
13+
"css/backgroundcliptext",
14+
"css/backgroundposition-shorthand",
15+
"css/backgroundposition-xy",
16+
"css/backgroundrepeat",
17+
"css/backgroundsize",
18+
"css/backgroundsizecover",
19+
"css/borderimage",
20+
"css/borderradius",
21+
"css/boxshadow",
22+
"css/boxsizing",
23+
"css/calc",
24+
"css/checked",
25+
"css/chunit",
26+
"css/columns",
27+
"css/cssgrid",
28+
"css/cubicbezierrange",
29+
"css/displayrunin",
30+
"css/displaytable",
31+
"css/ellipsis",
32+
"css/escape",
33+
"css/exunit",
34+
"css/filters",
35+
"css/flexbox",
36+
"css/flexboxlegacy",
37+
"css/flexboxtweener",
38+
"css/flexwrap",
39+
"css/fontface",
40+
"css/generatedcontent",
41+
"css/gradients",
42+
"css/hairline",
43+
"css/hsla",
44+
"css/invalid",
45+
"css/lastchild",
46+
"css/mask",
47+
"css/mediaqueries",
48+
"css/multiplebgs",
49+
"css/nthchild",
50+
"css/objectfit",
51+
"css/opacity",
52+
"css/overflow-scrolling",
53+
"css/pointerevents",
54+
"css/positionsticky",
55+
"css/pseudoanimations",
56+
"css/pseudotransitions",
57+
"css/reflections",
58+
"css/regions",
59+
"css/remunit",
60+
"css/resize",
61+
"css/rgba",
62+
"css/scrollbars",
63+
"css/scrollsnappoints",
64+
"css/shapes",
65+
"css/siblinggeneral",
66+
"css/subpixelfont",
67+
"css/supports",
68+
"css/target",
69+
"css/textalignlast",
70+
"css/textshadow",
71+
"css/transforms",
72+
"css/transformslevel2",
73+
"css/transforms3d",
74+
"css/transformstylepreserve3d",
75+
"css/transitions",
76+
"css/userselect",
77+
"css/valid",
78+
"css/vhunit",
79+
"css/vmaxunit",
80+
"css/vminunit",
81+
"css/vwunit",
82+
"css/will-change",
83+
"css/wrapflow",
84+
"event/deviceorientation-motion",
85+
"exif-orientation",
86+
"forms/capture",
87+
"forms/fileinput",
88+
"forms/validation",
89+
"inputtypes",
90+
"fullscreen-api",
91+
"hiddenscroll",
92+
"mediaquery/hovermq",
93+
"mediaquery/pointermq",
94+
"touchevents",
95+
"vibration",
96+
"video/autoplay",
97+
"video/loop",
98+
],
16799
};

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<!DOCTYPE html>
2-
<html>
2+
<html class="no-js">
33
<head>
44
<title>Patterns demo pages</title>
55
<meta charset="utf-8">
66
<link rel="stylesheet" href="/style/common.css" />
7+
<script src="/modernizr.min.js"></script>
78
<script src="/bundle.min.js"></script>
89
</head>
910
<body class="component-index">

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
"@patternslib/pat-tiptap": "^4.7.2",
4545
"@patternslib/pat-upload": "^3.1.1",
4646
"copy-webpack-plugin": "^11.0.0",
47-
"pegjs": "0.11.0-master.b7b87ea",
48-
"webpack-modernizr-loader": "^5.0.0"
47+
"modernizr": "^3.12.0",
48+
"pegjs": "0.11.0-master.b7b87ea"
4949
},
5050
"resolutions": {
5151
"jquery": "3.6.2"

src/pat/clone-code/index.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
<title>pat-clone demo page</title>
55
<meta charset="utf-8">
66
<link rel="stylesheet" href="/style/common.css" />
7-
<script>
8-
window.__patternslib_disable_modernizr = true;
9-
</script>
107
<script src="/bundle.min.js"></script>
118
</head>
129
<body>
@@ -34,6 +31,5 @@ <h2>Example 2</h2>
3431
<p>Test paragraph</p>
3532
</div>
3633

37-
3834
</body>
3935
</html>

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: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const mf_config = require("@patternslib/dev/webpack/webpack.mf");
55
const package_json = require("../package.json");
66
const path = require("path");
77
const webpack_config = require("@patternslib/dev/webpack/webpack.config").config;
8+
const modernizr_config = require("../.modernizrrc.js");
9+
const modernizr = require("modernizr");
810

911
module.exports = () => {
1012
let config = {
@@ -20,15 +22,6 @@ module.exports = () => {
2022

2123
config.output.path = path.resolve(__dirname, "../dist/");
2224

23-
// Modernizr
24-
config.module.rules.push({
25-
test: /\.modernizrrc\.js$/,
26-
loader: "webpack-modernizr-loader",
27-
});
28-
config.resolve.alias = {
29-
modernizr$: path.resolve(__dirname, "../.modernizrrc.js"),
30-
};
31-
3225
// Module federation
3326
config.plugins.push(
3427
mf_config({
@@ -49,14 +42,41 @@ module.exports = () => {
4942
})
5043
);
5144

52-
// BBB polyfills not used anymore.
53-
// TODO: Remove for next major version.
54-
// Polyfills
45+
// Copy static files
5546
config.plugins.push(
56-
// Copy polyfills loader to the output path.
5747
new CopyPlugin({
5848
patterns: [
59-
{ from: path.resolve(__dirname, "../src/polyfills-loader.js"), }, // prettier-ignore
49+
// Copy polyfills loader to the output path.
50+
// TODO: Polyfills not used anymore, remove for next major version.
51+
{ from: path.resolve(__dirname, "../src/polyfills-loader.js") },
52+
53+
// Build and copy Modernizr.
54+
// We're abusing the CopyPlugin transform method here to build
55+
// a Modernizr bundle using the modernizr config. The input
56+
// file does not matter and could be anything - we're using the
57+
// modernizr config itself.
58+
// Why building modernizr here and not in the Makefile?
59+
// Because we want webpack-dev-server also to serve it.
60+
{
61+
from: path.resolve(__dirname, "../.modernizrrc.js"),
62+
to: "[path]modernizr.min.js",
63+
transform: {
64+
transformer: () => {
65+
return new Promise((resolve) => {
66+
modernizr.build(
67+
{
68+
...modernizr_config,
69+
minify: process.env.NODE_ENV === "production",
70+
},
71+
(result) => {
72+
resolve(result);
73+
}
74+
);
75+
});
76+
},
77+
cache: true,
78+
},
79+
},
6080
],
6181
})
6282
);

0 commit comments

Comments
 (0)