Skip to content

Commit

Permalink
Custom lodash build, fixes #2877
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Mar 22, 2023
1 parent a9323c3 commit 30c7113
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 32 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"@11ty/dependency-tree": "^2.0.1",
"@11ty/eleventy-dev-server": "^1.0.4",
"@11ty/eleventy-utils": "^1.0.1",
"@11ty/lodash-custom": "^4.17.21",
"@iarna/toml": "^2.2.5",
"@sindresorhus/slugify": "^1.1.2",
"bcp-47-normalize": "^1.1.1",
Expand All @@ -115,9 +116,6 @@
"iso-639-1": "^2.1.15",
"kleur": "^4.1.5",
"liquidjs": "^10.6.1",
"lodash.chunk": "^4.2.0",
"lodash.get": "^4.4.2",
"lodash.set": "^4.3.2",
"luxon": "^3.3.0",
"markdown-it": "^13.0.1",
"micromatch": "^4.0.5",
Expand Down
14 changes: 3 additions & 11 deletions src/ComputedData.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const lodashGet = require("lodash.get");
const lodashSet = require("lodash.set");
const { set: lodashSet, get: lodashGet } = require("@11ty/lodash-custom");

const ComputedDataQueue = require("./ComputedDataQueue");
const ComputedDataTemplateString = require("./ComputedDataTemplateString");
Expand Down Expand Up @@ -39,20 +38,13 @@ class ComputedData {
}
}

addTemplateString(
key,
renderFn,
declaredDependencies = [],
symbolParseFn = undefined
) {
addTemplateString(key, renderFn, declaredDependencies = [], symbolParseFn = undefined) {
this.add(key, renderFn, declaredDependencies, symbolParseFn);
this.templateStringKeyLookup[key] = true;
}

async resolveVarOrder(data) {
let proxyByTemplateString = new ComputedDataTemplateString(
this.computedKeys
);
let proxyByTemplateString = new ComputedDataTemplateString(this.computedKeys);
let proxyByProxy = new ComputedDataProxy(this.computedKeys);

for (let key of this.computedKeys) {
Expand Down
3 changes: 1 addition & 2 deletions src/ComputedDataProxy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const lodashSet = require("lodash.set");
const lodashGet = require("lodash.get");
const { set: lodashSet, get: lodashGet } = require("@11ty/lodash-custom");
const { isPlainObject } = require("@11ty/eleventy-utils");

/* Calculates computed data using Proxies */
Expand Down
8 changes: 3 additions & 5 deletions src/ComputedDataTemplateString.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const lodashSet = require("lodash.set");
const { set: lodashSet } = require("@11ty/lodash-custom");

const debug = require("debug")("Eleventy:ComputedDataTemplateString");

/* Calculates computed data in Template Strings.
Expand Down Expand Up @@ -38,10 +39,7 @@ class ComputedDataTemplateString {
let vars = new Set();
let splits = output.split(this.prefix);
for (let split of splits) {
let varName = split.slice(
0,
split.indexOf(this.suffix) < 0 ? 0 : split.indexOf(this.suffix)
);
let varName = split.slice(0, split.indexOf(this.suffix) < 0 ? 0 : split.indexOf(this.suffix));
if (varName) {
vars.add(varName);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Engines/Nunjucks.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class Nunjucks extends TemplateEngine {
return ext;
}

/* Outputs an Array of lodash.get selectors */
/* Outputs an Array of lodash get selectors */
parseForSymbols(str) {
const { parser, nodes } = NunjucksLib;
let obj = parser.parse(str, this._getParseExtensions());
Expand Down
4 changes: 1 addition & 3 deletions src/Plugins/Pagination.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const lodashChunk = require("lodash.chunk");
const lodashGet = require("lodash.get");
const lodashSet = require("lodash.set");
const { set: lodashSet, get: lodashGet, chunk: lodashChunk } = require("@11ty/lodash-custom");
const { isPlainObject } = require("@11ty/eleventy-utils");

const EleventyBaseError = require("../EleventyBaseError");
Expand Down
3 changes: 1 addition & 2 deletions src/Template.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ const mkdir = util.promisify(fs.mkdir);
const os = require("os");
const path = require("path");
const normalize = require("normalize-path");
const lodashGet = require("lodash.get");
const lodashSet = require("lodash.set");
const { set: lodashSet, get: lodashGet } = require("@11ty/lodash-custom");
const { DateTime } = require("luxon");
const { TemplatePath, isPlainObject } = require("@11ty/eleventy-utils");

Expand Down
2 changes: 1 addition & 1 deletion src/TemplateContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const util = require("util");
const readFile = util.promisify(fs.readFile);
const normalize = require("normalize-path");
const matter = require("gray-matter");
const lodashSet = require("lodash.set");
const { set: lodashSet } = require("@11ty/lodash-custom");
const { TemplatePath } = require("@11ty/eleventy-utils");

const EleventyExtensionMap = require("./EleventyExtensionMap");
Expand Down
3 changes: 1 addition & 2 deletions src/TemplateData.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const fs = require("fs");
const path = require("path");
const lodashset = require("lodash.set");
const lodashget = require("lodash.get");
const { set: lodashset, get: lodashget } = require("@11ty/lodash-custom");
const { TemplatePath, isPlainObject } = require("@11ty/eleventy-utils");

const merge = require("./Util/Merge");
Expand Down
2 changes: 1 addition & 1 deletion src/TemplateDataInitialGlobalData.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const pkg = require("../package.json");
const semver = require("semver");
const lodashset = require("lodash.set");
const { set: lodashset } = require("@11ty/lodash-custom");

class TemplateDataInitialGlobalData {
constructor(templateConfig) {
Expand Down
2 changes: 1 addition & 1 deletion test/EleventyTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ ${newContents}
await fsp.writeFile(includeFilePath, previousContents, { encoding: "utf8" });
});

const lodashGet = require("lodash.get");
const { get: lodashGet } = require("@11ty/lodash-custom");
test("Lodash get (for pagination data target) object key with spaces, issue #2851", (t) => {
let data = {
collections: {
Expand Down

0 comments on commit 30c7113

Please sign in to comment.