@apleasantview/eleventy-plugin-baseline 0.1.0-next.20 → 0.1.0-next.22

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.
@@ -7,8 +7,9 @@ import shortcodes from "./core/shortcodes.js";
7
7
  import { eleventyImageOnRequestDuringServePlugin } from "@11ty/eleventy-img";
8
8
 
9
9
  import { createRequire } from "node:module";
10
- const require = createRequire(import.meta.url);
11
- const { version } = require("./package.json");
10
+ const __require = createRequire(import.meta.url);
11
+
12
+ const { name, version } = __require("./package.json");
12
13
 
13
14
  /**
14
15
  * Eleventy Plugin Baseline.
@@ -23,11 +24,11 @@ const { version } = require("./package.json");
23
24
  * @property {Object} [assetsESBuild] Options forwarded to assets-esbuild (minify/target).
24
25
  *
25
26
  * @param {BaselineOptions} [options={}] Custom options for the plugin.
26
- * @returns {(eleventyConfig: UserConfig) => void}
27
+ * @returns {(eleventyConfig: import("@11ty/eleventy").UserConfig) => Promise<void>}
27
28
  */
28
29
  export default function baseline(options = {}) {
29
30
  /** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
30
- return async function (eleventyConfig) {
31
+ const plugin = async function (eleventyConfig) {
31
32
  try {
32
33
  // Emit a warning message if the application is not using Eleventy 3.0 or newer (including prereleases).
33
34
  eleventyConfig.versionCheck(">=3.0");
@@ -38,13 +39,16 @@ export default function baseline(options = {}) {
38
39
  const hasImageTransformPlugin = eleventyConfig.hasPlugin("eleventyImageTransformPlugin");
39
40
 
40
41
  const userOptions = {
41
- version: version,
42
+ version,
43
+ name,
42
44
  verbose: options.verbose ?? false,
45
+ hasImageTransformPlugin,
43
46
  enableNavigatorTemplate: options.enableNavigatorTemplate ?? false,
44
47
  enableSitemapTemplate: options.enableSitemapTemplate ?? true,
48
+ assets: {
49
+ esbuild: options.assetsESBuild ?? { minify: true, target: "es2020" }
50
+ },
45
51
  multilingual: options.multilingual ?? false,
46
- assetsESBuild: options.assetsESBuild ?? { minify: true, target: "es2020" },
47
- hasImageTransformPlugin,
48
52
  ...options
49
53
  };
50
54
 
@@ -79,7 +83,7 @@ export default function baseline(options = {}) {
79
83
  eleventyConfig.addPlugin(modules.EleventyHtmlBasePlugin, { baseHref: process.env.URL || eleventyConfig.pathPrefix });
80
84
  eleventyConfig.addPlugin(modules.assetsCore);
81
85
  eleventyConfig.addPlugin(modules.assetsPostCSS);
82
- eleventyConfig.addPlugin(modules.assetsESBuild, userOptions.assetsESBuild);
86
+ eleventyConfig.addPlugin(modules.assetsESBuild, userOptions.assets.esbuild);
83
87
  eleventyConfig.addPlugin(modules.headCore);
84
88
  eleventyConfig.addPlugin(modules.sitemapCore, { enableSitemapTemplate: userOptions.enableSitemapTemplate, multilingual: isMultilingual, languages });
85
89
 
@@ -100,6 +104,10 @@ export default function baseline(options = {}) {
100
104
  eleventyConfig.addFilter("_keys", debug.keys);
101
105
  eleventyConfig.addPlugin(modules.navigatorCore, { enableNavigatorTemplate: userOptions.enableNavigatorTemplate });
102
106
  };
107
+
108
+ // Set plugin name so `eleventyConfig.hasPlugin()` can detect it.
109
+ Object.defineProperty(plugin, "name", { value: `${name}` });
110
+ return plugin;
103
111
  }
104
112
 
105
113
  export const config = {
@@ -68,9 +68,12 @@ export default function assetsCore(eleventyConfig, options = {}) {
68
68
 
69
69
  eleventyConfig.addGlobalData("_baseline.assets", () => {
70
70
  ensureCache(cache, eleventyConfig, rawDir, verbose);
71
+ // Merge with existing _baseline.assets (e.g., esbuild config)
72
+ const existing = eleventyConfig.globalData?._baseline?.assets || {};
71
73
  return {
72
74
  input: cache.assetsInput,
73
- output: cache.assetsOutput
75
+ output: cache.assetsOutput,
76
+ ...existing
74
77
  };
75
78
  });
76
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apleasantview/eleventy-plugin-baseline",
3
- "version": "0.1.0-next.20",
3
+ "version": "0.1.0-next.22",
4
4
  "description": "An experimental Swiss army knife toolkit for Eleventy",
5
5
  "type": "module",
6
6
  "main": "eleventy.config.js",