@11ty/eleventy-plugin-webc 0.11.1 → 0.12.0-beta.2
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 +21 -24
- package/package.json +19 -17
- package/src/eleventyWebcTemplate.js +10 -22
package/eleventyWebcPlugin.js
CHANGED
|
@@ -1,35 +1,29 @@
|
|
|
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
|
|
21
21
|
scopedHelpers: ["css", "js", "html"],
|
|
22
22
|
useTransform: false, // global transform
|
|
23
23
|
transformData: {}, // extra global data for transforms specifically
|
|
24
|
+
bundlePluginOptions: {},
|
|
24
25
|
}, options);
|
|
25
26
|
|
|
26
|
-
options.bundlePluginOptions = Object.assign({
|
|
27
|
-
hoistDuplicateBundlesFor: ["css", "js"]
|
|
28
|
-
}, options.bundlePluginOptions);
|
|
29
|
-
|
|
30
|
-
// Deprecated: this lives in @11ty/eleventy-plugin-bundle now
|
|
31
|
-
options.filters = filters;
|
|
32
|
-
|
|
33
27
|
if(options.components) {
|
|
34
28
|
let components = options.components;
|
|
35
29
|
if(!Array.isArray(components)) {
|
|
@@ -52,12 +46,15 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
52
46
|
}
|
|
53
47
|
}
|
|
54
48
|
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
// v0.12.0 upstream `bundlePluginOptions.toFileDirectory` (via Bundle Plugin changes) default changed from "bundle" to ""
|
|
50
|
+
// https://github.com/11ty/eleventy-plugin-bundle/releases/tag/v2.0.0
|
|
51
|
+
let htmlBundleOptions = Object.assign({}, options.bundlePluginOptions, {
|
|
52
|
+
hoist: false, // don’t hoist
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
eleventyConfig.addBundle("html", htmlBundleOptions);
|
|
56
|
+
eleventyConfig.addBundle("css", options.bundlePluginOptions);
|
|
57
|
+
eleventyConfig.addBundle("js", options.bundlePluginOptions);
|
|
61
58
|
|
|
62
59
|
templatePlugin(eleventyConfig, options);
|
|
63
60
|
|
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.2",
|
|
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
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
2
|
const debug = require("debug")("Eleventy:WebC");
|
|
3
3
|
|
|
4
|
-
const { EleventyRenderPlugin } = require("@11ty/eleventy");
|
|
5
|
-
const CompileString = EleventyRenderPlugin.String;
|
|
6
|
-
|
|
7
4
|
function relativePath(inputPath, newGlob) {
|
|
8
5
|
// project root
|
|
9
6
|
if(newGlob.startsWith("~/")) {
|
|
@@ -57,20 +54,6 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
57
54
|
templateConfig = cfg;
|
|
58
55
|
});
|
|
59
56
|
|
|
60
|
-
// Deprecated (backwards compat only): this lives in @11ty/eleventy-plugin-bundle now
|
|
61
|
-
if(options.filters.css) {
|
|
62
|
-
eleventyConfig.addFilter(options.filters.css, (url, bucket) => {
|
|
63
|
-
return eleventyConfig.javascriptFunctions.getBundle("css", bucket);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Deprecated (backwards compat only): this lives in @11ty/eleventy-plugin-bundle now
|
|
68
|
-
if(options.filters.js) {
|
|
69
|
-
eleventyConfig.addFilter(options.filters.js, (url, bucket) => {
|
|
70
|
-
return eleventyConfig.javascriptFunctions.getBundle("js", bucket)
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
57
|
eleventyConfig.addExtension("webc", {
|
|
75
58
|
outputFileExtension: "html",
|
|
76
59
|
|
|
@@ -84,7 +67,8 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
84
67
|
...this,
|
|
85
68
|
...data,
|
|
86
69
|
}, `Check the permalink for ${inputPath}`, "eleventyWebcPermalink:" + inputPath);
|
|
87
|
-
|
|
70
|
+
|
|
71
|
+
return evaluatedString.returns;
|
|
88
72
|
} catch(e) {
|
|
89
73
|
debug("Error evaluating dynamic permalink, returning raw string contents instead: %o\n%O", contents, e);
|
|
90
74
|
return contents;
|
|
@@ -108,15 +92,18 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
108
92
|
}
|
|
109
93
|
|
|
110
94
|
// Support both casings (I prefer getCss, but yeah)
|
|
111
|
-
page.setHelper("getCss", (url, bucket) => this.config.javascriptFunctions.getBundle("css", bucket), scopedHelpers.has("getCss"));
|
|
112
|
-
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"));
|
|
113
97
|
|
|
114
|
-
page.setHelper("getJs", (url, bucket) => this.config.javascriptFunctions.getBundle("js", bucket), scopedHelpers.has("getJs"));
|
|
115
|
-
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"));
|
|
116
100
|
|
|
117
101
|
page.setTransform("11ty", async function(content) {
|
|
118
102
|
let syntax = this["11ty:type"];
|
|
119
103
|
if(syntax) {
|
|
104
|
+
const { RenderPlugin } = await import("@11ty/eleventy");
|
|
105
|
+
const CompileString = RenderPlugin.String;
|
|
106
|
+
|
|
120
107
|
let fn = await CompileString(content, syntax, {
|
|
121
108
|
templateConfig
|
|
122
109
|
});
|
|
@@ -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));
|