@content-collections/core 0.14.1 → 0.14.3

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.
Files changed (2) hide show
  1. package/dist/index.js +14 -4
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ import fs2 from "fs";
8
8
  import path2 from "path";
9
9
  import { build } from "esbuild";
10
10
  import { createRequire } from "module";
11
+ import { fileURLToPath } from "node:url";
11
12
  import matter from "gray-matter";
12
13
  import { parse, stringify } from "yaml";
13
14
  import camelcase from "camelcase";
@@ -27,7 +28,9 @@ async function createCacheDirectory(cacheDirectory) {
27
28
  if (!existsSync(cacheDirectory)) await mkdir(cacheDirectory, { recursive: true });
28
29
  }
29
30
  function fileName(input) {
30
- return input.replace(/[^a-z0-9]/gi, "_").toLowerCase();
31
+ const readable = input.replace(/[^a-z0-9]/gi, "_").toLowerCase();
32
+ const hash = createHash("sha1").update(input).digest("hex").slice(0, 12);
33
+ return `${readable.slice(0, 24)}_${hash}`.replace(/^_([a-f0-9]{12})$/, "$1");
31
34
  }
32
35
  async function readMapping(mappingPath) {
33
36
  if (existsSync(mappingPath)) try {
@@ -247,7 +250,7 @@ var loadTsConfigInternal = (dir = process.cwd(), name = "tsconfig.json", isExten
247
250
  var loadTsConfig = (dir, name) => loadTsConfigInternal(dir, name);
248
251
 
249
252
  //#endregion
250
- //#region ../../node_modules/.pnpm/bundle-require@5.0.0_esbuild@0.25.11/node_modules/bundle-require/dist/index.js
253
+ //#region ../../node_modules/.pnpm/bundle-require@5.0.0_esbuild@0.25.12/node_modules/bundle-require/dist/index.js
251
254
  var tsconfigPathsToRegExp = (paths) => {
252
255
  return Object.keys(paths || {}).map((key) => {
253
256
  return /* @__PURE__ */ new RegExp(`^${key.replace(/\*/, ".*")}$`);
@@ -272,14 +275,21 @@ const NON_NODE_MODULE_RE = /^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/;
272
275
  function isCoreImport(path$1, kind) {
273
276
  return path$1 === "@content-collections/core" && kind === "import-statement";
274
277
  }
278
+ function resolveDirname() {
279
+ return dirname(fileURLToPath(import.meta.url));
280
+ }
281
+ function isInternalTest() {
282
+ return process.env.CC_TEST_INDICATOR === "__yes";
283
+ }
275
284
  function createExternalsPlugin(configPath) {
276
285
  const resolvePatterns = tsconfigPathsToRegExp(tsconfigResolvePaths(configPath));
286
+ const currentDir = resolveDirname();
277
287
  return {
278
288
  name: "external-packages",
279
289
  setup: (build$2) => {
280
290
  build$2.onResolve({ filter: /.*/ }, ({ path: path$1, kind }) => {
281
- if (process.env.NODE_ENV === "test" && isCoreImport(path$1, kind)) return {
282
- path: join(__dirname, "index.ts"),
291
+ if (isInternalTest() && isCoreImport(path$1, kind)) return {
292
+ path: join(currentDir, "index.ts"),
283
293
  external: true
284
294
  };
285
295
  if (match(path$1, resolvePatterns)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@content-collections/core",
3
3
  "type": "module",
4
- "version": "0.14.1",
4
+ "version": "0.14.3",
5
5
  "description": "Core of Content Collections",
6
6
  "author": "Sebastian Sdorra <s.sdorra@gmail.com>",
7
7
  "license": "MIT",
@@ -49,7 +49,7 @@
49
49
  "p-limit": "^6.1.0",
50
50
  "picomatch": "^4.0.2",
51
51
  "pluralize": "^8.0.0",
52
- "serialize-javascript": "^6.0.2",
52
+ "serialize-javascript": "^7.0.3",
53
53
  "tinyglobby": "^0.2.5",
54
54
  "yaml": "^2.4.5"
55
55
  },