@11ty/eleventy-plugin-webc 0.10.0 → 0.11.0
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 +1 -0
- package/package.json +2 -2
- package/src/eleventyWebcTemplate.js +12 -6
package/eleventyWebcPlugin.js
CHANGED
|
@@ -18,6 +18,7 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
18
18
|
|
|
19
19
|
options = Object.assign({
|
|
20
20
|
components: "_components/**/*.webc", // glob for no-import global components
|
|
21
|
+
scopedHelpers: ["css", "js", "html"],
|
|
21
22
|
useTransform: false, // global transform
|
|
22
23
|
transformData: {}, // extra global data for transforms specifically
|
|
23
24
|
}, options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@11ty/eleventy-plugin-webc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "WebC support for Eleventy adds for Single File Web Components",
|
|
5
5
|
"main": "eleventyWebcPlugin.js",
|
|
6
6
|
"scripts": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@11ty/eleventy": "^2.0.0",
|
|
46
46
|
"@11ty/eleventy-plugin-bundle": "^1.0.4",
|
|
47
|
-
"@11ty/webc": "^0.
|
|
47
|
+
"@11ty/webc": "^0.11.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"ava": "^5.2.0",
|
|
@@ -25,6 +25,7 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
25
25
|
let globalComponentManager;
|
|
26
26
|
let componentsMap = false; // cache the glob search
|
|
27
27
|
let moduleScript;
|
|
28
|
+
let scopedHelpers = new Set(options.scopedHelpers);
|
|
28
29
|
|
|
29
30
|
eleventyConfig.on("eleventy.before", async () => {
|
|
30
31
|
// For ESM in CJS
|
|
@@ -38,6 +39,11 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
38
39
|
}
|
|
39
40
|
});
|
|
40
41
|
|
|
42
|
+
let templateConfig;
|
|
43
|
+
eleventyConfig.on("eleventy.config", (cfg) => {
|
|
44
|
+
templateConfig = cfg;
|
|
45
|
+
});
|
|
46
|
+
|
|
41
47
|
// Deprecated (backwards compat only): this lives in @11ty/eleventy-plugin-bundle now
|
|
42
48
|
if(options.filters.css) {
|
|
43
49
|
eleventyConfig.addFilter(options.filters.css, (url, bucket) => {
|
|
@@ -91,21 +97,21 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
91
97
|
// Add Eleventy JavaScript Functions as WebC helpers
|
|
92
98
|
// Note that Universal Filters and Shortcodes populate into javascriptFunctions and will be present here
|
|
93
99
|
for(let helperName in this.config.javascriptFunctions) {
|
|
94
|
-
page.setHelper(helperName, this.config.javascriptFunctions[helperName]);
|
|
100
|
+
page.setHelper(helperName, this.config.javascriptFunctions[helperName], scopedHelpers.has(helperName));
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
// Support both casings (I prefer getCss, but yeah)
|
|
98
|
-
page.setHelper("getCss", (url, bucket) => this.config.javascriptFunctions.getBundle("css", bucket));
|
|
99
|
-
page.setHelper("getCSS", (url, bucket) => this.config.javascriptFunctions.getBundle("css", bucket));
|
|
104
|
+
page.setHelper("getCss", (url, bucket) => this.config.javascriptFunctions.getBundle("css", bucket), scopedHelpers.has("getCss"));
|
|
105
|
+
page.setHelper("getCSS", (url, bucket) => this.config.javascriptFunctions.getBundle("css", bucket), scopedHelpers.has("getCSS"));
|
|
100
106
|
|
|
101
|
-
page.setHelper("getJs", (url, bucket) => this.config.javascriptFunctions.getBundle("js", bucket));
|
|
102
|
-
page.setHelper("getJS", (url, bucket) => this.config.javascriptFunctions.getBundle("js", bucket));
|
|
107
|
+
page.setHelper("getJs", (url, bucket) => this.config.javascriptFunctions.getBundle("js", bucket), scopedHelpers.has("getJs"));
|
|
108
|
+
page.setHelper("getJS", (url, bucket) => this.config.javascriptFunctions.getBundle("js", bucket), scopedHelpers.has("getJS"));
|
|
103
109
|
|
|
104
110
|
page.setTransform("11ty", async function(content) {
|
|
105
111
|
let syntax = this["11ty:type"];
|
|
106
112
|
if(syntax) {
|
|
107
113
|
let fn = await CompileString(content, syntax, {
|
|
108
|
-
templateConfig
|
|
114
|
+
templateConfig
|
|
109
115
|
});
|
|
110
116
|
return fn(this);
|
|
111
117
|
}
|