Repository: 11ty/eleventy
Pull request #848 (2020-01-10 13:02:10)

Support for cjs extension in global and local data files
Implements support of `.cjs` (common js) extension in global and local data files as requested in #837  Places `.cjs` before `.js` in priority ordering for local files. For global data order, I need to wait while #821 gets merged.
Changes are very trivial in both the TemplateData.js and tests but a lot of tests were changed due to local data file lists checks.


Patch:
diff --git a/src/TemplateData.js b/src/TemplateData.js
index 7cc66a8e..d246a45b 100644
--- a/src/TemplateData.js
+++ b/src/TemplateData.js
@@ -114,6 +114,7 @@ class TemplateData {
     let dir = await this.getInputDir();
     let paths = [
       `${dir}/**/*.json`, // covers .11tydata.json too
+      `${dir}/**/*${this.config.jsDataFileSuffix}.cjs`,
       `${dir}/**/*${this.config.jsDataFileSuffix}.js`
     ];
 
@@ -146,7 +147,7 @@ class TemplateData {
   }
 
   getGlobalDataExtensionPriorities() {
-    return this.getUserDataExtensions().concat(["json", "js"]);
+    return this.getUserDataExtensions().concat(["json", "cjs", "js"]);
   }
 
   static calculateExtensionPriority(path, priorities) {
@@ -343,6 +344,7 @@ class TemplateData {
     // ignoreProcessing = true for local data files
     if (
       extension === "js" ||
+      extension === "cjs" ||
       (extension === "json" && (ignoreProcessing || !this.dataTemplateEngine))
     ) {
       // JS data file or require’d JSON (no preprocessing needed)
@@ -386,11 +388,13 @@ class TemplateData {
       paths.push(curpath + "." + extension);
     }
   }
+
   _addBaseToPaths(paths, base, extensions) {
     let dataSuffix = this.config.jsDataFileSuffix;
 
     // data suffix
     paths.push(base + dataSuffix + ".js");
+    paths.push(base + dataSuffix + ".cjs");
     paths.push(base + dataSuffix + ".json");
 
     // inject user extensions


Test patch:
diff --git a/test/EleventyFilesTest.js b/test/EleventyFilesTest.js
index 6d7debbc..915c0290 100644
--- a/test/EleventyFilesTest.js
+++ b/test/EleventyFilesTest.js
@@ -558,6 +558,7 @@ test("Glob Watcher Files with Config Passthroughs (no template formats)", async
 
   t.deepEqual(await evf.getGlobWatcherTemplateDataFiles(), [
     "./test/stubs/**/*.json",
+    "./test/stubs/**/*.11tydata.cjs",
     "./test/stubs/**/*.11tydata.js"
   ]);
 });
diff --git a/test/EleventyTest.js b/test/EleventyTest.js
index 19920cda..6d52bc36 100644
--- a/test/EleventyTest.js
+++ b/test/EleventyTest.js
@@ -56,6 +56,7 @@ test("Eleventy file watching", async t => {
     "./test/stubs/_data/**",
     "./.eleventy.js",
     "./test/stubs/**/*.json",
+    "./test/stubs/**/*.11tydata.cjs",
     "./test/stubs/**/*.11tydata.js",
     "./test/stubs/deps/dep1.js",
     "./test/stubs/deps/dep2.js"
@@ -78,6 +79,7 @@ test("Eleventy file watching (no JS dependencies)", async t => {
     "./test/stubs/_data/**",
     "./.eleventy.js",
     "./test/stubs/**/*.json",
+    "./test/stubs/**/*.11tydata.cjs",
     "./test/stubs/**/*.11tydata.js"
   ]);
 });
diff --git a/test/TemplateDataTest.js b/test/TemplateDataTest.js
index baa3aca0..cb58d1ab 100644
--- a/test/TemplateDataTest.js
+++ b/test/TemplateDataTest.js
@@ -53,6 +53,7 @@ test("Add local data", async t => {
 
   // from the js file
   // this checks priority/overrides
+  t.is(withLocalData.localdatakeyfromcjs, "common-js-howdydoody");
   t.is(withLocalData.localdatakeyfromjs, "howdydoody");
   t.is(withLocalData.localdatakeyfromjs2, "howdy2");
 });
@@ -66,6 +67,7 @@ test("Get local data async JS", async t => {
 
   // from the js file
   t.is(withLocalData.localdatakeyfromjs, "howdydoody");
+  t.is(withLocalData.localdatakeyfromcjs, "common-js-howdydoody");
 });
 
 test("addLocalData() doesn’t exist but doesn’t fail (template file does exist)", async t => {
@@ -98,14 +100,16 @@ test("addLocalData() doesn’t exist but doesn’t fail (template file does not
 test("Global Dir Directory", async t => {
   let dataObj = new TemplateData("./");
 
-  t.deepEqual(await dataObj.getGlobalDataGlob(), ["./_data/**/*.(json|js)"]);
+  t.deepEqual(await dataObj.getGlobalDataGlob(), [
+    "./_data/**/*.(json|cjs|js)"
+  ]);
 });
 
 test("Global Dir Directory with Constructor Path Arg", async t => {
   let dataObj = new TemplateData("./test/stubs/");
 
   t.deepEqual(await dataObj.getGlobalDataGlob(), [
-    "./test/stubs/_data/**/*.(json|js)"
+    "./test/stubs/_data/**/*.(json|cjs|js)"
   ]);
 });
 
@@ -155,7 +159,7 @@ test("getAllGlobalData() with js function data file", async t => {
 
   t.true(
     dataFilePaths.filter(path => {
-      return path.indexOf("./test/stubs/_data/globalData2.js") === 0;
+      return path.indexOf("./test/stubs/_data/globalDataFn.js") === 0;
     }).length > 0
   );
 
@@ -163,6 +167,21 @@ test("getAllGlobalData() with js function data file", async t => {
   t.is(data.globalDataFn.datakeyfromjsfn, "howdy");
 });
 
+test("getAllGlobalData() with common js function data file", async t => {
+  let dataObj = new TemplateData("./test/stubs/");
+  let data = await dataObj.cacheData();
+  let dataFilePaths = await dataObj.getGlobalDataFiles();
+
+  t.true(
+    dataFilePaths.filter(path => {
+      return path.indexOf("./test/stubs/_data/globalDataFnCJS.cjs") === 0;
+    }).length > 0
+  );
+
+  t.truthy(data.globalDataFnCJS);
+  t.is(data.globalDataFnCJS.datakeyfromcjsfn, "common-cjs-howdy");
+});
+
 test("getDataValue() without a dataTemplateEngine", async t => {
   let dataObj = new TemplateData("./test/stubs/");
   dataObj.setDataTemplateEngine(false);
@@ -200,9 +219,11 @@ test("getLocalDataPaths", async t => {
   t.deepEqual(paths, [
     "./test/stubs/stubs.json",
     "./test/stubs/stubs.11tydata.json",
+    "./test/stubs/stubs.11tydata.cjs",
     "./test/stubs/stubs.11tydata.js",
     "./test/stubs/component/component.json",
     "./test/stubs/component/component.11tydata.json",
+    "./test/stubs/component/component.11tydata.cjs",
     "./test/stubs/component/component.11tydata.js"
   ]);
 });
@@ -216,12 +237,15 @@ test("Deeper getLocalDataPaths", async t => {
   t.deepEqual(paths, [
     "./test/test.json",
     "./test/test.11tydata.json",
+    "./test/test.11tydata.cjs",
     "./test/test.11tydata.js",
     "./test/stubs/stubs.json",
     "./test/stubs/stubs.11tydata.json",
+    "./test/stubs/stubs.11tydata.cjs",
     "./test/stubs/stubs.11tydata.js",
     "./test/stubs/component/component.json",
     "./test/stubs/component/component.11tydata.json",
+    "./test/stubs/component/component.11tydata.cjs",
     "./test/stubs/component/component.11tydata.js"
   ]);
 });
@@ -235,9 +259,11 @@ test("getLocalDataPaths with an 11ty js template", async t => {
   t.deepEqual(paths, [
     "./test/stubs/stubs.json",
     "./test/stubs/stubs.11tydata.json",
+    "./test/stubs/stubs.11tydata.cjs",
     "./test/stubs/stubs.11tydata.js",
     "./test/stubs/component/component.json",
     "./test/stubs/component/component.11tydata.json",
+    "./test/stubs/component/component.11tydata.cjs",
     "./test/stubs/component/component.11tydata.js"
   ]);
 });
@@ -251,9 +277,11 @@ test("getLocalDataPaths with inputDir passed in (trailing slash)", async t => {
   t.deepEqual(paths, [
     "./test/stubs/stubs.json",
     "./test/stubs/stubs.11tydata.json",
+    "./test/stubs/stubs.11tydata.cjs",
     "./test/stubs/stubs.11tydata.js",
     "./test/stubs/component/component.json",
     "./test/stubs/component/component.11tydata.json",
+    "./test/stubs/component/component.11tydata.cjs",
     "./test/stubs/component/component.11tydata.js"
   ]);
 });
@@ -267,9 +295,11 @@ test("getLocalDataPaths with inputDir passed in (no trailing slash)", async t =>
   t.deepEqual(paths, [
     "./test/stubs/stubs.json",
     "./test/stubs/stubs.11tydata.json",
+    "./test/stubs/stubs.11tydata.cjs",
     "./test/stubs/stubs.11tydata.js",
     "./test/stubs/component/component.json",
     "./test/stubs/component/component.11tydata.json",
+    "./test/stubs/component/component.11tydata.cjs",
     "./test/stubs/component/component.11tydata.js"
   ]);
 });
@@ -283,9 +313,11 @@ test("getLocalDataPaths with inputDir passed in (no leading slash)", async t =>
   t.deepEqual(paths, [
     "./test/stubs/stubs.json",
     "./test/stubs/stubs.11tydata.json",
+    "./test/stubs/stubs.11tydata.cjs",
     "./test/stubs/stubs.11tydata.js",
     "./test/stubs/component/component.json",
     "./test/stubs/component/component.11tydata.json",
+    "./test/stubs/component/component.11tydata.cjs",
     "./test/stubs/component/component.11tydata.js"
   ]);
 });
@@ -302,6 +334,7 @@ test("getTemplateDataFileGlob", async t => {
 
   t.deepEqual(await tw.getTemplateDataFileGlob(), [
     "./test/stubs/**/*.json",
+    "./test/stubs/**/*.11tydata.cjs",
     "./test/stubs/**/*.11tydata.js"
   ]);
 });
diff --git a/test/TemplateTest.js b/test/TemplateTest.js
index c17d0e3d..11db9127 100644
--- a/test/TemplateTest.js
+++ b/test/TemplateTest.js
@@ -452,9 +452,11 @@ test("Local template data file import (without a global data json)", async t =>
   t.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [
     "./test/stubs/stubs.json",
     "./test/stubs/stubs.11tydata.json",
+    "./test/stubs/stubs.11tydata.cjs",
     "./test/stubs/stubs.11tydata.js",
     "./test/stubs/component/component.json",
     "./test/stubs/component/component.11tydata.json",
+    "./test/stubs/component/component.11tydata.cjs",
     "./test/stubs/component/component.11tydata.js"
   ]);
   t.is(data.localdatakey1, "localdatavalue1");
@@ -475,15 +477,19 @@ test("Local template data file import (two subdirectories deep)", async t => {
   t.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [
     "./test/stubs/stubs.json",
     "./test/stubs/stubs.11tydata.json",
+    "./test/stubs/stubs.11tydata.cjs",
     "./test/stubs/stubs.11tydata.js",
     "./test/stubs/firstdir/firstdir.json",
     "./test/stubs/firstdir/firstdir.11tydata.json",
+    "./test/stubs/firstdir/firstdir.11tydata.cjs",
     "./test/stubs/firstdir/firstdir.11tydata.js",
     "./test/stubs/firstdir/seconddir/seconddir.json",
     "./test/stubs/firstdir/seconddir/seconddir.11tydata.json",
+    "./test/stubs/firstdir/seconddir/seconddir.11tydata.cjs",
     "./test/stubs/firstdir/seconddir/seconddir.11tydata.js",
     "./test/stubs/firstdir/seconddir/component.json",
     "./test/stubs/firstdir/seconddir/component.11tydata.json",
+    "./test/stubs/firstdir/seconddir/component.11tydata.cjs",
     "./test/stubs/firstdir/seconddir/component.11tydata.js"
   ]);
 });
@@ -503,12 +509,15 @@ test("Posts inherits local JSON, layouts", async t => {
   t.deepEqual(localDataPaths, [
     "./test/stubs/stubs.json",
     "./test/stubs/stubs.11tydata.json",
+    "./test/stubs/stubs.11tydata.cjs",
     "./test/stubs/stubs.11tydata.js",
     "./test/stubs/posts/posts.json",
     "./test/stubs/posts/posts.11tydata.json",
+    "./test/stubs/posts/posts.11tydata.cjs",
     "./test/stubs/posts/posts.11tydata.js",
     "./test/stubs/posts/post1.json",
     "./test/stubs/posts/post1.11tydata.json",
+    "./test/stubs/posts/post1.11tydata.cjs",
     "./test/stubs/posts/post1.11tydata.js"
   ]);
 
@@ -541,9 +550,11 @@ test("Template and folder name are the same, make sure data imports work ok", as
   t.deepEqual(localDataPaths, [
     "./test/stubs/stubs.json",
     "./test/stubs/stubs.11tydata.json",
+    "./test/stubs/stubs.11tydata.cjs",
     "./test/stubs/stubs.11tydata.js",
     "./test/stubs/posts/posts.json",
     "./test/stubs/posts/posts.11tydata.json",
+    "./test/stubs/posts/posts.11tydata.cjs",
     "./test/stubs/posts/posts.11tydata.js"
   ]);
 
diff --git a/test/UserDataExtensionsTest.js b/test/UserDataExtensionsTest.js
index 3eb24863..0fb25447 100644
--- a/test/UserDataExtensionsTest.js
+++ b/test/UserDataExtensionsTest.js
@@ -16,12 +16,12 @@ test("Local data", async t => {
   let data = await dataObj.getData();
 
   // YAML GLOBAL DATA
-  t.is(data.globalData2.datakey1, "datavalue2");
-  t.is(data.globalData2.datakey2, "@11ty/eleventy--yaml");
+  t.is(data.globalData3.datakey1, "datavalue3");
+  t.is(data.globalData3.datakey2, "@11ty/eleventy--yaml");
 
   // NOSJ (JSON) GLOBAL DATA
-  t.is(data.globalData3.datakey1, "datavalue3");
-  t.is(data.globalData3.datakey2, "@11ty/eleventy--nosj");
+  t.is(data.globalData4.datakey1, "datavalue4");
+  t.is(data.globalData4.datakey2, "@11ty/eleventy--nosj");
 
   let withLocalData = await dataObj.getLocalData(
     "./test/stubs-630/component-yaml/component.njk"
@@ -50,6 +50,7 @@ test("Local files", async t => {
     "./test/stubs-630/stubs-630.11tydata.yaml",
     "./test/stubs-630/stubs-630.11tydata.nosj",
     "./test/stubs-630/stubs-630.11tydata.json",
+    "./test/stubs-630/stubs-630.11tydata.cjs",
     "./test/stubs-630/stubs-630.11tydata.js",
     "./test/stubs-630/component-yaml/component-yaml.yaml",
     "./test/stubs-630/component-yaml/component-yaml.nosj",
@@ -57,6 +58,7 @@ test("Local files", async t => {
     "./test/stubs-630/component-yaml/component-yaml.11tydata.yaml",
     "./test/stubs-630/component-yaml/component-yaml.11tydata.nosj",
     "./test/stubs-630/component-yaml/component-yaml.11tydata.json",
+    "./test/stubs-630/component-yaml/component-yaml.11tydata.cjs",
     "./test/stubs-630/component-yaml/component-yaml.11tydata.js",
     "./test/stubs-630/component-yaml/component.yaml",
     "./test/stubs-630/component-yaml/component.nosj",
@@ -64,6 +66,7 @@ test("Local files", async t => {
     "./test/stubs-630/component-yaml/component.11tydata.yaml",
     "./test/stubs-630/component-yaml/component.11tydata.nosj",
     "./test/stubs-630/component-yaml/component.11tydata.json",
+    "./test/stubs-630/component-yaml/component.11tydata.cjs",
     "./test/stubs-630/component-yaml/component.11tydata.js"
   ]);
 });
@@ -74,7 +77,7 @@ test("Global data", async t => {
   injectDataExtensions(dataObj);
 
   t.deepEqual(await dataObj.getGlobalDataGlob(), [
-    "./test/stubs-630/_data/**/*.(nosj|yaml|json|js)"
+    "./test/stubs-630/_data/**/*.(nosj|yaml|json|cjs|js)"
   ]);
 
   let data = await dataObj.getData();
@@ -82,17 +85,20 @@ test("Global data", async t => {
   // JS GLOBAL DATA
   t.is(data.globalData0.datakey1, "datavalue0");
 
-  // JSON GLOBAL DATA
+  // CJS GLOBAL DATA
   t.is(data.globalData1.datakey1, "datavalue1");
-  t.is(data.globalData1.datakey2, "@11ty/eleventy--json");
 
-  // YAML GLOBAL DATA
+  // JSON GLOBAL DATA
   t.is(data.globalData2.datakey1, "datavalue2");
-  t.is(data.globalData2.datakey2, "@11ty/eleventy--yaml");
+  t.is(data.globalData2.datakey2, "@11ty/eleventy--json");
 
-  // NOSJ (JSON) GLOBAL DATA
+  // YAML GLOBAL DATA
   t.is(data.globalData3.datakey1, "datavalue3");
-  t.is(data.globalData3.datakey2, "@11ty/eleventy--nosj");
+  t.is(data.globalData3.datakey2, "@11ty/eleventy--yaml");
+
+  // NOSJ (JSON) GLOBAL DATA
+  t.is(data.globalData4.datakey1, "datavalue4");
+  t.is(data.globalData4.datakey2, "@11ty/eleventy--nosj");
 
   t.is(data.subdir.globalDataSubdir.keyyaml, "yaml");
 });
@@ -104,12 +110,14 @@ test("Global data merging and priority", async t => {
   let data = await dataObj.getData();
 
   // TESTING GLOBAL DATA PRIORITY AND MERGING
-  t.is(data.mergingGlobalData.datakey1, "js-value1");
+  t.is(data.mergingGlobalData.datakey0, "js-value0");
+  t.is(data.mergingGlobalData.datakey1, "cjs-value1");
   t.is(data.mergingGlobalData.datakey2, "json-value2");
   t.is(data.mergingGlobalData.datakey3, "yaml-value3");
   t.is(data.mergingGlobalData.datakey4, "nosj-value4");
 
   t.is(data.mergingGlobalData.jskey, "js");
+  t.is(data.mergingGlobalData.cjskey, "cjs");
   t.is(data.mergingGlobalData.jsonkey, "json");
   t.is(data.mergingGlobalData.yamlkey, "yaml");
   t.is(data.mergingGlobalData.nosjkey, "nosj");
diff --git a/test/stubs-630/_data/globalData1.cjs b/test/stubs-630/_data/globalData1.cjs
new file mode 100644
index 00000000..891d7575
--- /dev/null
+++ b/test/stubs-630/_data/globalData1.cjs
@@ -0,0 +1,3 @@
+module.exports = {
+  datakey1: "datavalue1"
+};
diff --git a/test/stubs-630/_data/globalData1.json b/test/stubs-630/_data/globalData2.json
similarity index 58%
rename from test/stubs-630/_data/globalData1.json
rename to test/stubs-630/_data/globalData2.json
index 5f02feff..52ad7edd 100644
--- a/test/stubs-630/_data/globalData1.json
+++ b/test/stubs-630/_data/globalData2.json
@@ -1,4 +1,4 @@
 {
-  "datakey1": "datavalue1",
+  "datakey1": "datavalue2",
   "datakey2": "{{pkg.name}}--json"
 }
diff --git a/test/stubs-630/_data/globalData2.yaml b/test/stubs-630/_data/globalData3.yaml
similarity index 59%
rename from test/stubs-630/_data/globalData2.yaml
rename to test/stubs-630/_data/globalData3.yaml
index 9a852bfa..6fad8330 100644
--- a/test/stubs-630/_data/globalData2.yaml
+++ b/test/stubs-630/_data/globalData3.yaml
@@ -1,2 +1,2 @@
-datakey1: datavalue2
+datakey1: datavalue3
 datakey2: "{{pkg.name}}--yaml"
diff --git a/test/stubs-630/_data/globalData3.nosj b/test/stubs-630/_data/globalData4.nosj
similarity index 58%
rename from test/stubs-630/_data/globalData3.nosj
rename to test/stubs-630/_data/globalData4.nosj
index 3f01a07e..6bbdca34 100644
--- a/test/stubs-630/_data/globalData3.nosj
+++ b/test/stubs-630/_data/globalData4.nosj
@@ -1,4 +1,4 @@
 {
-  "datakey1": "datavalue3",
+  "datakey1": "datavalue4",
   "datakey2": "{{pkg.name}}--nosj"
 }
diff --git a/test/stubs-630/_data/mergingGlobalData.cjs b/test/stubs-630/_data/mergingGlobalData.cjs
new file mode 100644
index 00000000..a6b14c8a
--- /dev/null
+++ b/test/stubs-630/_data/mergingGlobalData.cjs
@@ -0,0 +1,5 @@
+module.exports = {
+  datakey0: "cjs-value1",
+  datakey1: "cjs-value1",
+  cjskey: "cjs"
+};
diff --git a/test/stubs-630/_data/mergingGlobalData.js b/test/stubs-630/_data/mergingGlobalData.js
index f99fc138..16712f96 100644
--- a/test/stubs-630/_data/mergingGlobalData.js
+++ b/test/stubs-630/_data/mergingGlobalData.js
@@ -1,4 +1,4 @@
 module.exports = {
-  datakey1: "js-value1",
+  datakey0: "js-value0",
   jskey: "js"
 };
diff --git a/test/stubs-630/_data/mergingGlobalData.json b/test/stubs-630/_data/mergingGlobalData.json
index 68aa73e1..8045904a 100644
--- a/test/stubs-630/_data/mergingGlobalData.json
+++ b/test/stubs-630/_data/mergingGlobalData.json
@@ -1,4 +1,5 @@
 {
+  "datakey0": "json-value1",
   "datakey1": "json-value1",
   "datakey2": "json-value2",
   "jsonkey": "json"
diff --git a/test/stubs-630/_data/mergingGlobalData.nosj b/test/stubs-630/_data/mergingGlobalData.nosj
index 6a015229..3b853f51 100644
--- a/test/stubs-630/_data/mergingGlobalData.nosj
+++ b/test/stubs-630/_data/mergingGlobalData.nosj
@@ -1,4 +1,5 @@
 {
+  "datakey0": "nosj-value1",
   "datakey1": "nosj-value1",
   "datakey2": "nosj-value2",
   "datakey3": "nosj-value3",
diff --git a/test/stubs-630/_data/mergingGlobalData.yaml b/test/stubs-630/_data/mergingGlobalData.yaml
index 916ef7b7..046506a8 100644
--- a/test/stubs-630/_data/mergingGlobalData.yaml
+++ b/test/stubs-630/_data/mergingGlobalData.yaml
@@ -1,3 +1,4 @@
+datakey0: "yaml-value1"
 datakey1: "yaml-value1"
 datakey2: "yaml-value2"
 datakey3: "yaml-value3"
diff --git a/test/stubs/_data/globalDataFnCJS.cjs b/test/stubs/_data/globalDataFnCJS.cjs
new file mode 100644
index 00000000..e6835df9
--- /dev/null
+++ b/test/stubs/_data/globalDataFnCJS.cjs
@@ -0,0 +1,7 @@
+const dep1 = require("../deps/dep1");
+
+module.exports = function() {
+  return {
+    datakeyfromcjsfn: "common-cjs-howdy"
+  };
+};
diff --git a/test/stubs/component-async/component.11tydata.cjs b/test/stubs/component-async/component.11tydata.cjs
new file mode 100644
index 00000000..b0ff52b2
--- /dev/null
+++ b/test/stubs/component-async/component.11tydata.cjs
@@ -0,0 +1,9 @@
+module.exports = async function() {
+  return new Promise(resolve => {
+    setTimeout(function() {
+      resolve({
+        localdatakeyfromcjs: "common-js-howdydoody"
+      });
+    }, 1);
+  });
+};
diff --git a/test/stubs/component/component.11tydata.cjs b/test/stubs/component/component.11tydata.cjs
new file mode 100644
index 00000000..f9b055ac
--- /dev/null
+++ b/test/stubs/component/component.11tydata.cjs
@@ -0,0 +1,5 @@
+const dep2 = require("../deps/dep2");
+
+module.exports = {
+  localdatakeyfromcjs: "common-js-howdydoody"
+};
diff --git a/test/stubs/component/component.11tydata.json b/test/stubs/component/component.11tydata.json
index d0d63736..77c24c74 100644
--- a/test/stubs/component/component.11tydata.json
+++ b/test/stubs/component/component.11tydata.json
@@ -1,4 +1,5 @@
 {
   "localdatakeyfromjs": "this_is_overridden",
+  "localdatakeyfromcjs": "this_is_overridden",
   "localdatakeyfromjs2": "howdy2"
-}
\ No newline at end of file
+}