@11ty/eleventy-plugin-webc 0.9.3 → 0.9.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@11ty/eleventy-plugin-webc",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
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.3",
|
|
47
|
-
"@11ty/webc": "^0.9.
|
|
47
|
+
"@11ty/webc": "^0.9.3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"ava": "^5.2.0",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
2
|
const debug = require("debug")("Eleventy:WebC");
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
const { EleventyRenderPlugin } = require("@11ty/eleventy");
|
|
6
5
|
const CompileString = EleventyRenderPlugin.String;
|
|
7
6
|
|
|
@@ -23,17 +22,19 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
23
22
|
eleventyConfig.addTemplateFormats("webc");
|
|
24
23
|
|
|
25
24
|
let _WebC;
|
|
25
|
+
let globalComponentManager;
|
|
26
26
|
let componentsMap = false; // cache the glob search
|
|
27
27
|
let moduleScript;
|
|
28
28
|
|
|
29
29
|
eleventyConfig.on("eleventy.before", async () => {
|
|
30
30
|
// For ESM in CJS
|
|
31
|
-
let { WebC, ModuleScript } = await import("@11ty/webc");
|
|
31
|
+
let { WebC, ModuleScript, ComponentManager } = await import("@11ty/webc");
|
|
32
32
|
moduleScript = ModuleScript;
|
|
33
33
|
_WebC = WebC;
|
|
34
|
+
globalComponentManager = new ComponentManager();
|
|
34
35
|
|
|
35
36
|
if(options.components) {
|
|
36
|
-
componentsMap = WebC.getComponentsMap(options.components);
|
|
37
|
+
componentsMap = WebC.getComponentsMap(options.components); // second argument is ignores here
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
|
|
@@ -63,7 +64,7 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
63
64
|
let evaluatedString = await moduleScript.evaluateScript(contents, {
|
|
64
65
|
...this,
|
|
65
66
|
...data,
|
|
66
|
-
}, `Check the permalink for ${inputPath}
|
|
67
|
+
}, `Check the permalink for ${inputPath}`, "eleventyWebcPermalink:" + inputPath);
|
|
67
68
|
return evaluatedString;
|
|
68
69
|
} catch(e) {
|
|
69
70
|
debug("Error evaluating dynamic permalink, returning raw string contents instead: %o\n%O", contents, e);
|
|
@@ -79,6 +80,7 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
79
80
|
compile: async function(inputContent, inputPath) {
|
|
80
81
|
let page = new _WebC();
|
|
81
82
|
|
|
83
|
+
page.setGlobalComponentManager(globalComponentManager);
|
|
82
84
|
page.setBundlerMode(true);
|
|
83
85
|
page.setContent(inputContent, inputPath);
|
|
84
86
|
|
|
@@ -110,6 +112,7 @@ module.exports = function(eleventyConfig, options = {}) {
|
|
|
110
112
|
return content;
|
|
111
113
|
});
|
|
112
114
|
|
|
115
|
+
// Render function
|
|
113
116
|
return async (data) => {
|
|
114
117
|
let setupObject = {
|
|
115
118
|
data,
|