@11ty/eleventy-plugin-webc 0.11.2 → 0.12.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/eleventyWebcPlugin.js +24 -20
- package/package.json +19 -17
- package/src/eleventyWebcTemplate.js +9 -21
package/eleventyWebcPlugin.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
const eleventyBundlePlugin = require("@11ty/eleventy-plugin-bundle");
|
|
2
1
|
const pkg = require("./package.json");
|
|
3
2
|
const templatePlugin = require("./src/eleventyWebcTemplate.js");
|
|
4
3
|
const transformPlugin = require("./src/eleventyWebcTransform.js");
|
|
5
4
|
|
|
6
5
|
module.exports = function(eleventyConfig, options = {}) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
eleventyConfig.versionCheck(pkg["11ty"].compatibility);
|
|
7
|
+
|
|
8
|
+
// Error for removed filters.
|
|
9
|
+
eleventyConfig.addFilter("webcGetCss", () => {
|
|
10
|
+
throw new Error("webcGetCss was removed from @11ty/eleventy-plugin-webc. Use the `getBundle('css')` shortcode instead.")
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// Error for removed filters.
|
|
14
|
+
eleventyConfig.addFilter("webcGetJs", () => {
|
|
15
|
+
throw new Error("webcGetJs was removed from @11ty/eleventy-plugin-webc. Use the `getBundle('js')` shortcode instead.")
|
|
16
|
+
})
|
|
12
17
|
|
|
13
|
-
// Deprecated: this lives in @11ty/eleventy-plugin-bundle now
|
|
14
|
-
let filters = Object.assign({
|
|
15
|
-
css: "webcGetCss",
|
|
16
|
-
js: "webcGetJs",
|
|
17
|
-
}, options.filters);
|
|
18
18
|
|
|
19
19
|
options = Object.assign({
|
|
20
20
|
components: "_components/**/*.webc", // glob for no-import global components
|
|
@@ -27,9 +27,6 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
27
27
|
hoistDuplicateBundlesFor: ["css", "js"]
|
|
28
28
|
}, options.bundlePluginOptions);
|
|
29
29
|
|
|
30
|
-
// Deprecated: this lives in @11ty/eleventy-plugin-bundle now
|
|
31
|
-
options.filters = filters;
|
|
32
|
-
|
|
33
30
|
if(options.components) {
|
|
34
31
|
let components = options.components;
|
|
35
32
|
if(!Array.isArray(components)) {
|
|
@@ -52,12 +49,19 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
// v0.12.0 upstream
|
|
53
|
+
// `bundlePluginOptions.toFileDirectory` (via Bundle Plugin changes) default changed from "bundle" to ""
|
|
54
|
+
// https://github.com/11ty/eleventy-plugin-bundle/releases/tag/v2.0.0
|
|
55
|
+
|
|
56
|
+
eleventyConfig.addBundle("html", Object.assign({}, options.bundlePluginOptions, {
|
|
57
|
+
hoist: options.bundlePluginOptions.hoistDuplicateBundlesFor.includes("html"),
|
|
58
|
+
}));
|
|
59
|
+
eleventyConfig.addBundle("css", Object.assign({}, options.bundlePluginOptions, {
|
|
60
|
+
hoist: options.bundlePluginOptions.hoistDuplicateBundlesFor.includes("css"),
|
|
61
|
+
}));
|
|
62
|
+
eleventyConfig.addBundle("js", Object.assign({}, options.bundlePluginOptions, {
|
|
63
|
+
hoist: options.bundlePluginOptions.hoistDuplicateBundlesFor.includes("js")
|
|
64
|
+
}));
|
|
61
65
|
|
|
62
66
|
templatePlugin(eleventyConfig, options);
|
|
63
67
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@11ty/eleventy-plugin-webc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0-beta.3",
|
|
4
4
|
"description": "WebC support for Eleventy adds for Single File Web Components",
|
|
5
5
|
"main": "eleventyWebcPlugin.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
},
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"engines": {
|
|
14
|
-
"node": ">=
|
|
14
|
+
"node": ">= 18"
|
|
15
15
|
},
|
|
16
16
|
"11ty": {
|
|
17
|
-
"compatibility": ">=
|
|
17
|
+
"compatibility": ">=3.0.0"
|
|
18
18
|
},
|
|
19
19
|
"funding": {
|
|
20
20
|
"type": "opencollective",
|
|
@@ -26,28 +26,30 @@
|
|
|
26
26
|
"web-components",
|
|
27
27
|
"custom-elements"
|
|
28
28
|
],
|
|
29
|
-
"author":
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"url": "
|
|
29
|
+
"author": "Zach Leatherman <zachleatherman@gmail.com> (https://zachleat.com/)",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git://github.com/11ty/eleventy-plugin-webc.git"
|
|
33
33
|
},
|
|
34
|
+
"bugs": "https://github.com/11ty/eleventy-plugin-webc/issues",
|
|
34
35
|
"ava": {
|
|
35
36
|
"failFast": true,
|
|
36
37
|
"files": [
|
|
37
|
-
"./test/test*.js"
|
|
38
|
+
"./test/test*.js",
|
|
39
|
+
"./test/test*.mjs"
|
|
38
40
|
],
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
"watchMode": {
|
|
42
|
+
"ignoreChanges": [
|
|
43
|
+
"**/_site/**",
|
|
44
|
+
".cache"
|
|
45
|
+
]
|
|
46
|
+
}
|
|
43
47
|
},
|
|
44
48
|
"dependencies": {
|
|
45
|
-
"@11ty/
|
|
46
|
-
"@11ty/webc": "^0.11.0"
|
|
49
|
+
"@11ty/webc": "^0.11"
|
|
47
50
|
},
|
|
48
51
|
"devDependencies": {
|
|
49
|
-
"@11ty/eleventy": "^
|
|
50
|
-
"ava": "^
|
|
51
|
-
"node-retrieve-globals": "^2.0.8"
|
|
52
|
+
"@11ty/eleventy": "^3.0.0",
|
|
53
|
+
"ava": "^6.2.0"
|
|
52
54
|
}
|
|
53
55
|
}
|
|
@@ -54,20 +54,6 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
54
54
|
templateConfig = cfg;
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
// Deprecated (backwards compat only): this lives in @11ty/eleventy-plugin-bundle now
|
|
58
|
-
if(options.filters.css) {
|
|
59
|
-
eleventyConfig.addFilter(options.filters.css, (url, bucket) => {
|
|
60
|
-
return eleventyConfig.javascriptFunctions.getBundle("css", bucket);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Deprecated (backwards compat only): this lives in @11ty/eleventy-plugin-bundle now
|
|
65
|
-
if(options.filters.js) {
|
|
66
|
-
eleventyConfig.addFilter(options.filters.js, (url, bucket) => {
|
|
67
|
-
return eleventyConfig.javascriptFunctions.getBundle("js", bucket)
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
57
|
eleventyConfig.addExtension("webc", {
|
|
72
58
|
outputFileExtension: "html",
|
|
73
59
|
|
|
@@ -81,7 +67,8 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
81
67
|
...this,
|
|
82
68
|
...data,
|
|
83
69
|
}, `Check the permalink for ${inputPath}`, "eleventyWebcPermalink:" + inputPath);
|
|
84
|
-
|
|
70
|
+
|
|
71
|
+
return evaluatedString.returns;
|
|
85
72
|
} catch(e) {
|
|
86
73
|
debug("Error evaluating dynamic permalink, returning raw string contents instead: %o\n%O", contents, e);
|
|
87
74
|
return contents;
|
|
@@ -105,17 +92,17 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
105
92
|
}
|
|
106
93
|
|
|
107
94
|
// Support both casings (I prefer getCss, but yeah)
|
|
108
|
-
page.setHelper("getCss", (url, bucket) => this.config.javascriptFunctions.getBundle("css", bucket), scopedHelpers.has("getCss"));
|
|
109
|
-
page.setHelper("getCSS", (url, bucket) => this.config.javascriptFunctions.getBundle("css", bucket), scopedHelpers.has("getCSS"));
|
|
95
|
+
page.setHelper("getCss", (url, bucket) => this.config.javascriptFunctions.getBundle("css", bucket, url), scopedHelpers.has("getCss"));
|
|
96
|
+
page.setHelper("getCSS", (url, bucket) => this.config.javascriptFunctions.getBundle("css", bucket, url), scopedHelpers.has("getCSS"));
|
|
110
97
|
|
|
111
|
-
page.setHelper("getJs", (url, bucket) => this.config.javascriptFunctions.getBundle("js", bucket), scopedHelpers.has("getJs"));
|
|
112
|
-
page.setHelper("getJS", (url, bucket) => this.config.javascriptFunctions.getBundle("js", bucket), scopedHelpers.has("getJS"));
|
|
98
|
+
page.setHelper("getJs", (url, bucket) => this.config.javascriptFunctions.getBundle("js", bucket, url), scopedHelpers.has("getJs"));
|
|
99
|
+
page.setHelper("getJS", (url, bucket) => this.config.javascriptFunctions.getBundle("js", bucket, url), scopedHelpers.has("getJS"));
|
|
113
100
|
|
|
114
101
|
page.setTransform("11ty", async function(content) {
|
|
115
102
|
let syntax = this["11ty:type"];
|
|
116
103
|
if(syntax) {
|
|
117
|
-
const {
|
|
118
|
-
const CompileString =
|
|
104
|
+
const { RenderPlugin } = await import("@11ty/eleventy");
|
|
105
|
+
const CompileString = RenderPlugin.String;
|
|
119
106
|
|
|
120
107
|
let fn = await CompileString(content, syntax, {
|
|
121
108
|
templateConfig
|
|
@@ -129,6 +116,7 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
129
116
|
return async (data) => {
|
|
130
117
|
// Add Eleventy JavaScript Functions as WebC helpers
|
|
131
118
|
// Note that Universal Filters and Shortcodes populate into javascriptFunctions and will be present here
|
|
119
|
+
|
|
132
120
|
for(let helperName in this.config.javascriptFunctions) {
|
|
133
121
|
let helperFunction = addContextToJavaScriptFunction(data, this.config.javascriptFunctions[helperName]);
|
|
134
122
|
page.setHelper(helperName, helperFunction, scopedHelpers.has(helperName));
|