@11ty/eleventy-plugin-webc 0.9.2 → 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.
@@ -22,6 +22,10 @@ module.exports = function(eleventyConfig, options = {}) {
22
22
  transformData: {}, // extra global data for transforms specifically
23
23
  }, options);
24
24
 
25
+ options.bundlePluginOptions = Object.assign({
26
+ hoistDuplicateBundlesFor: ["css", "js"]
27
+ }, options.bundlePluginOptions);
28
+
25
29
  // Deprecated: this lives in @11ty/eleventy-plugin-bundle now
26
30
  options.filters = filters;
27
31
 
@@ -51,7 +55,7 @@ module.exports = function(eleventyConfig, options = {}) {
51
55
  // If the bundle plugin has not been added, we add it here:
52
56
  let bundlePlugin = eleventyConfig.plugins.find(entry => entry.plugin.eleventyPackage === "@11ty/eleventy-plugin-bundle");
53
57
  if(!bundlePlugin) {
54
- eleventyConfig.addPlugin(eleventyBundlePlugin);
58
+ eleventyConfig.addPlugin(eleventyBundlePlugin, options.bundlePluginOptions);
55
59
  }
56
60
 
57
61
  templatePlugin(eleventyConfig, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@11ty/eleventy-plugin-webc",
3
- "version": "0.9.2",
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.1"
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,